| OLD | NEW |
| 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 #library("test_progress"); | 5 #library("test_progress"); |
| 6 | 6 |
| 7 #import("test_runner.dart"); | 7 #import("test_runner.dart"); |
| 8 #import("test_suite.dart"); | 8 #import("test_suite.dart"); |
| 9 | 9 |
| 10 class ProgressIndicator { | 10 class ProgressIndicator { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 case 'status': | 25 case 'status': |
| 26 return new StatusProgressIndicator(startTime, printTiming); | 26 return new StatusProgressIndicator(startTime, printTiming); |
| 27 case 'buildbot': | 27 case 'buildbot': |
| 28 return new BuildbotProgressIndicator(startTime, printTiming); | 28 return new BuildbotProgressIndicator(startTime, printTiming); |
| 29 default: | 29 default: |
| 30 assert(false); | 30 assert(false); |
| 31 break; | 31 break; |
| 32 } | 32 } |
| 33 } | 33 } |
| 34 | 34 |
| 35 void testAdded() => _foundTests++; | 35 void testAdded() { _foundTests++; } |
| 36 | 36 |
| 37 void start(TestCase test) { | 37 void start(TestCase test) { |
| 38 _printStartProgress(test); | 38 _printStartProgress(test); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void done(TestCase test) { | 41 void done(TestCase test) { |
| 42 if (test.output.unexpectedOutput) { | 42 if (test.output.unexpectedOutput) { |
| 43 _failedTests++; | 43 _failedTests++; |
| 44 _printFailureOutput(test); | 44 _printFailureOutput(test); |
| 45 } else { | 45 } else { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 | 75 |
| 76 void allDone() { | 76 void allDone() { |
| 77 _printStatus(); | 77 _printStatus(); |
| 78 _printTimingInformation(); | 78 _printTimingInformation(); |
| 79 exit(_failedTests > 0 ? 1 : 0); | 79 exit(_failedTests > 0 ? 1 : 0); |
| 80 } | 80 } |
| 81 | 81 |
| 82 abstract _printStartProgress(); | 82 abstract _printStartProgress(TestCase test); |
| 83 abstract _printDoneProgress(); | 83 abstract _printDoneProgress(TestCase test); |
| 84 | 84 |
| 85 String _pad(String s, int length) { | 85 String _pad(String s, int length) { |
| 86 StringBuffer buffer = new StringBuffer(); | 86 StringBuffer buffer = new StringBuffer(); |
| 87 for (int i = s.length; i < length; i++) { | 87 for (int i = s.length; i < length; i++) { |
| 88 buffer.add(' '); | 88 buffer.add(' '); |
| 89 } | 89 } |
| 90 buffer.add(s); | 90 buffer.add(s); |
| 91 return buffer.toString(); | 91 return buffer.toString(); |
| 92 } | 92 } |
| 93 | 93 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 | 162 |
| 163 void allDone() { | 163 void allDone() { |
| 164 stdout.write('\n'.charCodes()); | 164 stdout.write('\n'.charCodes()); |
| 165 _printTimingInformation(); | 165 _printTimingInformation(); |
| 166 stdout.close(); | 166 stdout.close(); |
| 167 exit(_failedTests > 0 ? 1 : 0); | 167 exit(_failedTests > 0 ? 1 : 0); |
| 168 } | 168 } |
| 169 | 169 |
| 170 void _printStartProgress(TestCase test) => _printProgress(); | 170 void _printStartProgress(TestCase test) => _printProgress(); |
| 171 void _printDoneProgress(TestCase test) => _printProgress(); | 171 void _printDoneProgress(TestCase test) => _printProgress(); |
| 172 |
| 173 abstract void _printProgress(); |
| 172 } | 174 } |
| 173 | 175 |
| 174 | 176 |
| 175 class CompactProgressIndicator extends CompactIndicator { | 177 class CompactProgressIndicator extends CompactIndicator { |
| 176 CompactProgressIndicator(Date startTime, bool printTiming) | 178 CompactProgressIndicator(Date startTime, bool printTiming) |
| 177 : super(startTime, printTiming); | 179 : super(startTime, printTiming); |
| 178 | 180 |
| 179 void _printProgress() { | 181 void _printProgress() { |
| 180 var percent = ((_completedTests() / _foundTests) * 100).toInt().toString(); | 182 var percent = ((_completedTests() / _foundTests) * 100).toInt().toString(); |
| 181 var progressPadded = _pad(_allTestsKnown ? percent : '--', 3); | 183 var progressPadded = _pad(_allTestsKnown ? percent : '--', 3); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 var status = 'pass'; | 284 var status = 'pass'; |
| 283 if (test.output.unexpectedOutput) { | 285 if (test.output.unexpectedOutput) { |
| 284 status = 'fail'; | 286 status = 'fail'; |
| 285 } | 287 } |
| 286 var percent = ((_completedTests() / _foundTests) * 100).toInt().toString(); | 288 var percent = ((_completedTests() / _foundTests) * 100).toInt().toString(); |
| 287 print('Done ${test.displayName}: $status'); | 289 print('Done ${test.displayName}: $status'); |
| 288 print('@@@STEP_CLEAR@@@'); | 290 print('@@@STEP_CLEAR@@@'); |
| 289 print('@@@STEP_TEXT@ $percent% +$_passedTests -$_failedTests @@@'); | 291 print('@@@STEP_TEXT@ $percent% +$_passedTests -$_failedTests @@@'); |
| 290 } | 292 } |
| 291 } | 293 } |
| OLD | NEW |