| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library test_helper; | 5 library test_helper; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 import 'package:observatory/service_io.dart'; | 10 import 'package:observatory/service_io.dart'; |
| 11 import 'package:stack_trace/stack_trace.dart'; |
| 11 import 'service_test_common.dart'; | 12 import 'service_test_common.dart'; |
| 12 | 13 |
| 13 /// Will be set to the http address of the VM's service protocol before | 14 /// Will be set to the http address of the VM's service protocol before |
| 14 /// any tests are invoked. | 15 /// any tests are invoked. |
| 15 String serviceHttpAddress; | 16 String serviceHttpAddress; |
| 16 String serviceWebsocketAddress; | 17 String serviceWebsocketAddress; |
| 17 | 18 |
| 18 const String _TESTEE_ENV_KEY = 'SERVICE_TEST_TESTEE'; | 19 const String _TESTEE_ENV_KEY = 'SERVICE_TEST_TESTEE'; |
| 19 const Map<String, String> _TESTEE_SPAWN_ENV = const { | 20 const Map<String, String> _TESTEE_SPAWN_ENV = const { |
| 20 _TESTEE_ENV_KEY: 'true' | 21 _TESTEE_ENV_KEY: 'true' |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 testeeControlsServer, | 287 testeeControlsServer, |
| 287 useAuthToken, extraArgs).then((Uri serverAddress) async { | 288 useAuthToken, extraArgs).then((Uri serverAddress) async { |
| 288 if (mainArgs.contains("--gdb")) { | 289 if (mainArgs.contains("--gdb")) { |
| 289 var pid = process.process.pid; | 290 var pid = process.process.pid; |
| 290 var wait = new Duration(seconds: 10); | 291 var wait = new Duration(seconds: 10); |
| 291 print("Testee has pid $pid, waiting $wait before continuing"); | 292 print("Testee has pid $pid, waiting $wait before continuing"); |
| 292 sleep(wait); | 293 sleep(wait); |
| 293 } | 294 } |
| 294 setupAddresses(serverAddress); | 295 setupAddresses(serverAddress); |
| 295 var name = Platform.script.pathSegments.last; | 296 var name = Platform.script.pathSegments.last; |
| 296 try { | 297 Chain.capture(() async { |
| 297 var vm = | 298 var vm = |
| 298 new WebSocketVM(new WebSocketVMTarget(serviceWebsocketAddress)); | 299 new WebSocketVM(new WebSocketVMTarget(serviceWebsocketAddress)); |
| 299 print('Loading VM...'); | 300 print('Loading VM...'); |
| 300 await vm.load(); | 301 await vm.load(); |
| 301 print('Done loading VM'); | 302 print('Done loading VM'); |
| 302 | 303 |
| 303 // Run vm tests. | 304 // Run vm tests. |
| 304 if (vmTests != null) { | 305 if (vmTests != null) { |
| 305 var testIndex = 1; | 306 var testIndex = 1; |
| 306 var totalTests = vmTests.length; | 307 var totalTests = vmTests.length; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 321 vm.verbose = verbose_vm; | 322 vm.verbose = verbose_vm; |
| 322 print('Running $name [$testIndex/$totalTests]'); | 323 print('Running $name [$testIndex/$totalTests]'); |
| 323 testIndex++; | 324 testIndex++; |
| 324 await test(isolate); | 325 await test(isolate); |
| 325 } | 326 } |
| 326 } | 327 } |
| 327 | 328 |
| 328 print('All service tests completed successfully.'); | 329 print('All service tests completed successfully.'); |
| 329 testsDone = true; | 330 testsDone = true; |
| 330 await process.requestExit(); | 331 await process.requestExit(); |
| 331 } catch (error, stackTrace) { | 332 }, onError: (error, stackTrace) { |
| 332 if (testsDone) { | 333 if (testsDone) { |
| 333 print('Ignoring late exception during process exit:\n' | 334 print('Ignoring late exception during process exit:\n' |
| 334 '$error\n#stackTrace'); | 335 '$error\n#stackTrace'); |
| 335 } else { | 336 } else { |
| 336 process.requestExit(); | 337 process.requestExit(); |
| 337 print('Unexpected exception in service tests: $error\n$stackTrace'); | 338 print('Unexpected exception in service tests: $error\n$stackTrace'); |
| 338 rethrow; | 339 throw error; |
| 339 } | 340 } |
| 340 } | 341 }); |
| 341 }); | 342 }); |
| 342 } | 343 } |
| 343 | 344 |
| 344 | 345 |
| 345 | 346 |
| 346 Future<Isolate> getFirstIsolate(WebSocketVM vm) async { | 347 Future<Isolate> getFirstIsolate(WebSocketVM vm) async { |
| 347 if (vm.isolates.isNotEmpty) { | 348 if (vm.isolates.isNotEmpty) { |
| 348 var isolate = await vm.isolates.first.load(); | 349 var isolate = await vm.isolates.first.load(); |
| 349 if (isolate is Isolate) { | 350 if (isolate is Isolate) { |
| 350 return isolate; | 351 return isolate; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 new _ServiceTesterRunner().run( | 481 new _ServiceTesterRunner().run( |
| 481 mainArgs: mainArgs, | 482 mainArgs: mainArgs, |
| 482 extraArgs: extraArgs, | 483 extraArgs: extraArgs, |
| 483 vmTests: tests, | 484 vmTests: tests, |
| 484 pause_on_start: pause_on_start, | 485 pause_on_start: pause_on_start, |
| 485 pause_on_exit: pause_on_exit, | 486 pause_on_exit: pause_on_exit, |
| 486 verbose_vm: verbose_vm, | 487 verbose_vm: verbose_vm, |
| 487 pause_on_unhandled_exceptions: pause_on_unhandled_exceptions); | 488 pause_on_unhandled_exceptions: pause_on_unhandled_exceptions); |
| 488 } | 489 } |
| 489 } | 490 } |
| OLD | NEW |