OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 for (var t in results["results"]) { | 207 for (var t in results["results"]) { |
208 buffer.writeln("${t['result'].toUpperCase()}: ${t['description']}"); | 208 buffer.writeln("${t['result'].toUpperCase()}: ${t['description']}"); |
209 if (t['message'] != '') buffer.writeln("${_indent(t['message'])}"); | 209 if (t['message'] != '') buffer.writeln("${_indent(t['message'])}"); |
210 if (t['stackTrace'] != null && t['stackTrace'] != '') { | 210 if (t['stackTrace'] != null && t['stackTrace'] != '') { |
211 buffer.writeln("${_indent(t['stackTrace'])}"); | 211 buffer.writeln("${_indent(t['stackTrace'])}"); |
212 } | 212 } |
213 } | 213 } |
214 | 214 |
215 buffer.writeln(); | 215 buffer.writeln(); |
216 | 216 |
217 var success = false; | |
218 if (results['passed'] == 0 && results['failed'] == 0 && | 217 if (results['passed'] == 0 && results['failed'] == 0 && |
219 results['errors'] == 0 && results['uncaughtError'] == null) { | 218 results['errors'] == 0 && results['uncaughtError'] == null) { |
220 buffer.write('No tests found.'); | 219 buffer.write('No tests found.'); |
221 // This is considered a failure too. | 220 // This is considered a failure too. |
222 } else if (results['failed'] == 0 && results['errors'] == 0 && | 221 } else if (results['failed'] == 0 && results['errors'] == 0 && |
223 results['uncaughtError'] == null) { | 222 results['uncaughtError'] == null) { |
224 buffer.write('All ${results['passed']} tests passed.'); | 223 buffer.write('All ${results['passed']} tests passed.'); |
225 success = true; | |
226 } else { | 224 } else { |
227 if (results['uncaughtError'] != null) { | 225 if (results['uncaughtError'] != null) { |
228 buffer.write('Top-level uncaught error: ${results['uncaughtError']}'); | 226 buffer.write('Top-level uncaught error: ${results['uncaughtError']}'); |
229 } | 227 } |
230 buffer.write('${results['passed']} PASSED, ${results['failed']} FAILED, ' | 228 buffer.write('${results['passed']} PASSED, ${results['failed']} FAILED, ' |
231 '${results['errors']} ERRORS'); | 229 '${results['errors']} ERRORS'); |
232 } | 230 } |
233 return prefixLines(buffer.toString()); | 231 return prefixLines(buffer.toString()); |
234 } | 232 } |
235 | 233 |
(...skipping 25 matching lines...) Expand all Loading... |
261 "uncaughtError": uncaughtError, | 259 "uncaughtError": uncaughtError, |
262 "results": results.map((testCase) => { | 260 "results": results.map((testCase) => { |
263 "description": testCase.description, | 261 "description": testCase.description, |
264 "message": testCase.message, | 262 "message": testCase.message, |
265 "result": testCase.result, | 263 "result": testCase.result, |
266 "stackTrace": testCase.stackTrace.toString() | 264 "stackTrace": testCase.stackTrace.toString() |
267 }).toList() | 265 }).toList() |
268 }); | 266 }); |
269 } | 267 } |
270 } | 268 } |
OLD | NEW |