| 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 /// A test library for testing test libraries? We must go deeper. | 5 /// A test library for testing test libraries? We must go deeper. |
| 6 /// | 6 /// |
| 7 /// Since unit testing code tends to use a lot of global state, it can be tough | 7 /// Since unit testing code tends to use a lot of global state, it can be tough |
| 8 /// to test. This library manages it by running each test case in a child | 8 /// to test. This library manages it by running each test case in a child |
| 9 /// isolate, then reporting the results back to the parent isolate. | 9 /// isolate, then reporting the results back to the parent isolate. |
| 10 library metatest; | 10 library metatest; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 port.close(); | 126 port.close(); |
| 127 return false; | 127 return false; |
| 128 }); | 128 }); |
| 129 return _inChildIsolateFuture; | 129 return _inChildIsolateFuture; |
| 130 } | 130 } |
| 131 | 131 |
| 132 /// Runs the test described by [description] in its own isolate. Returns a map | 132 /// Runs the test described by [description] in its own isolate. Returns a map |
| 133 /// describing the results of that test run. | 133 /// describing the results of that test run. |
| 134 Future<Map> _runInIsolate(String description) { | 134 Future<Map> _runInIsolate(String description) { |
| 135 // TODO(nweiz): Don't use path here once issue 8440 is fixed. | 135 // TODO(nweiz): Don't use path here once issue 8440 is fixed. |
| 136 var future = spawnUri(path.join(path.current, new Options().script)).call({ | 136 var future = spawnUri(path.join(path.current, Platform.script)).call({ |
| 137 'testToRun': description, | 137 'testToRun': description, |
| 138 'executable': new Options().executable | 138 'executable': Platform.executable |
| 139 }); | 139 }); |
| 140 // TODO(nweiz): Remove this timeout once issue 8417 is fixed and we can | 140 // TODO(nweiz): Remove this timeout once issue 8417 is fixed and we can |
| 141 // capture top-level exceptions. | 141 // capture top-level exceptions. |
| 142 return timeout(future, 30 * 1000, () { | 142 return timeout(future, 30 * 1000, () { |
| 143 throw 'Timed out waiting for test to complete.'; | 143 throw 'Timed out waiting for test to complete.'; |
| 144 }); | 144 }); |
| 145 } | 145 } |
| 146 | 146 |
| 147 /// Returns whether [results] (a test result map) describes a test run in which | 147 /// Returns whether [results] (a test result map) describes a test run in which |
| 148 /// an error occurred. | 148 /// an error occurred. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 "message": testCase.message, | 217 "message": testCase.message, |
| 218 "result": testCase.result, | 218 "result": testCase.result, |
| 219 "stackTrace": testCase.stackTrace | 219 "stackTrace": testCase.stackTrace |
| 220 }).toList() | 220 }).toList() |
| 221 }); | 221 }); |
| 222 } | 222 } |
| 223 | 223 |
| 224 void onInit() {} | 224 void onInit() {} |
| 225 void onDone(bool success) {} | 225 void onDone(bool success) {} |
| 226 } | 226 } |
| OLD | NEW |