Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: pkg/unittest/lib/src/config.dart

Issue 14917022: Added color coding to test results in VM config. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/unittest/lib/vm_config.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 part of unittest; 5 part of unittest;
6 6
7 // A custom failure handler for [expect] that routes expect failures 7 // A custom failure handler for [expect] that routes expect failures
8 // to the config. 8 // to the config.
9 class _ExpectFailureHandler extends DefaultFailureHandler { 9 class _ExpectFailureHandler extends DefaultFailureHandler {
10 Configuration _config; 10 Configuration _config;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 _testLogBuffer.add(reason); 153 _testLogBuffer.add(reason);
154 try { 154 try {
155 throw ''; 155 throw '';
156 } catch (_, stack) { 156 } catch (_, stack) {
157 _testLogBuffer.add(stack); 157 _testLogBuffer.add(stack);
158 } 158 }
159 } 159 }
160 } 160 }
161 161
162 /** 162 /**
163 * Format a test result.
164 */
165 String formatResult(TestCase testCase) {
166 var result = new StringBuffer();
167 result.write(testCase.result.toUpperCase());
168 result.write(": ");
169 result.write(testCase.description);
170 result.write("\n");
171
172 if (testCase.message != '') {
173 result.write(_indent(testCase.message));
174 result.write("\n");
175 }
176
177 if (testCase.stackTrace != null && testCase.stackTrace != '') {
178 result.write(_indent(testCase.stackTrace));
179 result.write("\n");
180 }
181 return result.toString();
182 }
183
184 /**
163 * Called with the result of all test cases. The default implementation prints 185 * Called with the result of all test cases. The default implementation prints
164 * the result summary using the built-in [print] command. Browser tests 186 * the result summary using the built-in [print] command. Browser tests
165 * commonly override this to reformat the output. 187 * commonly override this to reformat the output.
166 * 188 *
167 * When [uncaughtError] is not null, it contains an error that occured outside 189 * When [uncaughtError] is not null, it contains an error that occured outside
168 * of tests (e.g. setting up the test). 190 * of tests (e.g. setting up the test).
169 */ 191 */
170 void onSummary(int passed, int failed, int errors, List<TestCase> results, 192 void onSummary(int passed, int failed, int errors, List<TestCase> results,
171 String uncaughtError) { 193 String uncaughtError) {
172 // Print each test's result. 194 // Print each test's result.
173 for (final t in results) { 195 for (final t in results) {
174 var resultString = "${t.result}".toUpperCase(); 196 print(formatResult(t));
Siggi Cherem (dart-lang) 2013/05/07 20:55:01 just to make sure, this is not affecting compact_v
175 print('$resultString: ${t.description}');
176
177 if (t.message != '') {
178 print(_indent(t.message));
179 }
180
181 if (t.stackTrace != null && t.stackTrace != '') {
182 print(_indent(t.stackTrace));
183 }
184 } 197 }
185 198
186 // Show the summary. 199 // Show the summary.
187 print(''); 200 print('');
188 201
189 if (passed == 0 && failed == 0 && errors == 0 && uncaughtError == null) { 202 if (passed == 0 && failed == 0 && errors == 0 && uncaughtError == null) {
190 print('No tests found.'); 203 print('No tests found.');
191 // This is considered a failure too. 204 // This is considered a failure too.
192 } else if (failed == 0 && errors == 0 && uncaughtError == null) { 205 } else if (failed == 0 && errors == 0 && uncaughtError == null) {
193 print('All $passed tests passed.'); 206 print('All $passed tests passed.');
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 // Currently e.message works in dartium, but not in dartc. 240 // Currently e.message works in dartium, but not in dartc.
228 void handleExternalError(e, String message, [String stack = '']) => 241 void handleExternalError(e, String message, [String stack = '']) =>
229 _reportTestError('$message\nCaught $e', stack); 242 _reportTestError('$message\nCaught $e', stack);
230 243
231 _postMessage(String message) { 244 _postMessage(String message) {
232 // In dart2js browser tests, the JavaScript-based test controller 245 // In dart2js browser tests, the JavaScript-based test controller
233 // intercepts calls to print and listens for "secret" messages. 246 // intercepts calls to print and listens for "secret" messages.
234 print(message); 247 print(message);
235 } 248 }
236 } 249 }
OLDNEW
« no previous file with comments | « no previous file | pkg/unittest/lib/vm_config.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698