| 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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 for (var i = 0; i < rootLib.classes.length; i++) { | 312 for (var i = 0; i < rootLib.classes.length; i++) { |
| 313 Class cls = rootLib.classes[i]; | 313 Class cls = rootLib.classes[i]; |
| 314 if (cls.name == className) { | 314 if (cls.name == className) { |
| 315 return cls; | 315 return cls; |
| 316 } | 316 } |
| 317 } | 317 } |
| 318 return null; | 318 return null; |
| 319 } | 319 } |
| 320 | 320 |
| 321 | 321 |
| 322 Future<Instance> rootLibraryFieldValue(Isolate isolate, |
| 323 String fieldName) async { |
| 324 Library rootLib = await isolate.rootLibrary.load(); |
| 325 Field field = rootLib.variables.singleWhere((v) => v.name == fieldName); |
| 326 await field.load(); |
| 327 Instance value = field.staticValue; |
| 328 await value.load(); |
| 329 return value; |
| 330 } |
| 331 |
| 332 |
| 322 /// Runs [tests] in sequence, each of which should take an [Isolate] and | 333 /// Runs [tests] in sequence, each of which should take an [Isolate] and |
| 323 /// return a [Future]. Code for setting up state can run before and/or | 334 /// return a [Future]. Code for setting up state can run before and/or |
| 324 /// concurrently with the tests. Uses [mainArgs] to determine whether | 335 /// concurrently with the tests. Uses [mainArgs] to determine whether |
| 325 /// to run tests or testee in this invokation of the script. | 336 /// to run tests or testee in this invokation of the script. |
| 326 Future runVMTests(List<String> mainArgs, | 337 Future runVMTests(List<String> mainArgs, |
| 327 List<VMTest> tests, | 338 List<VMTest> tests, |
| 328 {Future testeeBefore(), | 339 {Future testeeBefore(), |
| 329 Future testeeConcurrent(), | 340 Future testeeConcurrent(), |
| 330 bool pause_on_start: false, | 341 bool pause_on_start: false, |
| 331 bool pause_on_exit: false, | 342 bool pause_on_exit: false, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 }, onError: (e, st) { | 380 }, onError: (e, st) { |
| 370 process.requestExit(); | 381 process.requestExit(); |
| 371 if (!_isWebSocketDisconnect(e)) { | 382 if (!_isWebSocketDisconnect(e)) { |
| 372 print('Unexpected exception in service tests: $e $st'); | 383 print('Unexpected exception in service tests: $e $st'); |
| 373 throw e; | 384 throw e; |
| 374 } | 385 } |
| 375 }); | 386 }); |
| 376 }); | 387 }); |
| 377 } | 388 } |
| 378 } | 389 } |
| OLD | NEW |