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 part of unittest; | 5 part of unittest; |
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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 } else { | 139 } else { |
140 _receivePort.close(); | 140 _receivePort.close(); |
141 throw new Exception('Some tests failed.'); | 141 throw new Exception('Some tests failed.'); |
142 } | 142 } |
143 } | 143 } |
144 | 144 |
145 String _indent(String str) { | 145 String _indent(String str) { |
146 // TODO(nweiz): Use this simpler code once issue 2980 is fixed. | 146 // TODO(nweiz): Use this simpler code once issue 2980 is fixed. |
147 // return str.replaceAll(new RegExp("^", multiLine: true), " "); | 147 // return str.replaceAll(new RegExp("^", multiLine: true), " "); |
148 | 148 |
149 return Strings.join(str.split("\n").mappedBy((line) => " $line"), "\n"); | 149 return Strings.join(str.split("\n").map((line) => " $line"), "\n"); |
150 } | 150 } |
151 | 151 |
152 /** Handle errors that happen outside the tests. */ | 152 /** Handle errors that happen outside the tests. */ |
153 // TODO(vsm): figure out how to expose the stack trace here | 153 // TODO(vsm): figure out how to expose the stack trace here |
154 // Currently e.message works in dartium, but not in dartc. | 154 // Currently e.message works in dartium, but not in dartc. |
155 handleExternalError(e, String message) => | 155 handleExternalError(e, String message) => |
156 _reportTestError('$message\nCaught $e', ''); | 156 _reportTestError('$message\nCaught $e', ''); |
157 | 157 |
158 /** | 158 /** |
159 * Send messages to the test controller code (see 'test_controller.js'). This | 159 * Send messages to the test controller code (see 'test_controller.js'). This |
160 * is only needed to support browser tests with dart2js. Note: we could wrap | 160 * is only needed to support browser tests with dart2js. Note: we could wrap |
161 * tests and send the appropriate messages to the controller through the | 161 * tests and send the appropriate messages to the controller through the |
162 * wrapper, but using wrappers has a noticeable overhead in the testing bots, | 162 * wrapper, but using wrappers has a noticeable overhead in the testing bots, |
163 * so we use this approach instead. | 163 * so we use this approach instead. |
164 * | 164 * |
165 * Configurations that will not run in DRT (such as vm_config and | 165 * Configurations that will not run in DRT (such as vm_config and |
166 * compact_vm_config), can safely override this method to avoid printing extra | 166 * compact_vm_config), can safely override this method to avoid printing extra |
167 * mesages in the console. | 167 * mesages in the console. |
168 */ | 168 */ |
169 // TODO(sigmund): find a way to unify notifyController and _postMessage | 169 // TODO(sigmund): find a way to unify notifyController and _postMessage |
170 void notifyController(String message) { | 170 void notifyController(String message) { |
171 } | 171 } |
172 | 172 |
173 _postMessage(String message) { | 173 _postMessage(String message) { |
174 // In dart2js browser tests, the JavaScript-based test controller | 174 // In dart2js browser tests, the JavaScript-based test controller |
175 // intercepts calls to print and listens for "secret" messages. | 175 // intercepts calls to print and listens for "secret" messages. |
176 print(message); | 176 print(message); |
177 } | 177 } |
178 } | 178 } |
OLD | NEW |