| 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 28 matching lines...) Expand all Loading... |
| 39 } | 39 } |
| 40 } | 40 } |
| 41 | 41 |
| 42 void testAdded() { _foundTests++; } | 42 void testAdded() { _foundTests++; } |
| 43 | 43 |
| 44 void start(TestCase test) { | 44 void start(TestCase test) { |
| 45 _printStartProgress(test); | 45 _printStartProgress(test); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void done(TestCase test) { | 48 void done(TestCase test) { |
| 49 if (test.isFlaky && test.output.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 | 56 |
| 57 if (test.output.unexpectedOutput) { | 57 if (test.lastCommandOutput.unexpectedOutput) { |
| 58 _failedTests++; | 58 _failedTests++; |
| 59 _printFailureOutput(test); | 59 _printFailureOutput(test); |
| 60 } else { | 60 } else { |
| 61 _passedTests++; | 61 _passedTests++; |
| 62 } | 62 } |
| 63 _printDoneProgress(test); | 63 _printDoneProgress(test); |
| 64 // 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 |
| 65 // tests. | 65 // tests. |
| 66 if (_printTiming) _tests.add(test); | 66 if (_printTiming) _tests.add(test); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void allTestsKnown() { | 69 void allTestsKnown() { |
| 70 if (!_allTestsKnown) SummaryReport.printReport(); | 70 if (!_allTestsKnown) SummaryReport.printReport(); |
| 71 _allTestsKnown = true; | 71 _allTestsKnown = true; |
| 72 } | 72 } |
| 73 | 73 |
| 74 void _printTimingInformation() { | 74 void _printTimingInformation() { |
| 75 if (_printTiming) { | 75 if (_printTiming) { |
| 76 // TODO: We should take all the commands into account |
| 76 Duration d = (new Date.now()).difference(_startTime); | 77 Duration d = (new Date.now()).difference(_startTime); |
| 77 print('\n--- Total time: ${_timeString(d)} ---'); | 78 print('\n--- Total time: ${_timeString(d)} ---'); |
| 78 _tests.sort((a, b) { | 79 _tests.sort((a, b) { |
| 79 Duration aDuration = a.output.time; | 80 Duration aDuration = a.lastCommandOutput.time; |
| 80 Duration bDuration = b.output.time; | 81 Duration bDuration = b.lastCommandOutput.time; |
| 81 return bDuration.inMilliseconds - aDuration.inMilliseconds; | 82 return bDuration.inMilliseconds - aDuration.inMilliseconds; |
| 82 }); | 83 }); |
| 83 for (int i = 0; i < 20 && i < _tests.length; i++) { | 84 for (int i = 0; i < 20 && i < _tests.length; i++) { |
| 84 var name = _tests[i].displayName; | 85 var name = _tests[i].displayName; |
| 85 var duration = _tests[i].output.time; | 86 var duration = _tests[i].lastCommandOutput.time; |
| 86 var configuration = _tests[i].configurationString; | 87 var configuration = _tests[i].configurationString; |
| 87 print('${duration} - $configuration $name'); | 88 print('${duration} - $configuration $name'); |
| 88 } | 89 } |
| 89 } | 90 } |
| 90 } | 91 } |
| 91 | 92 |
| 92 void allDone() { | 93 void allDone() { |
| 93 _printFailureSummary(); | 94 _printFailureSummary(); |
| 94 _printStatus(); | 95 _printStatus(); |
| 95 _printTimingInformation(); | 96 _printTimingInformation(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 List<String> output = new List<String>(); | 141 List<String> output = new List<String>(); |
| 141 output.add(''); | 142 output.add(''); |
| 142 output.add(_header('FAILED: ${test.configurationString}' | 143 output.add(_header('FAILED: ${test.configurationString}' |
| 143 ' ${test.displayName}')); | 144 ' ${test.displayName}')); |
| 144 StringBuffer expected = new StringBuffer(); | 145 StringBuffer expected = new StringBuffer(); |
| 145 expected.add('Expected: '); | 146 expected.add('Expected: '); |
| 146 for (var expectation in test.expectedOutcomes) { | 147 for (var expectation in test.expectedOutcomes) { |
| 147 expected.add('$expectation '); | 148 expected.add('$expectation '); |
| 148 } | 149 } |
| 149 output.add(expected.toString()); | 150 output.add(expected.toString()); |
| 150 output.add('Actual: ${test.output.result}'); | 151 output.add('Actual: ${test.lastCommandOutput.result}'); |
| 151 if (!test.output.hasTimedOut && test.info != null) { | 152 if (!test.lastCommandOutput.hasTimedOut && test.info != null) { |
| 152 if (test.output.incomplete && !test.info.hasCompileError) { | 153 if (test.lastCommandOutput.incomplete && !test.info.hasCompileError) { |
| 153 output.add('Unexpected compile-time error.'); | 154 output.add('Unexpected compile-time error.'); |
| 154 } else { | 155 } else { |
| 155 if (test.info.hasCompileError) { | 156 if (test.info.hasCompileError) { |
| 156 output.add('Compile-time error expected.'); | 157 output.add('Compile-time error expected.'); |
| 157 } | 158 } |
| 158 if (test.info.hasRuntimeError) { | 159 if (test.info.hasRuntimeError) { |
| 159 output.add('Runtime error expected.'); | 160 output.add('Runtime error expected.'); |
| 160 } | 161 } |
| 161 } | 162 } |
| 162 } | 163 } |
| 163 if (!test.output.diagnostics.isEmpty) { | 164 if (!test.lastCommandOutput.diagnostics.isEmpty) { |
| 164 String prefix = 'diagnostics:'; | 165 String prefix = 'diagnostics:'; |
| 165 for (var s in test.output.diagnostics) { | 166 for (var s in test.lastCommandOutput.diagnostics) { |
| 166 output.add('$prefix ${s}'); | 167 output.add('$prefix ${s}'); |
| 167 prefix = ' '; | 168 prefix = ' '; |
| 168 } | 169 } |
| 169 } | 170 } |
| 170 if (!test.output.stdout.isEmpty) { | 171 if (!test.lastCommandOutput.stdout.isEmpty) { |
| 171 output.add(''); | 172 output.add(''); |
| 172 output.add('stdout:'); | 173 output.add('stdout:'); |
| 173 for (var s in test.output.stdout) { | 174 for (var s in test.lastCommandOutput.stdout) { |
| 174 output.add(s); | 175 output.add(s); |
| 175 } | 176 } |
| 176 } | 177 } |
| 177 if (!test.output.stderr.isEmpty) { | 178 if (!test.lastCommandOutput.stderr.isEmpty) { |
| 178 output.add(''); | 179 output.add(''); |
| 179 output.add('stderr:'); | 180 output.add('stderr:'); |
| 180 for (var s in test.output.stderr) { | 181 for (var s in test.lastCommandOutput.stderr) { |
| 181 output.add(s); | 182 output.add(s); |
| 182 } | 183 } |
| 183 } | 184 } |
| 184 for (Command c in test.commands) { | 185 for (Command c in test.commands) { |
| 185 output.add(''); | 186 output.add(''); |
| 186 String message = (c == test.commands.last | 187 String message = (c == test.commands.last |
| 187 ? "Command line" : "Compilation command"); | 188 ? "Command line" : "Compilation command"); |
| 188 output.add('$message: ${c.commandLine}'); | 189 output.add('$message: ${c.commandLine}'); |
| 189 } | 190 } |
| 190 return output; | 191 return output; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 | 341 |
| 341 class LineProgressIndicator extends ProgressIndicator { | 342 class LineProgressIndicator extends ProgressIndicator { |
| 342 LineProgressIndicator(Date startTime, bool printTiming) | 343 LineProgressIndicator(Date startTime, bool printTiming) |
| 343 : super(startTime, printTiming); | 344 : super(startTime, printTiming); |
| 344 | 345 |
| 345 void _printStartProgress(TestCase test) { | 346 void _printStartProgress(TestCase test) { |
| 346 } | 347 } |
| 347 | 348 |
| 348 void _printDoneProgress(TestCase test) { | 349 void _printDoneProgress(TestCase test) { |
| 349 var status = 'pass'; | 350 var status = 'pass'; |
| 350 if (test.output.unexpectedOutput) { | 351 if (test.lastCommandOutput.unexpectedOutput) { |
| 351 status = 'fail'; | 352 status = 'fail'; |
| 352 } | 353 } |
| 353 print('Done ${test.configurationString} ${test.displayName}: $status'); | 354 print('Done ${test.configurationString} ${test.displayName}: $status'); |
| 354 } | 355 } |
| 355 } | 356 } |
| 356 | 357 |
| 357 | 358 |
| 358 class VerboseProgressIndicator extends ProgressIndicator { | 359 class VerboseProgressIndicator extends ProgressIndicator { |
| 359 VerboseProgressIndicator(Date startTime, bool printTiming) | 360 VerboseProgressIndicator(Date startTime, bool printTiming) |
| 360 : super(startTime, printTiming); | 361 : super(startTime, printTiming); |
| 361 | 362 |
| 362 void _printStartProgress(TestCase test) { | 363 void _printStartProgress(TestCase test) { |
| 363 print('Starting ${test.configurationString} ${test.displayName}...'); | 364 print('Starting ${test.configurationString} ${test.displayName}...'); |
| 364 } | 365 } |
| 365 | 366 |
| 366 void _printDoneProgress(TestCase test) { | 367 void _printDoneProgress(TestCase test) { |
| 367 var status = 'pass'; | 368 var status = 'pass'; |
| 368 if (test.output.unexpectedOutput) { | 369 if (test.lastCommandOutput.unexpectedOutput) { |
| 369 status = 'fail'; | 370 status = 'fail'; |
| 370 } | 371 } |
| 371 print('Done ${test.configurationString} ${test.displayName}: $status'); | 372 print('Done ${test.configurationString} ${test.displayName}: $status'); |
| 372 } | 373 } |
| 373 } | 374 } |
| 374 | 375 |
| 375 | 376 |
| 376 class StatusProgressIndicator extends ProgressIndicator { | 377 class StatusProgressIndicator extends ProgressIndicator { |
| 377 StatusProgressIndicator(Date startTime, bool printTiming) | 378 StatusProgressIndicator(Date startTime, bool printTiming) |
| 378 : super(startTime, printTiming); | 379 : super(startTime, printTiming); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 389 static String stepName; | 390 static String stepName; |
| 390 | 391 |
| 391 BuildbotProgressIndicator(Date startTime, bool printTiming) | 392 BuildbotProgressIndicator(Date startTime, bool printTiming) |
| 392 : super(startTime, printTiming); | 393 : super(startTime, printTiming); |
| 393 | 394 |
| 394 void _printStartProgress(TestCase test) { | 395 void _printStartProgress(TestCase test) { |
| 395 } | 396 } |
| 396 | 397 |
| 397 void _printDoneProgress(TestCase test) { | 398 void _printDoneProgress(TestCase test) { |
| 398 var status = 'pass'; | 399 var status = 'pass'; |
| 399 if (test.output.unexpectedOutput) { | 400 if (test.lastCommandOutput.unexpectedOutput) { |
| 400 status = 'fail'; | 401 status = 'fail'; |
| 401 } | 402 } |
| 402 var percent = ((_completedTests() / _foundTests) * 100).toInt().toString(); | 403 var percent = ((_completedTests() / _foundTests) * 100).toInt().toString(); |
| 403 print('Done ${test.configurationString} ${test.displayName}: $status'); | 404 print('Done ${test.configurationString} ${test.displayName}: $status'); |
| 404 print('@@@STEP_CLEAR@@@'); | 405 print('@@@STEP_CLEAR@@@'); |
| 405 print('@@@STEP_TEXT@ $percent% +$_passedTests -$_failedTests @@@'); | 406 print('@@@STEP_TEXT@ $percent% +$_passedTests -$_failedTests @@@'); |
| 406 } | 407 } |
| 407 | 408 |
| 408 void _printFailureSummary() { | 409 void _printFailureSummary() { |
| 409 if (!_failureSummary.isEmpty) { | 410 if (!_failureSummary.isEmpty) { |
| 410 print('@@@STEP_FAILURE@@@'); | 411 print('@@@STEP_FAILURE@@@'); |
| 411 print('@@@BUILD_STEP $stepName failures@@@'); | 412 print('@@@BUILD_STEP $stepName failures@@@'); |
| 412 } | 413 } |
| 413 super._printFailureSummary(); | 414 super._printFailureSummary(); |
| 414 } | 415 } |
| 415 } | 416 } |
| 416 | 417 |
| 417 class DiffProgressIndicator extends ColorProgressIndicator { | 418 class DiffProgressIndicator extends ColorProgressIndicator { |
| 418 Map<String, List<String>> statusToConfigs = new Map<String, List<String>>(); | 419 Map<String, List<String>> statusToConfigs = new Map<String, List<String>>(); |
| 419 | 420 |
| 420 DiffProgressIndicator(Date startTime, bool printTiming) | 421 DiffProgressIndicator(Date startTime, bool printTiming) |
| 421 : super(startTime, printTiming); | 422 : super(startTime, printTiming); |
| 422 | 423 |
| 423 void _printFailureOutput(TestCase test) { | 424 void _printFailureOutput(TestCase test) { |
| 424 String status = '${test.displayName}: ${test.output.result}'; | 425 String status = '${test.displayName}: ${test.lastCommandOutput.result}'; |
| 425 List<String> configs = | 426 List<String> configs = |
| 426 statusToConfigs.putIfAbsent(status, () => <String>[]); | 427 statusToConfigs.putIfAbsent(status, () => <String>[]); |
| 427 configs.add(test.configurationString); | 428 configs.add(test.configurationString); |
| 428 if (test.output.hasTimedOut) { | 429 if (test.lastCommandOutput.hasTimedOut) { |
| 429 print('\n${test.displayName} timed out on ${test.configurationString}'); | 430 print('\n${test.displayName} timed out on ${test.configurationString}'); |
| 430 } | 431 } |
| 431 } | 432 } |
| 432 | 433 |
| 433 String _extractRuntime(String configuration) { | 434 String _extractRuntime(String configuration) { |
| 434 // Extract runtime from a configuration, for example, | 435 // Extract runtime from a configuration, for example, |
| 435 // 'none-vm-checked release_ia32'. | 436 // 'none-vm-checked release_ia32'. |
| 436 List<String> runtime = configuration.split(' ')[0].split('-'); | 437 List<String> runtime = configuration.split(' ')[0].split('-'); |
| 437 return '${runtime[0]}-${runtime[1]}'; | 438 return '${runtime[0]}-${runtime[1]}'; |
| 438 } | 439 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 462 print(''); | 463 print(''); |
| 463 print('$config:'); | 464 print('$config:'); |
| 464 statuses.sort((a, b) => a.compareTo(b)); | 465 statuses.sort((a, b) => a.compareTo(b)); |
| 465 for (String status in statuses) { | 466 for (String status in statuses) { |
| 466 print(' $status'); | 467 print(' $status'); |
| 467 } | 468 } |
| 468 }); | 469 }); |
| 469 _printStatus(); | 470 _printStatus(); |
| 470 } | 471 } |
| 471 } | 472 } |
| OLD | NEW |