Reland "Serve DevTools when running flutter test (#123607)" (#124058)

Originally reverted due to a misattributed hot reload benchmark
regression.

This reverts commit f5bce716e1.
This commit is contained in:
Ben Konyi
2023-04-04 19:44:14 -04:00
committed by GitHub
parent 38805a4392
commit d83c510de9
2 changed files with 61 additions and 6 deletions

View File

@@ -222,7 +222,7 @@ void main() {
final Completer<Uri> completer = Completer<Uri>();
final RegExp vmServiceUriRegExp = RegExp(r'((http)?:\/\/)[^\s]+');
sub = process.stdout.transform(utf8.decoder).listen((String e) {
if (vmServiceUriRegExp.hasMatch(e)) {
if (!completer.isCompleted && vmServiceUriRegExp.hasMatch(e)) {
completer.complete(Uri.parse(vmServiceUriRegExp.firstMatch(e)!.group(0)!));
}
});
@@ -237,6 +237,31 @@ void main() {
process.kill();
}
});
testWithoutContext('flutter test should serve DevTools', () async {
late final Process process;
late final StreamSubscription<String> sub;
try {
process = await _runFlutterTestConcurrent('trivial', automatedTestsDirectory, flutterTestDirectory,
extraArguments: const <String>['--start-paused']);
final Completer<Uri> completer = Completer<Uri>();
final RegExp devToolsUriRegExp = RegExp(r'The Flutter DevTools debugger and profiler is available at: (http://[^\s]+)');
sub = process.stdout.transform(utf8.decoder).listen((String e) {
if (!completer.isCompleted && devToolsUriRegExp.hasMatch(e)) {
completer.complete(Uri.parse(devToolsUriRegExp.firstMatch(e)!.group(1)!));
}
});
final Uri devToolsUri = await completer.future;
final HttpClient client = HttpClient();
final HttpClientRequest request = await client.getUrl(devToolsUri);
final HttpClientResponse response = await request.close();
final String content = await response.transform(utf8.decoder).join();
expect(content.contains('DevTools'), true);
} finally {
await sub.cancel();
process.kill();
}
});
}
Future<void> _testFile(