| 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 /** | 5 /** |
| 6 * A simple unit test library for running tests on the VM. | 6 * A simple unit test library for running tests on the VM. |
| 7 */ | 7 */ |
| 8 #library('unittest'); | 8 #library('unittest'); |
| 9 | 9 |
| 10 #import('dart:io'); | 10 #import('dart:io'); |
| 11 #import('dart:isolate'); |
| 12 |
| 13 #source('config.dart'); |
| 11 #source('shared.dart'); | 14 #source('shared.dart'); |
| 12 | 15 |
| 13 _platformInitialize() { | |
| 14 // Do nothing. | |
| 15 } | |
| 16 | |
| 17 _platformDefer(void callback()) { | |
| 18 new Timer(0, (timer) { | |
| 19 callback(); | |
| 20 }); | |
| 21 } | |
| 22 | |
| 23 _platformStartTests() { | |
| 24 // Do nothing. | |
| 25 } | |
| 26 | |
| 27 _platformCompleteTests(int testsPassed, int testsFailed, int testsErrors) { | 16 _platformCompleteTests(int testsPassed, int testsFailed, int testsErrors) { |
| 28 // Print each test's result. | 17 // Print each test's result. |
| 29 for (final test in _tests) { | 18 for (final test in _tests) { |
| 30 print('${test.result.toUpperCase()}: ${test.description}'); | 19 print('${test.result.toUpperCase()}: ${test.description}'); |
| 31 | 20 |
| 32 if (test.message != '') { | 21 if (test.message != '') { |
| 33 print(' ${test.message}'); | 22 print(' ${test.message}'); |
| 34 } | 23 } |
| 35 } | 24 } |
| 36 | 25 |
| 37 // Show the summary. | 26 // Show the summary. |
| 38 print(''); | 27 print(''); |
| 39 | 28 |
| 40 var success = false; | 29 var success = false; |
| 41 if (testsPassed == 0 && testsFailed == 0 && testsErrors == 0) { | 30 if (testsPassed == 0 && testsFailed == 0 && testsErrors == 0) { |
| 42 print('No tests found.'); | 31 print('No tests found.'); |
| 43 // This is considered a failure too: if this happens you probably have a | 32 // This is considered a failure too: if this happens you probably have a |
| 44 // bug in your unit tests. | 33 // bug in your unit tests. |
| 45 } else if (testsFailed == 0 && testsErrors == 0) { | 34 } else if (testsFailed == 0 && testsErrors == 0) { |
| 46 print('All $testsPassed tests passed.'); | 35 print('All $testsPassed tests passed.'); |
| 47 success = true; | 36 success = true; |
| 48 } else { | 37 } else { |
| 49 print('$testsPassed PASSED, $testsFailed FAILED, $testsErrors ERRORS'); | 38 print('$testsPassed PASSED, $testsFailed FAILED, $testsErrors ERRORS'); |
| 50 } | 39 } |
| 51 | 40 |
| 52 // A non-zero exit code is used by the test infrastructure to detect failure. | 41 // A non-zero exit code is used by the test infrastructure to detect failure. |
| 53 if (!success) exit(1); | 42 if (!success) exit(1); |
| 54 } | 43 } |
| 44 |
| 45 Configuration _defaultConfig() { |
| 46 return new Configuration( |
| 47 () {}, // do nothing onInit |
| 48 () {}, // do nothing onStart |
| 49 (testCase) {}, // do nothing onTestResult |
| 50 _platformCompleteTests); |
| 51 } |
| OLD | NEW |