| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 _inChildIsolateFuture = timeout(completer.future, 500, () { | 108 _inChildIsolateFuture = timeout(completer.future, 500, () { |
| 109 port.close(); | 109 port.close(); |
| 110 return false; | 110 return false; |
| 111 }); | 111 }); |
| 112 return _inChildIsolateFuture; | 112 return _inChildIsolateFuture; |
| 113 } | 113 } |
| 114 | 114 |
| 115 /// Runs the test described by [description] in its own isolate. Returns a map | 115 /// Runs the test described by [description] in its own isolate. Returns a map |
| 116 /// describing the results of that test run. | 116 /// describing the results of that test run. |
| 117 Future<Map> _runInIsolate(String description) { | 117 Future<Map> _runInIsolate(String description) { |
| 118 // TODO(nweiz): Don't use path here once issue 8440 is fixed. |
| 118 var future = spawnUri(path.join(path.current, new Options().script)) | 119 var future = spawnUri(path.join(path.current, new Options().script)) |
| 119 .call(description); | 120 .call(description); |
| 120 // TODO(nweiz): Remove this timeout once issue 8417 is fixed and we can | 121 // TODO(nweiz): Remove this timeout once issue 8417 is fixed and we can |
| 121 // capture top-level exceptions. | 122 // capture top-level exceptions. |
| 122 return timeout(future, 30 * 1000, () { | 123 return timeout(future, 30 * 1000, () { |
| 123 throw 'Timed out waiting for test to complete.'; | 124 throw 'Timed out waiting for test to complete.'; |
| 124 }); | 125 }); |
| 125 } | 126 } |
| 126 | 127 |
| 127 /// Returns whether [results] (a test result map) describes a test run in which | 128 /// Returns whether [results] (a test result map) describes a test run in which |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 "message": testCase.message, | 196 "message": testCase.message, |
| 196 "result": testCase.result, | 197 "result": testCase.result, |
| 197 "stackTrace": testCase.stackTrace | 198 "stackTrace": testCase.stackTrace |
| 198 }).toList() | 199 }).toList() |
| 199 }); | 200 }); |
| 200 } | 201 } |
| 201 | 202 |
| 202 void onInit() {} | 203 void onInit() {} |
| 203 void onDone(bool success) {} | 204 void onDone(bool success) {} |
| 204 } | 205 } |
| OLD | NEW |