Chromium Code Reviews| 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 // Helper functions and classes for running a set of unittests in a | 5 // Helper functions and classes for running a set of unittests in a |
| 6 // remote isolate. | 6 // remote isolate. |
| 7 // Used to test Isolate.spawn because dartium/drt does not allow it in the DOM | 7 // Used to test Isolate.spawn because dartium/drt does not allow it in the DOM |
| 8 // isolate. | 8 // isolate. |
| 9 | 9 |
| 10 import "dart:isolate"; | 10 import "dart:isolate"; |
| 11 import "package:unittest/unittest.dart"; | 11 import "package:unittest/unittest.dart"; |
| 12 @MirrorsUsed(symbols: "main", targets: "main", override: "*") | 12 @MirrorsUsed(symbols: "main", targets: "main", override: "*") |
| 13 import "dart:mirrors"; | 13 import "dart:mirrors"; |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * Use this function at the beginning of the main method: | 16 * Use this function at the beginning of the main method: |
| 17 * | 17 * |
| 18 * void main([args, port]) { | 18 * void main([args, port]) { |
| 19 * if (testRemote(main, port)) return; | 19 * if (testRemote(main, port)) return; |
| 20 * // the usual test. | 20 * // the usual test. |
|
sra1
2017/03/21 01:43:48
??
Jacob
2017/03/21 02:25:36
Done.
| |
| 21 * } | 21 * } |
| 22 * | 22 * |
| 23 * Remember to import unittest using the URI `package:inittest/unittest.dart`. | 23 * Remember to import unittest using the URI `package:inittest/unittest.dart`. |
| 24 * Otherwise it won't be sharing the `unittestConfiguration` with this library, | 24 * Otherwise it won't be sharing the `unittestConfiguration` with this library, |
| 25 * and the override set below won't work. | 25 * and the override set below won't work. |
| 26 * | 26 * |
| 27 * Returns `true` if the tests are being run remotely, and | 27 * Returns `true` if the tests are being run remotely, and |
| 28 * `false` if the tests should be run locally. | 28 * `false` if the tests should be run locally. |
| 29 */ | 29 */ |
| 30 bool testRemote(Function main, SendPort port) { | 30 bool testRemote(Function main, SendPort port) { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 var result = response[2]; | 125 var result = response[2]; |
| 126 var message = response[3]; | 126 var message = response[3]; |
| 127 if (result == FAIL) { | 127 if (result == FAIL) { |
| 128 fail(message); | 128 fail(message); |
| 129 } else if (result == ERROR) { | 129 } else if (result == ERROR) { |
| 130 throw message; | 130 throw message; |
| 131 } | 131 } |
| 132 }); | 132 }); |
| 133 }); | 133 }); |
| 134 } | 134 } |
| OLD | NEW |