OLD | NEW |
---|---|
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 /** This file is sourced by unitest.dart. */ | 5 /** This file is sourced by unitest.dart. */ |
6 | 6 |
7 /** | 7 /** |
8 * Hooks to configure the unittest library for different platforms. This class | 8 * Hooks to configure the unittest library for different platforms. This class |
9 * implements the API in a platform-independent way. Tests that want to take | 9 * implements the API in a platform-independent way. Tests that want to take |
10 * advantage of the platform can create a subclass and override methods from | 10 * advantage of the platform can create a subclass and override methods from |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 */ | 47 */ |
48 void onTestResult(TestCase testCase) { | 48 void onTestResult(TestCase testCase) { |
49 currentTestCase = null; | 49 currentTestCase = null; |
50 } | 50 } |
51 | 51 |
52 /** | 52 /** |
53 * Can be called by tests to log status. Tests should use this | 53 * Can be called by tests to log status. Tests should use this |
54 * instead of print. Subclasses should not override this; they | 54 * instead of print. Subclasses should not override this; they |
55 * should instead override logMessage which is passed the test case. | 55 * should instead override logMessage which is passed the test case. |
56 */ | 56 */ |
57 void log(String message) { | 57 void trace(String message) { |
Siggi Cherem (dart-lang)
2012/09/05 17:45:41
I think I prefer the old name.
gram
2012/09/06 18:25:25
As discussed, changed logMessage to logTestCaseMes
| |
58 if (currentTestCase == null || _currentTest >= _tests.length || | 58 if (currentTestCase == null || _currentTest >= _tests.length || |
59 currentTestCase.id != _tests[_currentTest].id) { | 59 currentTestCase.id != _tests[_currentTest].id) { |
60 // Before or after tests run, or with a mismatch between what the | 60 // Before or after tests run, or with a mismatch between what the |
61 // config and the test harness think is the current test. In this | 61 // config and the test harness think is the current test. In this |
62 // case we pass null for the test case reference and let the config | 62 // case we pass null for the test case reference and let the config |
63 // decide what to do with this. | 63 // decide what to do with this. |
64 logMessage(null, message); | 64 logMessage(null, message); |
65 } else { | 65 } else { |
66 logMessage(currentTestCase, message); | 66 logMessage(currentTestCase, message); |
67 } | 67 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 | 125 |
126 return Strings.join(str.split("\n").map((line) => " $line"), "\n"); | 126 return Strings.join(str.split("\n").map((line) => " $line"), "\n"); |
127 } | 127 } |
128 | 128 |
129 /** Handle errors that happen outside the tests. */ | 129 /** Handle errors that happen outside the tests. */ |
130 // TODO(vsm): figure out how to expose the stack trace here | 130 // TODO(vsm): figure out how to expose the stack trace here |
131 // Currently e.message works in dartium, but not in dartc. | 131 // Currently e.message works in dartium, but not in dartc. |
132 handleExternalError(e, String message) => | 132 handleExternalError(e, String message) => |
133 _reportTestError('$message\nCaught $e', ''); | 133 _reportTestError('$message\nCaught $e', ''); |
134 } | 134 } |
OLD | NEW |