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

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

Issue 1074053002: Run service tests in a zone that gracefully handles websocket disconnections (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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 666c9c338a645b2b12e3118a8e0075d640e0e2e3..3dddedd351cc0760ff8cbd4df2c7b3a6bf1d72b9 100644
--- a/runtime/observatory/tests/service/test_helper.dart
+++ b/runtime/observatory/tests/service/test_helper.dart
@@ -10,6 +10,13 @@ import 'dart:convert';
import 'dart:io';
import 'package:observatory/service_io.dart';
+bool _isWebSocketDisconnect(e) {
+ if (e is! ServiceException) {
+ return false;
+ }
+ return (e as ServiceException).message == 'WebSocket disconnected';
+}
+
// This invocation should set up the state being tested.
const String _TESTEE_MODE_FLAG = "--testee-mode";
@@ -102,13 +109,20 @@ void runIsolateTests(List<String> mainArgs,
var testIndex = 0;
var totalTests = tests.length - 1;
var name = Platform.script.pathSegments.last;
- new WebSocketVM(new WebSocketVMTarget(addr)).load()
- .then((VM vm) => vm.isolates.first.load())
- .then((Isolate isolate) => Future.forEach(tests, (test) {
- print('Running $name [$testIndex/$totalTests]');
- testIndex++;
- return test(isolate);
- })).then((_) => process.requestExit());
+ runZoned(() {
+ new WebSocketVM(new WebSocketVMTarget(addr)).load()
+ .then((VM vm) => vm.isolates.first.load())
+ .then((Isolate isolate) => Future.forEach(tests, (test) {
+ print('Running $name [$testIndex/$totalTests]');
+ testIndex++;
+ return test(isolate);
+ })).then((_) => process.requestExit());
+ }, onError: (e, st) {
+ if (!_isWebSocketDisconnect(e)) {
+ print('Unexpected exception in service tests: $e $st');
+ throw e;
+ }
+ });
});
}
}
@@ -156,12 +170,19 @@ Future runVMTests(List<String> mainArgs,
var testIndex = 0;
var totalTests = tests.length - 1;
var name = Platform.script.pathSegments.last;
- new WebSocketVM(new WebSocketVMTarget(addr)).load()
- .then((VM vm) => Future.forEach(tests, (test) {
- print('Running $name [$testIndex/$totalTests]');
- testIndex++;
- return test(vm);
- })).then((_) => process.requestExit());
+ runZoned(() {
+ new WebSocketVM(new WebSocketVMTarget(addr)).load()
+ .then((VM vm) => Future.forEach(tests, (test) {
+ print('Running $name [$testIndex/$totalTests]');
+ testIndex++;
+ return test(vm);
+ })).then((_) => process.requestExit());
+ }, onError: (e, st) {
+ if (!_isWebSocketDisconnect(e)) {
+ print('Unexpected exception in service tests: $e $st');
+ throw e;
+ }
+ });
});
}
}
« 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