| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of test_controller; | 5 part of test_controller; |
| 6 | 6 |
| 7 /** Path to DRT executable. */ | 7 /** Path to DRT executable. */ |
| 8 String drt; | 8 String drt; |
| 9 | 9 |
| 10 /** Whether to include elapsed time. */ | 10 /** Whether to include elapsed time. */ |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 | 197 |
| 198 void onSummary(int passed, int failed, int errors, | 198 void onSummary(int passed, int failed, int errors, |
| 199 List<TestCase> results, String uncaughtError) { | 199 List<TestCase> results, String uncaughtError) { |
| 200 TestCase test = results[0]; | 200 TestCase test = results[0]; |
| 201 parentPort.send([test.result, test.runningTime.inMilliseconds, | 201 parentPort.send([test.result, test.runningTime.inMilliseconds, |
| 202 test.message, test.stackTrace.toString()]); | 202 test.message, test.stackTrace.toString()]); |
| 203 } | 203 } |
| 204 } | 204 } |
| 205 | 205 |
| 206 var parentPort; | 206 var parentPort; |
| 207 runChildTest() { | 207 runChildTest(message) { |
| 208 port.receive((testName, sendport) { | 208 var testName = message[0]; |
| 209 parentPort = sendport; | 209 parentPort = message[1]; |
| 210 unittestConfiguration = new TestRunnerChildConfiguration(); | 210 unittestConfiguration = new TestRunnerChildConfiguration(); |
| 211 groupSep = marker; | 211 groupSep = marker; |
| 212 group('', test.main); | 212 group('', test.main); |
| 213 filterTests(testName); | 213 filterTests(testName); |
| 214 runTests(); | 214 runTests(); |
| 215 }); | |
| 216 } | 215 } |
| 217 | 216 |
| 218 isolatedTestParentWrapper(testCase) => () { | 217 isolatedTestParentWrapper(testCase) => () { |
| 219 SendPort childPort = spawnFunction(runChildTest); | 218 ReceivePort response = new ReceivePort(); |
| 220 var f = childPort.call(testCase.description); | 219 return Isolate.spawn(runChildTest, [testCase.description, response.sendPort]) |
| 221 f.then((results) { | 220 .then((_) => response.first) |
| 221 .then((results) { |
| 222 var result = results[0]; | 222 var result = results[0]; |
| 223 var duration = new Duration(milliseconds: results[1]); | 223 var duration = new Duration(milliseconds: results[1]); |
| 224 var message = results[2]; | 224 var message = results[2]; |
| 225 var stack = results[3]; | 225 var stack = results[3]; |
| 226 if (result == 'fail') { | 226 if (result == 'fail') { |
| 227 testCase.fail(message, stack); | 227 testCase.fail(message, stack); |
| 228 } else if (result == 'error') { | 228 } else if (result == 'error') { |
| 229 testCase.error(message, stack); | 229 testCase.error(message, stack); |
| 230 } | 230 } |
| 231 }); | 231 }); |
| 232 return f; | |
| 233 }; | 232 }; |
| 234 | 233 |
| 235 runIsolateTests() { | 234 runIsolateTests() { |
| 236 // Replace each test with a wrapped version first. | 235 // Replace each test with a wrapped version first. |
| 237 for (var i = 0; i < testCases.length; i++) { | 236 for (var i = 0; i < testCases.length; i++) { |
| 238 testCases[i].testFunction = isolatedTestParentWrapper(testCases[i]); | 237 testCases[i].testFunction = isolatedTestParentWrapper(testCases[i]); |
| 239 } | 238 } |
| 240 runTests(); | 239 runTests(); |
| 241 } | 240 } |
| 242 | 241 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 260 } | 259 } |
| 261 | 260 |
| 262 process(testMain, action) { | 261 process(testMain, action) { |
| 263 groupSep = marker; | 262 groupSep = marker; |
| 264 unittestConfiguration = new TestRunnerConfiguration(); | 263 unittestConfiguration = new TestRunnerConfiguration(); |
| 265 group('', testMain); | 264 group('', testMain); |
| 266 // Do any user-specified test filtering. | 265 // Do any user-specified test filtering. |
| 267 filterTests(filterTest); | 266 filterTests(filterTest); |
| 268 action(); | 267 action(); |
| 269 } | 268 } |
| OLD | NEW |