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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 return timeout(replyPort.first, 30 * 1000, () { | 130 return timeout(replyPort.first, 30 * 1000, () { |
131 throw 'Timed out waiting for test to complete.'; | 131 throw 'Timed out waiting for test to complete.'; |
132 }); | 132 }); |
133 }); | 133 }); |
134 } | 134 } |
135 | 135 |
136 /// Returns whether [results] (a test result map) describes a test run in which | 136 /// Returns whether [results] (a test result map) describes a test run in which |
137 /// an error occurred. | 137 /// an error occurred. |
138 bool _hasError(Map results) { | 138 bool _hasError(Map results) { |
139 return results['errors'] > 0 || results['uncaughtError'] != null || | 139 return results['errors'] > 0 || results['uncaughtError'] != null || |
140 (results['passed'] == 0 && results['failed'] == 0); | 140 (results['passed'] == 0 && results['failed'] == 0); |
141 } | 141 } |
142 | 142 |
143 /// Returns a string description of the test run descibed by [results]. | 143 /// Returns a string description of the test run descibed by [results]. |
144 String _summarizeTests(Map results) { | 144 String _summarizeTests(Map results) { |
145 var buffer = new StringBuffer(); | 145 var buffer = new StringBuffer(); |
146 for (var t in results["results"]) { | 146 for (var t in results["results"]) { |
147 buffer.writeln("${t['result'].toUpperCase()}: ${t['description']}"); | 147 buffer.writeln("${t['result'].toUpperCase()}: ${t['description']}"); |
148 if (t['message'] != '') buffer.writeln("${_indent(t['message'])}"); | 148 if (t['message'] != '') buffer.writeln("${_indent(t['message'])}"); |
149 if (t['stackTrace'] != null && t['stackTrace'] != '') { | 149 if (t['stackTrace'] != null && t['stackTrace'] != '') { |
150 buffer.writeln("${_indent(t['stackTrace'])}"); | 150 buffer.writeln("${_indent(t['stackTrace'])}"); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 "uncaughtError": uncaughtError, | 202 "uncaughtError": uncaughtError, |
203 "results": results.map((testCase) => { | 203 "results": results.map((testCase) => { |
204 "description": testCase.description, | 204 "description": testCase.description, |
205 "message": testCase.message, | 205 "message": testCase.message, |
206 "result": testCase.result, | 206 "result": testCase.result, |
207 "stackTrace": testCase.stackTrace.toString() | 207 "stackTrace": testCase.stackTrace.toString() |
208 }).toList() | 208 }).toList() |
209 }); | 209 }); |
210 } | 210 } |
211 } | 211 } |
OLD | NEW |