| 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 String _summarizeTests(Map results) { | 146 String _summarizeTests(Map results) { |
| 147 var buffer = new StringBuffer(); | 147 var buffer = new StringBuffer(); |
| 148 for (var t in results["results"]) { | 148 for (var t in results["results"]) { |
| 149 buffer.writeln("${t['result'].toUpperCase()}: ${t['description']}"); | 149 buffer.writeln("${t['result'].toUpperCase()}: ${t['description']}"); |
| 150 if (t['message'] != '') buffer.writeln("${_indent(t['message'])}"); | 150 if (t['message'] != '') buffer.writeln("${_indent(t['message'])}"); |
| 151 if (t['stackTrace'] != null && t['stackTrace'] != '') { | 151 if (t['stackTrace'] != null && t['stackTrace'] != '') { |
| 152 buffer.writeln("${_indent(t['stackTrace'])}"); | 152 buffer.writeln("${_indent(t['stackTrace'])}"); |
| 153 } | 153 } |
| 154 } | 154 } |
| 155 | 155 |
| 156 buffer.writeln(""); | 156 buffer.writeln(); |
| 157 | 157 |
| 158 var success = false; | 158 var success = false; |
| 159 if (results['passed'] == 0 && results['failed'] == 0 && | 159 if (results['passed'] == 0 && results['failed'] == 0 && |
| 160 results['errors'] == 0 && results['uncaughtError'] == null) { | 160 results['errors'] == 0 && results['uncaughtError'] == null) { |
| 161 buffer.write('No tests found.'); | 161 buffer.write('No tests found.'); |
| 162 // This is considered a failure too. | 162 // This is considered a failure too. |
| 163 } else if (results['failed'] == 0 && results['errors'] == 0 && | 163 } else if (results['failed'] == 0 && results['errors'] == 0 && |
| 164 results['uncaughtError'] == null) { | 164 results['uncaughtError'] == null) { |
| 165 buffer.write('All ${results['passed']} tests passed.'); | 165 buffer.write('All ${results['passed']} tests passed.'); |
| 166 success = true; | 166 success = true; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 "message": testCase.message, | 206 "message": testCase.message, |
| 207 "result": testCase.result, | 207 "result": testCase.result, |
| 208 "stackTrace": testCase.stackTrace | 208 "stackTrace": testCase.stackTrace |
| 209 }).toList() | 209 }).toList() |
| 210 }); | 210 }); |
| 211 } | 211 } |
| 212 | 212 |
| 213 void onInit() {} | 213 void onInit() {} |
| 214 void onDone(bool success) {} | 214 void onDone(bool success) {} |
| 215 } | 215 } |
| OLD | NEW |