| 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 /// Indents each line of [str] by two spaces. | 177 /// Indents each line of [str] by two spaces. |
| 178 String _indent(String str) { | 178 String _indent(String str) { |
| 179 // TODO(nweiz): Use this simpler code once issue 2980 is fixed. | 179 // TODO(nweiz): Use this simpler code once issue 2980 is fixed. |
| 180 // return str.replaceAll(new RegExp("^", multiLine: true), " "); | 180 // return str.replaceAll(new RegExp("^", multiLine: true), " "); |
| 181 | 181 |
| 182 return str.split("\n").map((line) => " $line").join("\n"); | 182 return str.split("\n").map((line) => " $line").join("\n"); |
| 183 } | 183 } |
| 184 | 184 |
| 185 /// Ensure that the metatest configuration is loaded. | 185 /// Ensure that the metatest configuration is loaded. |
| 186 void _ensureInitialized() { | 186 void _ensureInitialized() { |
| 187 if (config is! _MetaConfiguration) configure(new _MetaConfiguration()); | 187 unittestConfiguration = _singleton; |
| 188 } | 188 } |
| 189 | 189 |
| 190 final _singleton = new _MetaConfiguration(); |
| 191 |
| 190 /// Special test configuration for use within the child isolates. This hides all | 192 /// Special test configuration for use within the child isolates. This hides all |
| 191 /// output and reports data back to the parent isolate. | 193 /// output and reports data back to the parent isolate. |
| 192 class _MetaConfiguration extends Configuration { | 194 class _MetaConfiguration extends Configuration { |
| 193 final name = "MetaConfiguration"; | 195 final name = "MetaConfiguration"; |
| 194 | 196 |
| 195 void logTestCaseMesssage(TestCase testCase, String message) {} | 197 void logTestCaseMesssage(TestCase testCase, String message) {} |
| 196 | 198 |
| 197 void onSummary(int passed, int failed, int errors, List<TestCase> results, | 199 void onSummary(int passed, int failed, int errors, List<TestCase> results, |
| 198 String uncaughtError) { | 200 String uncaughtError) { |
| 199 _replyTo.send({ | 201 _replyTo.send({ |
| 200 "passed": passed, | 202 "passed": passed, |
| 201 "failed": failed, | 203 "failed": failed, |
| 202 "errors": errors, | 204 "errors": errors, |
| 203 "uncaughtError": uncaughtError, | 205 "uncaughtError": uncaughtError, |
| 204 "results": results.map((testCase) => { | 206 "results": results.map((testCase) => { |
| 205 "description": testCase.description, | 207 "description": testCase.description, |
| 206 "message": testCase.message, | 208 "message": testCase.message, |
| 207 "result": testCase.result, | 209 "result": testCase.result, |
| 208 "stackTrace": testCase.stackTrace | 210 "stackTrace": testCase.stackTrace |
| 209 }).toList() | 211 }).toList() |
| 210 }); | 212 }); |
| 211 } | 213 } |
| 212 | 214 |
| 213 void onInit() {} | 215 void onInit() {} |
| 214 void onDone(bool success) {} | 216 void onDone(bool success) {} |
| 215 } | 217 } |
| OLD | NEW |