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 /** | 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 */ |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 } | 49 } |
50 | 50 |
51 void onTestResult(TestCase test) { | 51 void onTestResult(TestCase test) { |
52 super.onTestResult(test); | 52 super.onTestResult(test); |
53 if (test.result == PASS) { | 53 if (test.result == PASS) { |
54 _pass++; | 54 _pass++; |
55 _progressLine(_start, _pass, _fail, test.description); | 55 _progressLine(_start, _pass, _fail, test.description); |
56 } else { | 56 } else { |
57 _fail++; | 57 _fail++; |
58 _progressLine(_start, _pass, _fail, test.description); | 58 _progressLine(_start, _pass, _fail, test.description); |
59 print(''); | 59 stdout.write('\n'); |
60 if (test.message != '') { | 60 if (test.message != '') { |
61 print(indent(test.message)); | 61 print(indent(test.message)); |
62 } | 62 } |
63 | 63 |
64 if (test.stackTrace != null) { | 64 if (test.stackTrace != null) { |
65 print(indent(test.stackTrace.toString())); | 65 print(indent(test.stackTrace.toString())); |
66 } | 66 } |
67 } | 67 } |
68 } | 68 } |
69 | 69 |
70 void onTestResultChanged(TestCase test) { | 70 void onTestResultChanged(TestCase test) { |
71 _pass--; | 71 _pass--; |
72 _fail++; | 72 _fail++; |
73 _progressLine(_start, _pass, _fail, test.description); | 73 _progressLine(_start, _pass, _fail, test.description); |
74 print(''); | 74 stdout.write('\n'); |
75 if (test.message != '') { | 75 if (test.message != '') { |
76 print(indent(test.message)); | 76 print(indent(test.message)); |
77 } | 77 } |
78 | 78 |
79 if (test.stackTrace != null) { | 79 if (test.stackTrace != null) { |
80 print(indent(test.stackTrace.toString())); | 80 print(indent(test.stackTrace.toString())); |
81 } | 81 } |
82 } | 82 } |
83 | 83 |
84 void onDone(bool success) { | 84 void onDone(bool success) { |
85 // Override and don't call the superclass onDone() to avoid printing the | 85 // Override and don't call the superclass onDone() to avoid printing the |
86 // "unittest-suite-..." boilerplate. | 86 // "unittest-suite-..." boilerplate. |
87 Future.wait([stdout.close(), stderr.close()]).then((_) { | 87 Future.wait([stdout.close(), stderr.close()]).then((_) { |
88 _receivePort.close(); | 88 _receivePort.close(); |
89 exit(success ? 0 : 1); | 89 exit(success ? 0 : 1); |
90 }); | 90 }); |
91 } | 91 } |
92 | 92 |
93 void onSummary(int passed, int failed, int errors, List<TestCase> results, | 93 void onSummary(int passed, int failed, int errors, List<TestCase> results, |
94 String uncaughtError) { | 94 String uncaughtError) { |
95 var success = false; | 95 var success = false; |
96 if (passed == 0 && failed == 0 && errors == 0 && uncaughtError == null) { | 96 if (passed == 0 && failed == 0 && errors == 0 && uncaughtError == null) { |
97 print('\nNo tests ran.'); | 97 print('\nNo tests ran.'); |
98 } else if (failed == 0 && errors == 0 && uncaughtError == null) { | 98 } else if (failed == 0 && errors == 0 && uncaughtError == null) { |
99 _progressLine(_start, _pass, _fail, 'All tests passed!', _NONE); | 99 _progressLine(_start, _pass, _fail, 'All tests passed!', _NONE); |
100 print(''); | 100 stdout.write('\n'); |
101 success = true; | 101 success = true; |
102 } else { | 102 } else { |
103 _progressLine(_start, _pass, _fail, 'Some tests failed.', _RED); | 103 _progressLine(_start, _pass, _fail, 'Some tests failed.', _RED); |
104 print(''); | 104 stdout.write('\n'); |
105 if (uncaughtError != null) { | 105 if (uncaughtError != null) { |
106 print('Top-level uncaught error: $uncaughtError'); | 106 print('Top-level uncaught error: $uncaughtError'); |
107 } | 107 } |
108 print('$passed PASSED, $failed FAILED, $errors ERRORS'); | 108 print('$passed PASSED, $failed FAILED, $errors ERRORS'); |
109 } | 109 } |
110 } | 110 } |
111 | 111 |
112 int _lastLength = 0; | 112 int _lastLength = 0; |
113 | 113 |
114 final int _nonVisiblePrefix = 1 + _GREEN.length + _NONE.length; | 114 final int _nonVisiblePrefix = 1 + _GREEN.length + _NONE.length; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 // If the test is running on the Dart buildbots, we don't want to use this | 205 // If the test is running on the Dart buildbots, we don't want to use this |
206 // config since it's output may not be what the bots expect. | 206 // config since it's output may not be what the bots expect. |
207 if (Platform.environment['LOGNAME'] == 'chrome-bot') { | 207 if (Platform.environment['LOGNAME'] == 'chrome-bot') { |
208 return; | 208 return; |
209 } | 209 } |
210 | 210 |
211 unittestConfiguration = _singleton; | 211 unittestConfiguration = _singleton; |
212 } | 212 } |
213 | 213 |
214 final _singleton = new CompactVMConfiguration(); | 214 final _singleton = new CompactVMConfiguration(); |
OLD | NEW |