OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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:async"; | 7 import "dart:async"; |
8 import "dart:io"; | 8 import "dart:io"; |
9 import "dart:io" as io; | 9 import "dart:io" as io; |
10 import "dart:convert" show JSON; | 10 import "dart:convert" show JSON; |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 | 269 |
270 void _writeTestOutcomeRecord(Map record) { | 270 void _writeTestOutcomeRecord(Map record) { |
271 if (_sink == null) { | 271 if (_sink == null) { |
272 _sink = new File(TestUtils.testOutcomeFileName()) | 272 _sink = new File(TestUtils.testOutcomeFileName()) |
273 .openWrite(mode: FileMode.APPEND); | 273 .openWrite(mode: FileMode.APPEND); |
274 } | 274 } |
275 _sink.write("${JSON.encode(record)}\n"); | 275 _sink.write("${JSON.encode(record)}\n"); |
276 } | 276 } |
277 } | 277 } |
278 | 278 |
| 279 |
| 280 class UnexpectedCrashDumpArchiver extends EventListener { |
| 281 void done(TestCase test) { |
| 282 if (test.unexpectedOutput && test.result == Expectation.CRASH) { |
| 283 var name = "core.dart.${test.lastCommandOutput.pid}"; |
| 284 var file = new File(name); |
| 285 if (file.existsSync()) { |
| 286 // Find the binary - we assume this is the first part of the command |
| 287 var binName = test.lastCommandExecuted.toString().split(' ').first; |
| 288 var binFile = new File(binName); |
| 289 var binBaseName = new Path(binName).filename; |
| 290 if (binFile.existsSync()) { |
| 291 var tmpPath = new Path(Directory.systemTemp.path); |
| 292 var dir = new Path(TestUtils.mkdirRecursive(tmpPath, |
| 293 new Path('coredump_${test.lastCommandOutput.pid}')).path); |
| 294 TestUtils.copyFile(new Path(name), dir.append(name)); |
| 295 TestUtils.copyFile(new Path(binName), dir.append(binBaseName)); |
| 296 print("\nCopied core dump and binary for unexpected crash to: " |
| 297 "$dir"); |
| 298 } |
| 299 } |
| 300 } |
| 301 } |
| 302 } |
| 303 |
| 304 |
279 class SummaryPrinter extends EventListener { | 305 class SummaryPrinter extends EventListener { |
280 void allTestsKnown() { | 306 void allTestsKnown() { |
281 if (SummaryReport.total > 0) { | 307 if (SummaryReport.total > 0) { |
282 SummaryReport.printReport(); | 308 SummaryReport.printReport(); |
283 } | 309 } |
284 } | 310 } |
285 } | 311 } |
286 | 312 |
| 313 |
287 class TimingPrinter extends EventListener { | 314 class TimingPrinter extends EventListener { |
288 final _command2testCases = new Map<Command, List<TestCase>>(); | 315 final _command2testCases = new Map<Command, List<TestCase>>(); |
289 final _commandOutputs = new Set<CommandOutput>(); | 316 final _commandOutputs = new Set<CommandOutput>(); |
290 DateTime _startTime; | 317 DateTime _startTime; |
291 | 318 |
292 TimingPrinter(this._startTime); | 319 TimingPrinter(this._startTime); |
293 | 320 |
294 void done(TestCase testCase) { | 321 void done(TestCase testCase) { |
295 for (var commandOutput in testCase.commandOutputs.values) { | 322 for (var commandOutput in testCase.commandOutputs.values) { |
296 var command = commandOutput.command; | 323 var command = commandOutput.command; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 class LineProgressIndicator extends EventListener { | 476 class LineProgressIndicator extends EventListener { |
450 void done(TestCase test) { | 477 void done(TestCase test) { |
451 var status = 'pass'; | 478 var status = 'pass'; |
452 if (test.unexpectedOutput) { | 479 if (test.unexpectedOutput) { |
453 status = 'fail'; | 480 status = 'fail'; |
454 } | 481 } |
455 print('Done ${test.configurationString} ${test.displayName}: $status'); | 482 print('Done ${test.configurationString} ${test.displayName}: $status'); |
456 } | 483 } |
457 } | 484 } |
458 | 485 |
| 486 |
459 class TestFailurePrinter extends EventListener { | 487 class TestFailurePrinter extends EventListener { |
460 bool _printSummary; | 488 bool _printSummary; |
461 var _formatter; | 489 var _formatter; |
462 var _failureSummary = <String>[]; | 490 var _failureSummary = <String>[]; |
463 var _failedTests= 0; | 491 var _failedTests= 0; |
464 | 492 |
465 TestFailurePrinter(this._printSummary, | 493 TestFailurePrinter(this._printSummary, |
466 [this._formatter = const Formatter()]); | 494 [this._formatter = const Formatter()]); |
467 | 495 |
468 void done(TestCase test) { | 496 void done(TestCase test) { |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 return new VerboseProgressIndicator(startTime); | 658 return new VerboseProgressIndicator(startTime); |
631 case 'status': | 659 case 'status': |
632 return new ProgressIndicator(startTime); | 660 return new ProgressIndicator(startTime); |
633 case 'buildbot': | 661 case 'buildbot': |
634 return new BuildbotProgressIndicator(startTime); | 662 return new BuildbotProgressIndicator(startTime); |
635 default: | 663 default: |
636 assert(false); | 664 assert(false); |
637 break; | 665 break; |
638 } | 666 } |
639 } | 667 } |
OLD | NEW |