Unverified Commit bcd28e7e authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Don't pause on tool tests (#35657)

parent e1d43124
...@@ -47,7 +47,7 @@ class CoverageCollector extends TestWatcher { ...@@ -47,7 +47,7 @@ class CoverageCollector extends TestWatcher {
/// has been run to completion so that all coverage data has been recorded. /// has been run to completion so that all coverage data has been recorded.
/// ///
/// The returned [Future] completes when the coverage is collected. /// The returned [Future] completes when the coverage is collected.
Future<void> collectCoverageIsolate(Uri observatoryUri, String debugName) async { Future<void> collectCoverageIsolate(Uri observatoryUri) async {
assert(observatoryUri != null); assert(observatoryUri != null);
print('collecting coverage data from $observatoryUri...'); print('collecting coverage data from $observatoryUri...');
final Map<String, dynamic> data = await collect(observatoryUri, (String libraryName) { final Map<String, dynamic> data = await collect(observatoryUri, (String libraryName) {
...@@ -56,7 +56,7 @@ class CoverageCollector extends TestWatcher { ...@@ -56,7 +56,7 @@ class CoverageCollector extends TestWatcher {
return (coverageDirectory != null) return (coverageDirectory != null)
|| (flutterProject == null) || (flutterProject == null)
|| libraryName.contains(flutterProject.manifest.appName); || libraryName.contains(flutterProject.manifest.appName);
}, waitPaused: true, debugName: debugName); });
if (data == null) { if (data == null) {
throw Exception('Failed to collect coverage.'); throw Exception('Failed to collect coverage.');
} }
...@@ -196,28 +196,6 @@ Future<Map<String, dynamic>> collect(Uri serviceUri, bool Function(String) libra ...@@ -196,28 +196,6 @@ Future<Map<String, dynamic>> collect(Uri serviceUri, bool Function(String) libra
}) async { }) async {
final VMService vmService = await connector(serviceUri); final VMService vmService = await connector(serviceUri);
await vmService.getVM(); await vmService.getVM();
if (!waitPaused) {
return _getAllCoverage(vmService, libraryPredicate);
}
final Isolate isolate = vmService.vm.isolates.firstWhere((Isolate isolate) => isolate.name == debugName);
const int kPollAttempts = 20;
int i = 0;
while (i < kPollAttempts) {
await isolate.load();
if (isolate.pauseEvent?.kind == ServiceEvent.kPauseStart) {
break;
}
await Future<void>.delayed(const Duration(milliseconds: 50));
i += 1;
}
if (i == kPollAttempts) {
print('Isolate $debugName was never paused, refusing to collect coverage');
return const <String, dynamic>{
'type': 'CodeCoverage',
'coverage': <Object>[]
};
}
print('isolate is paused, collecting coverage...');
return _getAllCoverage(vmService, libraryPredicate); return _getAllCoverage(vmService, libraryPredicate);
} }
......
...@@ -77,10 +77,8 @@ class VMPlatform extends PlatformPlugin { ...@@ -77,10 +77,8 @@ class VMPlatform extends PlatformPlugin {
final dynamic channel = IsolateChannel<Object>.connectReceive(receivePort) final dynamic channel = IsolateChannel<Object>.connectReceive(receivePort)
.transformStream(StreamTransformer<Object, Object>.fromHandlers(handleDone: (EventSink<Object> sink) async { .transformStream(StreamTransformer<Object, Object>.fromHandlers(handleDone: (EventSink<Object> sink) async {
try { try {
// Pause the isolate so it is ready for coverage collection.
isolate.pause();
// this will throw if collection fails. // this will throw if collection fails.
await coverageCollector.collectCoverageIsolate(info.serverUri, path); await coverageCollector.collectCoverageIsolate(info.serverUri);
} finally { } finally {
isolate.kill(priority: Isolate.immediate); isolate.kill(priority: Isolate.immediate);
isolate = null; isolate = null;
...@@ -117,14 +115,13 @@ class VMPlatform extends PlatformPlugin { ...@@ -117,14 +115,13 @@ class VMPlatform extends PlatformPlugin {
return await Isolate.spawnUri(p.toUri(testPath), <String>[], message, return await Isolate.spawnUri(p.toUri(testPath), <String>[], message,
packageConfig: p.toUri('.packages'), packageConfig: p.toUri('.packages'),
checked: true, checked: true,
debugName: path,
); );
} }
@override @override
Future<void> close() async { Future<void> close() async {
try { try {
await Future.wait(_pending.values).timeout(const Duration(seconds: 10)); await Future.wait(_pending.values).timeout(const Duration(minutes: 1));
} on TimeoutException { } on TimeoutException {
// TODO(jonahwilliams): resolve whether there are any specific tests that // TODO(jonahwilliams): resolve whether there are any specific tests that
// get stuck or if it is a general infra issue with how we are collecting // get stuck or if it is a general infra issue with how we are collecting
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment