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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 '${results['errors']} ERRORS'); | 163 '${results['errors']} ERRORS'); |
164 } | 164 } |
165 return prefixLines(buffer.toString()); | 165 return prefixLines(buffer.toString()); |
166 } | 166 } |
167 | 167 |
168 /// Indents each line of [str] by two spaces. | 168 /// Indents each line of [str] by two spaces. |
169 String _indent(String str) { | 169 String _indent(String str) { |
170 // TODO(nweiz): Use this simpler code once issue 2980 is fixed. | 170 // TODO(nweiz): Use this simpler code once issue 2980 is fixed. |
171 // return str.replaceAll(new RegExp("^", multiLine: true), " "); | 171 // return str.replaceAll(new RegExp("^", multiLine: true), " "); |
172 | 172 |
173 return Strings.join(str.split("\n").map((line) => " $line"), "\n"); | 173 return str.split("\n").map((line) => " $line").join("\n"); |
174 } | 174 } |
175 | 175 |
176 /// Ensure that the metatest configuration is loaded. | 176 /// Ensure that the metatest configuration is loaded. |
177 void _ensureInitialized() { | 177 void _ensureInitialized() { |
178 if (config is! _MetaConfiguration) configure(new _MetaConfiguration()); | 178 if (config is! _MetaConfiguration) configure(new _MetaConfiguration()); |
179 } | 179 } |
180 | 180 |
181 /// Special test configuration for use within the child isolates. This hides all | 181 /// Special test configuration for use within the child isolates. This hides all |
182 /// output and reports data back to the parent isolate. | 182 /// output and reports data back to the parent isolate. |
183 class _MetaConfiguration extends Configuration { | 183 class _MetaConfiguration extends Configuration { |
(...skipping 13 matching lines...) Expand all Loading... |
197 "message": testCase.message, | 197 "message": testCase.message, |
198 "result": testCase.result, | 198 "result": testCase.result, |
199 "stackTrace": testCase.stackTrace | 199 "stackTrace": testCase.stackTrace |
200 }).toList() | 200 }).toList() |
201 }); | 201 }); |
202 } | 202 } |
203 | 203 |
204 void onInit() {} | 204 void onInit() {} |
205 void onDone(bool success) {} | 205 void onDone(bool success) {} |
206 } | 206 } |
OLD | NEW |