| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 #library("test_progress"); | 5 #library("test_progress"); |
| 6 | 6 |
| 7 #import("dart:io"); | 7 #import("dart:io"); |
| 8 #import("test_runner.dart"); | 8 #import("test_runner.dart"); |
| 9 #import("test_suite.dart"); | 9 #import("test_suite.dart"); |
| 10 | 10 |
| 11 class ProgressIndicator { | 11 class ProgressIndicator { |
| 12 ProgressIndicator(this._startTime, this._printTiming) | 12 ProgressIndicator(this._startTime, this._printTiming) |
| 13 : _tests = [], _failureSummary = []; | 13 : _tests = [], _failureSummary = []; |
| 14 | 14 |
| 15 factory ProgressIndicator.fromName(String name, | 15 factory ProgressIndicator.fromName(String name, |
| 16 Date startTime, | 16 Date startTime, |
| 17 bool printTiming) { | 17 bool printTiming) { |
| 18 switch (name) { | 18 switch (name) { |
| 19 case 'compact': | 19 case 'compact': |
| 20 return new CompactProgressIndicator(startTime, printTiming); | 20 return new CompactProgressIndicator(startTime, printTiming); |
| 21 case 'color': | 21 case 'color': |
| 22 return new ColorProgressIndicator(startTime, printTiming); | 22 return new ColorProgressIndicator(startTime, printTiming); |
| 23 case 'line': | 23 case 'line': |
| 24 return new LineProgressIndicator(startTime, printTiming); | 24 return new LineProgressIndicator(startTime, printTiming); |
| 25 case 'verbose': | 25 case 'verbose': |
| 26 return new VerboseProgressIndicator(startTime, printTiming); | 26 return new VerboseProgressIndicator(startTime, printTiming); |
| 27 case 'silent': |
| 28 return new SilentProgressIndicator(startTime, printTiming); |
| 27 case 'status': | 29 case 'status': |
| 28 return new StatusProgressIndicator(startTime, printTiming); | 30 return new StatusProgressIndicator(startTime, printTiming); |
| 29 case 'buildbot': | 31 case 'buildbot': |
| 30 return new BuildbotProgressIndicator(startTime, printTiming); | 32 return new BuildbotProgressIndicator(startTime, printTiming); |
| 31 default: | 33 default: |
| 32 assert(false); | 34 assert(false); |
| 33 break; | 35 break; |
| 34 } | 36 } |
| 35 } | 37 } |
| 36 | 38 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 int _passedTests = 0; | 178 int _passedTests = 0; |
| 177 int _failedTests = 0; | 179 int _failedTests = 0; |
| 178 bool _allTestsKnown = false; | 180 bool _allTestsKnown = false; |
| 179 Date _startTime; | 181 Date _startTime; |
| 180 bool _printTiming; | 182 bool _printTiming; |
| 181 List<TestCase> _tests; | 183 List<TestCase> _tests; |
| 182 List<String> _failureSummary; | 184 List<String> _failureSummary; |
| 183 } | 185 } |
| 184 | 186 |
| 185 | 187 |
| 188 class SilentProgressIndicator extends ProgressIndicator { |
| 189 SilentProgressIndicator(Date startTime, bool printTiming) |
| 190 : super(startTime, printTiming); |
| 191 void testAdded() { } |
| 192 void start(TestCase test) { } |
| 193 void done(TestCase test) { } |
| 194 void allTestsKnown() { } |
| 195 void allDone() { |
| 196 exit(0); |
| 197 } |
| 198 } |
| 199 |
| 186 class CompactIndicator extends ProgressIndicator { | 200 class CompactIndicator extends ProgressIndicator { |
| 187 CompactIndicator(Date startTime, bool printTiming) | 201 CompactIndicator(Date startTime, bool printTiming) |
| 188 : super(startTime, printTiming); | 202 : super(startTime, printTiming); |
| 189 | 203 |
| 190 void allDone() { | 204 void allDone() { |
| 191 stdout.write('\n'.charCodes()); | 205 stdout.write('\n'.charCodes()); |
| 192 _printFailureSummary(); | 206 _printFailureSummary(); |
| 193 _printTimingInformation(); | 207 _printTimingInformation(); |
| 194 if (_failedTests > 0) { | 208 if (_failedTests > 0) { |
| 195 // We may have printed many failure logs, so reprint the summary data. | 209 // We may have printed many failure logs, so reprint the summary data. |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 var status = 'pass'; | 341 var status = 'pass'; |
| 328 if (test.output.unexpectedOutput) { | 342 if (test.output.unexpectedOutput) { |
| 329 status = 'fail'; | 343 status = 'fail'; |
| 330 } | 344 } |
| 331 var percent = ((_completedTests() / _foundTests) * 100).toInt().toString(); | 345 var percent = ((_completedTests() / _foundTests) * 100).toInt().toString(); |
| 332 print('Done ${test.configurationString} ${test.displayName}: $status'); | 346 print('Done ${test.configurationString} ${test.displayName}: $status'); |
| 333 print('@@@STEP_CLEAR@@@'); | 347 print('@@@STEP_CLEAR@@@'); |
| 334 print('@@@STEP_TEXT@ $percent% +$_passedTests -$_failedTests @@@'); | 348 print('@@@STEP_TEXT@ $percent% +$_passedTests -$_failedTests @@@'); |
| 335 } | 349 } |
| 336 } | 350 } |
| OLD | NEW |