Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(352)

Unified Diff: runtime/observatory/tests/service/test_helper.dart

Issue 2670303003: Make service tests more resilient to isolate load timing (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/observatory/tests/service/test_helper.dart
diff --git a/runtime/observatory/tests/service/test_helper.dart b/runtime/observatory/tests/service/test_helper.dart
index 58162431f0d13324955ed65fed1273f799f9e5c1..2266df9a68f095dc6e6da9a7bae0e6dc41c7b8a5 100644
--- a/runtime/observatory/tests/service/test_helper.dart
+++ b/runtime/observatory/tests/service/test_helper.dart
@@ -315,7 +315,7 @@ class _ServiceTesterRunner {
// Run isolate tests.
if (isolateTests != null) {
- var isolate = await vm.isolates.first.load();
+ var isolate = await getIsolate(vm);
var testIndex = 1;
var totalTests = isolateTests.length;
for (var test in isolateTests) {
@@ -341,6 +341,50 @@ class _ServiceTesterRunner {
});
});
}
+
+
+
+ Future<Isolate> getIsolate(WebSocketVM vm) async {
Cutch 2017/02/08 15:45:59 naming nit: getFirstIsolate
+ if (vm.isolates.isNotEmpty) {
+ var isolate = await vm.isolates.first.load();
+ if (isolate is Isolate) {
+ return isolate;
+ }
+ }
+
+ Completer completer = new Completer();
+ vm.getEventStream(VM.kIsolateStream).then((stream) {
+ var subscription;
+ subscription = stream.listen((ServiceEvent event) async {
+ if (completer == null) {
+ subscription.cancel();
+ return;
+ }
+ if (event.kind == ServiceEvent.kIsolateRunnable) {
+ if (vm.isolates.isNotEmpty) {
+ vm.isolates.first.load().then((result) {
+ if (result is Isolate) {
+ subscription.cancel();
+ completer.complete(result);
+ completer = null;
+ }
+ });
+ }
+ }
+ });
+ });
+
+ // The isolate may have started before we subscribed.
+ if (vm.isolates.isNotEmpty) {
+ vm.isolates.first.reload().then((result) async {
+ if (completer != null && result is Isolate) {
+ completer.complete(result);
+ completer = null;
+ }
+ });
+ }
+ return await completer.future;
+ }
}
/// Runs [tests] in sequence, each of which should take an [Isolate] and
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698