| 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 #import("status_file_parser.dart"); | 10 #import("status_file_parser.dart"); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 } | 46 } |
| 47 | 47 |
| 48 void done(TestCase test) { | 48 void done(TestCase test) { |
| 49 if (test.isFlaky && test.lastCommandOutput.result != PASS) { | 49 if (test.isFlaky && test.lastCommandOutput.result != PASS) { |
| 50 var buf = new StringBuffer(); | 50 var buf = new StringBuffer(); |
| 51 for (var l in _buildFailureOutput(test)) { | 51 for (var l in _buildFailureOutput(test)) { |
| 52 buf.add("$l\n"); | 52 buf.add("$l\n"); |
| 53 } | 53 } |
| 54 _appendToFlakyFile(buf.toString()); | 54 _appendToFlakyFile(buf.toString()); |
| 55 } | 55 } |
| 56 for (var commandOutput in test.commandOutputs.values) { | |
| 57 if (commandOutput.compilationSkipped) | |
| 58 _skippedCompilations++; | |
| 59 } | |
| 60 | 56 |
| 61 if (test.lastCommandOutput.unexpectedOutput) { | 57 if (test.lastCommandOutput.unexpectedOutput) { |
| 62 _failedTests++; | 58 _failedTests++; |
| 63 _printFailureOutput(test); | 59 _printFailureOutput(test); |
| 64 } else { | 60 } else { |
| 65 _passedTests++; | 61 _passedTests++; |
| 66 } | 62 } |
| 67 _printDoneProgress(test); | 63 _printDoneProgress(test); |
| 68 // If we need to print timing information we hold on to all completed | 64 // If we need to print timing information we hold on to all completed |
| 69 // tests. | 65 // tests. |
| 70 if (_printTiming) _tests.add(test); | 66 if (_printTiming) _tests.add(test); |
| 71 } | 67 } |
| 72 | 68 |
| 73 void allTestsKnown() { | 69 void allTestsKnown() { |
| 74 if (!_allTestsKnown) SummaryReport.printReport(); | 70 if (!_allTestsKnown) SummaryReport.printReport(); |
| 75 _allTestsKnown = true; | 71 _allTestsKnown = true; |
| 76 } | 72 } |
| 77 | 73 |
| 78 void _printSkippedCompilationInfo() { | |
| 79 if (_skippedCompilations > 0) { | |
| 80 print('\n$_skippedCompilations compilations were skipped because ' | |
| 81 'the previous output was already up to date\n'); | |
| 82 } | |
| 83 } | |
| 84 | |
| 85 void _printTimingInformation() { | 74 void _printTimingInformation() { |
| 86 if (_printTiming) { | 75 if (_printTiming) { |
| 87 // TODO: We should take all the commands into account | 76 // TODO: We should take all the commands into account |
| 88 Duration d = (new Date.now()).difference(_startTime); | 77 Duration d = (new Date.now()).difference(_startTime); |
| 89 print('\n--- Total time: ${_timeString(d)} ---'); | 78 print('\n--- Total time: ${_timeString(d)} ---'); |
| 90 _tests.sort((a, b) { | 79 _tests.sort((a, b) { |
| 91 Duration aDuration = a.lastCommandOutput.time; | 80 Duration aDuration = a.lastCommandOutput.time; |
| 92 Duration bDuration = b.lastCommandOutput.time; | 81 Duration bDuration = b.lastCommandOutput.time; |
| 93 return bDuration.inMilliseconds - aDuration.inMilliseconds; | 82 return bDuration.inMilliseconds - aDuration.inMilliseconds; |
| 94 }); | 83 }); |
| 95 for (int i = 0; i < 20 && i < _tests.length; i++) { | 84 for (int i = 0; i < 20 && i < _tests.length; i++) { |
| 96 var name = _tests[i].displayName; | 85 var name = _tests[i].displayName; |
| 97 var duration = _tests[i].lastCommandOutput.time; | 86 var duration = _tests[i].lastCommandOutput.time; |
| 98 var configuration = _tests[i].configurationString; | 87 var configuration = _tests[i].configurationString; |
| 99 print('${duration} - $configuration $name'); | 88 print('${duration} - $configuration $name'); |
| 100 } | 89 } |
| 101 } | 90 } |
| 102 } | 91 } |
| 103 | 92 |
| 104 void allDone() { | 93 void allDone() { |
| 105 _printFailureSummary(); | 94 _printFailureSummary(); |
| 106 _printStatus(); | 95 _printStatus(); |
| 107 _printSkippedCompilationInfo(); | |
| 108 _printTimingInformation(); | 96 _printTimingInformation(); |
| 109 stdout.close(); | 97 stdout.close(); |
| 110 stderr.close(); | 98 stderr.close(); |
| 111 if (_failedTests > 0) exit(1); | 99 if (_failedTests > 0) exit(1); |
| 112 } | 100 } |
| 113 | 101 |
| 114 void _printStartProgress(TestCase test) {} | 102 void _printStartProgress(TestCase test) {} |
| 115 void _printDoneProgress(TestCase test) {} | 103 void _printDoneProgress(TestCase test) {} |
| 116 | 104 |
| 117 String _pad(String s, int length) { | 105 String _pad(String s, int length) { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 fd.closeSync(); | 218 fd.closeSync(); |
| 231 } | 219 } |
| 232 | 220 |
| 233 int get numFailedTests => _failedTests; | 221 int get numFailedTests => _failedTests; |
| 234 | 222 |
| 235 int _completedTests() => _passedTests + _failedTests; | 223 int _completedTests() => _passedTests + _failedTests; |
| 236 | 224 |
| 237 int _foundTests = 0; | 225 int _foundTests = 0; |
| 238 int _passedTests = 0; | 226 int _passedTests = 0; |
| 239 int _failedTests = 0; | 227 int _failedTests = 0; |
| 240 int _skippedCompilations = 0; | |
| 241 bool _allTestsKnown = false; | 228 bool _allTestsKnown = false; |
| 242 Date _startTime; | 229 Date _startTime; |
| 243 bool _printTiming; | 230 bool _printTiming; |
| 244 List<TestCase> _tests; | 231 List<TestCase> _tests; |
| 245 List<String> _failureSummary; | 232 List<String> _failureSummary; |
| 246 } | 233 } |
| 247 | 234 |
| 248 | 235 |
| 249 class SilentProgressIndicator extends ProgressIndicator { | 236 class SilentProgressIndicator extends ProgressIndicator { |
| 250 SilentProgressIndicator(Date startTime, bool printTiming) | 237 SilentProgressIndicator(Date startTime, bool printTiming) |
| 251 : super(startTime, printTiming); | 238 : super(startTime, printTiming); |
| 252 void testAdded() { } | 239 void testAdded() { } |
| 253 void start(TestCase test) { } | 240 void start(TestCase test) { } |
| 254 void done(TestCase test) { } | 241 void done(TestCase test) { } |
| 255 void _printStartProgress(TestCase test) { } | 242 void _printStartProgress(TestCase test) { } |
| 256 void _printDoneProgress(TestCase test) { } | 243 void _printDoneProgress(TestCase test) { } |
| 257 void allTestsKnown() { } | 244 void allTestsKnown() { } |
| 258 void allDone() { } | 245 void allDone() { } |
| 259 } | 246 } |
| 260 | 247 |
| 261 abstract class CompactIndicator extends ProgressIndicator { | 248 abstract class CompactIndicator extends ProgressIndicator { |
| 262 CompactIndicator(Date startTime, bool printTiming) | 249 CompactIndicator(Date startTime, bool printTiming) |
| 263 : super(startTime, printTiming); | 250 : super(startTime, printTiming); |
| 264 | 251 |
| 265 void allDone() { | 252 void allDone() { |
| 266 stdout.write('\n'.charCodes); | 253 stdout.write('\n'.charCodes); |
| 267 _printFailureSummary(); | 254 _printFailureSummary(); |
| 268 _printSkippedCompilationInfo(); | |
| 269 _printTimingInformation(); | 255 _printTimingInformation(); |
| 270 if (_failedTests > 0) { | 256 if (_failedTests > 0) { |
| 271 // We may have printed many failure logs, so reprint the summary data. | 257 // We may have printed many failure logs, so reprint the summary data. |
| 272 _printProgress(); | 258 _printProgress(); |
| 273 print(''); | 259 print(''); |
| 274 } | 260 } |
| 275 stdout.close(); | 261 stdout.close(); |
| 276 stderr.close(); | 262 stderr.close(); |
| 277 if (_failedTests > 0) exit(1); | 263 if (_failedTests > 0) exit(1); |
| 278 } | 264 } |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 print(''); | 463 print(''); |
| 478 print('$config:'); | 464 print('$config:'); |
| 479 statuses.sort((a, b) => a.compareTo(b)); | 465 statuses.sort((a, b) => a.compareTo(b)); |
| 480 for (String status in statuses) { | 466 for (String status in statuses) { |
| 481 print(' $status'); | 467 print(' $status'); |
| 482 } | 468 } |
| 483 }); | 469 }); |
| 484 _printStatus(); | 470 _printStatus(); |
| 485 } | 471 } |
| 486 } | 472 } |
| OLD | NEW |