Chromium Code Reviews| 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"); | |
| 11 | |
| 12 const FAILED_FLAKY_TESTS_LOGFILE = "failed_flaky_tests.log"; | |
| 10 | 13 |
| 11 class ProgressIndicator { | 14 class ProgressIndicator { |
| 12 ProgressIndicator(this._startTime, this._printTiming) | 15 ProgressIndicator(this._startTime, this._printTiming) |
| 13 : _tests = [], _failureSummary = []; | 16 : _tests = [], _failureSummary = []; |
| 14 | 17 |
| 15 factory ProgressIndicator.fromName(String name, | 18 factory ProgressIndicator.fromName(String name, |
| 16 Date startTime, | 19 Date startTime, |
| 17 bool printTiming) { | 20 bool printTiming) { |
| 18 switch (name) { | 21 switch (name) { |
| 19 case 'compact': | 22 case 'compact': |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 38 } | 41 } |
| 39 } | 42 } |
| 40 | 43 |
| 41 void testAdded() { _foundTests++; } | 44 void testAdded() { _foundTests++; } |
| 42 | 45 |
| 43 void start(TestCase test) { | 46 void start(TestCase test) { |
| 44 _printStartProgress(test); | 47 _printStartProgress(test); |
| 45 } | 48 } |
| 46 | 49 |
| 47 void done(TestCase test) { | 50 void done(TestCase test) { |
| 51 if (test.isExpectedToBeFlaky() && test.output.result != PASS) { | |
| 52 var report = new StringBuffer(); | |
|
ricow1
2012/11/07 19:56:51
extract the body of this conditional into a separa
kustermann
2012/11/08 09:15:13
I refactored this instead
| |
| 53 report.add("Flaky test ${test.displayName} failed: \n"); | |
|
ricow1
2012/11/07 19:56:51
How about refactoring _printFailureOutput to call
kustermann
2012/11/08 09:15:13
Done.
| |
| 54 report.add("--------------------------------------------------\n"); | |
| 55 report.add("stdout of ${test.displayName} was:\n"); | |
| 56 for (var s in test.output.stdout) { | |
| 57 report.add(" $s\n"); | |
| 58 } | |
| 59 report.add("\n"); | |
| 60 report.add("stderr of ${test.displayName} was:\n"); | |
| 61 for (var s in test.output.stderr) { | |
| 62 report.add(" $s\n"); | |
| 63 } | |
| 64 report.add("\n\n"); | |
| 65 appendToFlakyFile(report.toString()); | |
| 66 } | |
| 67 | |
| 48 if (test.output.unexpectedOutput) { | 68 if (test.output.unexpectedOutput) { |
| 49 _failedTests++; | 69 _failedTests++; |
| 50 _printFailureOutput(test); | 70 _printFailureOutput(test); |
| 51 } else { | 71 } else { |
| 52 _passedTests++; | 72 _passedTests++; |
| 53 } | 73 } |
| 54 _printDoneProgress(test); | 74 _printDoneProgress(test); |
| 55 // If we need to print timing information we hold on to all completed | 75 // If we need to print timing information we hold on to all completed |
| 56 // tests. | 76 // tests. |
| 57 if (_printTiming) _tests.add(test); | 77 if (_printTiming) _tests.add(test); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 print('=== All tests succeeded'); | 209 print('=== All tests succeeded'); |
| 190 print('===\n'); | 210 print('===\n'); |
| 191 } else { | 211 } else { |
| 192 var pluralSuffix = _failedTests != 1 ? 's' : ''; | 212 var pluralSuffix = _failedTests != 1 ? 's' : ''; |
| 193 print('\n==='); | 213 print('\n==='); |
| 194 print('=== ${_failedTests} test$pluralSuffix failed'); | 214 print('=== ${_failedTests} test$pluralSuffix failed'); |
| 195 print('===\n'); | 215 print('===\n'); |
| 196 } | 216 } |
| 197 } | 217 } |
| 198 | 218 |
| 219 void appendToFlakyFile(String msg) { | |
| 220 var file = new File(FAILED_FLAKY_TESTS_LOGFILE); | |
| 221 var fd = file.openSync(FileMode.APPEND); | |
| 222 fd.writeStringSync(msg); | |
| 223 fd.closeSync(); | |
| 224 } | |
| 225 | |
| 199 int get numFailedTests => _failedTests; | 226 int get numFailedTests => _failedTests; |
| 200 | 227 |
| 201 int _completedTests() => _passedTests + _failedTests; | 228 int _completedTests() => _passedTests + _failedTests; |
| 202 | 229 |
| 203 int _foundTests = 0; | 230 int _foundTests = 0; |
| 204 int _passedTests = 0; | 231 int _passedTests = 0; |
| 205 int _failedTests = 0; | 232 int _failedTests = 0; |
| 206 bool _allTestsKnown = false; | 233 bool _allTestsKnown = false; |
| 207 Date _startTime; | 234 Date _startTime; |
| 208 bool _printTiming; | 235 bool _printTiming; |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 441 print(''); | 468 print(''); |
| 442 print('$config:'); | 469 print('$config:'); |
| 443 statuses.sort((a, b) => a.compareTo(b)); | 470 statuses.sort((a, b) => a.compareTo(b)); |
| 444 for (String status in statuses) { | 471 for (String status in statuses) { |
| 445 print(' $status'); | 472 print(' $status'); |
| 446 } | 473 } |
| 447 }); | 474 }); |
| 448 _printStatus(); | 475 _printStatus(); |
| 449 } | 476 } |
| 450 } | 477 } |
| OLD | NEW |