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

Side by Side Diff: pkg/unittest/lib/compact_vm_config.dart

Issue 18400002: Roll back "Use package:stack_trace in unittest." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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/html_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) 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 /** 5 /**
6 * A test configuration that generates a compact 1-line progress bar. The bar is 6 * A test configuration that generates a compact 1-line progress bar. The bar is
7 * updated in-place before and after each test is executed. If all test pass, 7 * updated in-place before and after each test is executed. If all test pass,
8 * you should only see a couple lines in the terminal. If a test fails, the 8 * you should only see a couple lines in the terminal. If a test fails, the
9 * failure is shown and the progress bar continues to be updated below it. 9 * failure is shown and the progress bar continues to be updated below it.
10 */ 10 */
11 library compact_vm_config; 11 library compact_vm_config;
12 12
13 import 'dart:io'; 13 import 'dart:io';
14
15 import 'unittest.dart'; 14 import 'unittest.dart';
16 import 'src/utils.dart';
17 import 'vm_config.dart'; 15 import 'vm_config.dart';
18 16
19 const String _GREEN = '\u001b[32m'; 17 const String _GREEN = '\u001b[32m';
20 const String _RED = '\u001b[31m'; 18 const String _RED = '\u001b[31m';
21 const String _NONE = '\u001b[0m'; 19 const String _NONE = '\u001b[0m';
22 const int MAX_LINE = 80; 20 const int MAX_LINE = 80;
23 21
24 class CompactVMConfiguration extends VMConfiguration { 22 class CompactVMConfiguration extends VMConfiguration {
25 DateTime _start; 23 DateTime _start;
26 int _pass = 0; 24 int _pass = 0;
(...skipping 16 matching lines...) Expand all
43 void onTestResult(TestCase test) { 41 void onTestResult(TestCase test) {
44 super.onTestResult(test); 42 super.onTestResult(test);
45 if (test.result == PASS) { 43 if (test.result == PASS) {
46 _pass++; 44 _pass++;
47 _progressLine(_start, _pass, _fail, test.description); 45 _progressLine(_start, _pass, _fail, test.description);
48 } else { 46 } else {
49 _fail++; 47 _fail++;
50 _progressLine(_start, _pass, _fail, test.description); 48 _progressLine(_start, _pass, _fail, test.description);
51 print(''); 49 print('');
52 if (test.message != '') { 50 if (test.message != '') {
53 print(indent(test.message)); 51 print(_indent(test.message));
54 } 52 }
55 53
56 if (test.stackTrace != null) { 54 if (test.stackTrace != null && test.stackTrace != '') {
57 print(indent(test.stackTrace.toString())); 55 print(_indent(test.stackTrace));
58 } 56 }
59 } 57 }
60 } 58 }
61 59
60 String _indent(String str) {
61 return str.split("\n").map((line) => " $line").join("\n");
62 }
63
62 void onSummary(int passed, int failed, int errors, List<TestCase> results, 64 void onSummary(int passed, int failed, int errors, List<TestCase> results,
63 String uncaughtError) { 65 String uncaughtError) {
64 var success = false; 66 var success = false;
65 if (passed == 0 && failed == 0 && errors == 0 && uncaughtError == null) { 67 if (passed == 0 && failed == 0 && errors == 0 && uncaughtError == null) {
66 print('\nNo tests ran.'); 68 print('\nNo tests ran.');
67 } else if (failed == 0 && errors == 0 && uncaughtError == null) { 69 } else if (failed == 0 && errors == 0 && uncaughtError == null) {
68 _progressLine(_start, _pass, _fail, 'All tests pass', _GREEN); 70 _progressLine(_start, _pass, _fail, 'All tests pass', _GREEN);
69 print('\nAll $passed tests passed.'); 71 print('\nAll $passed tests passed.');
70 success = true; 72 success = true;
71 } else { 73 } else {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 168 }
167 return '...$res'; 169 return '...$res';
168 } 170 }
169 } 171 }
170 172
171 void useCompactVMConfiguration() { 173 void useCompactVMConfiguration() {
172 unittestConfiguration = _singleton; 174 unittestConfiguration = _singleton;
173 } 175 }
174 176
175 final _singleton = new CompactVMConfiguration(); 177 final _singleton = new CompactVMConfiguration();
OLDNEW
« no previous file with comments | « no previous file | pkg/unittest/lib/html_config.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698