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'; |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 } | 248 } |
249 | 249 |
250 void requestExit() { | 250 void requestExit() { |
251 print('** Killing script'); | 251 print('** Killing script'); |
252 if (process.kill()) { | 252 if (process.kill()) { |
253 killedByTester = true; | 253 killedByTester = true; |
254 } | 254 } |
255 } | 255 } |
256 } | 256 } |
257 | 257 |
| 258 // A tester runner that doesn't spawn a process but instead connects to |
| 259 // an already running flutter application running on a device. Assumes |
| 260 // port 8100. This is only useful for debugging. |
| 261 class _FlutterDeviceServiceTesterRunner { |
| 262 void run({List<String> mainArgs, |
| 263 List<VMTest> vmTests, |
| 264 List<IsolateTest> isolateTests, |
| 265 bool pause_on_start: false, |
| 266 bool pause_on_exit: false, |
| 267 bool trace_service: false, |
| 268 bool trace_compiler: false, |
| 269 bool verbose_vm: false, |
| 270 bool pause_on_unhandled_exceptions: false}) { |
| 271 var port = 8100; |
| 272 serviceWebsocketAddress = 'ws://localhost:$port/ws'; |
| 273 serviceHttpAddress = 'http://localhost:$port'; |
| 274 var name = Platform.script.pathSegments.last; |
| 275 runZoned(() async { |
| 276 var vm = |
| 277 new WebSocketVM(new WebSocketVMTarget(serviceWebsocketAddress)); |
| 278 print('Loading VM...'); |
| 279 await vm.load(); |
| 280 print('Done loading VM'); |
| 281 |
| 282 // Run vm tests. |
| 283 if (vmTests != null) { |
| 284 var testIndex = 1; |
| 285 var totalTests = vmTests.length; |
| 286 for (var test in vmTests) { |
| 287 vm.verbose = verbose_vm; |
| 288 print('Running $name [$testIndex/$totalTests]'); |
| 289 testIndex++; |
| 290 await test(vm); |
| 291 } |
| 292 } |
| 293 |
| 294 // Run isolate tests. |
| 295 if (isolateTests != null) { |
| 296 var isolate = await vm.isolates.first.load(); |
| 297 var testIndex = 1; |
| 298 var totalTests = isolateTests.length; |
| 299 for (var test in isolateTests) { |
| 300 vm.verbose = verbose_vm; |
| 301 print('Running $name [$testIndex/$totalTests]'); |
| 302 testIndex++; |
| 303 await test(isolate); |
| 304 } |
| 305 } |
| 306 }, onError: (e, st) { |
| 307 if (!_isWebSocketDisconnect(e)) { |
| 308 print('Unexpected exception in service tests: $e $st'); |
| 309 throw e; |
| 310 } |
| 311 }); |
| 312 } |
| 313 } |
| 314 |
258 class _ServiceTesterRunner { | 315 class _ServiceTesterRunner { |
259 void run({List<String> mainArgs, | 316 void run({List<String> mainArgs, |
260 List<VMTest> vmTests, | 317 List<VMTest> vmTests, |
261 List<IsolateTest> isolateTests, | 318 List<IsolateTest> isolateTests, |
262 bool pause_on_start: false, | 319 bool pause_on_start: false, |
263 bool pause_on_exit: false, | 320 bool pause_on_exit: false, |
264 bool trace_service: false, | 321 bool trace_service: false, |
265 bool trace_compiler: false, | 322 bool trace_compiler: false, |
266 bool verbose_vm: false, | 323 bool verbose_vm: false, |
267 bool pause_on_unhandled_exceptions: false}) { | 324 bool pause_on_unhandled_exceptions: false}) { |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 mainArgs: mainArgs, | 479 mainArgs: mainArgs, |
423 vmTests: tests, | 480 vmTests: tests, |
424 pause_on_start: pause_on_start, | 481 pause_on_start: pause_on_start, |
425 pause_on_exit: pause_on_exit, | 482 pause_on_exit: pause_on_exit, |
426 trace_service: trace_service, | 483 trace_service: trace_service, |
427 trace_compiler: trace_compiler, | 484 trace_compiler: trace_compiler, |
428 verbose_vm: verbose_vm, | 485 verbose_vm: verbose_vm, |
429 pause_on_unhandled_exceptions: pause_on_unhandled_exceptions); | 486 pause_on_unhandled_exceptions: pause_on_unhandled_exceptions); |
430 } | 487 } |
431 } | 488 } |
OLD | NEW |