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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 void _writeTestOutcomeRecord(Map record) { | 309 void _writeTestOutcomeRecord(Map record) { |
310 if (_sink == null) { | 310 if (_sink == null) { |
311 _sink = new File(TestUtils.testOutcomeFileName()) | 311 _sink = new File(TestUtils.testOutcomeFileName()) |
312 .openWrite(mode: FileMode.APPEND); | 312 .openWrite(mode: FileMode.APPEND); |
313 } | 313 } |
314 _sink.write("${JSON.encode(record)}\n"); | 314 _sink.write("${JSON.encode(record)}\n"); |
315 } | 315 } |
316 } | 316 } |
317 | 317 |
318 class UnexpectedCrashDumpArchiver extends EventListener { | 318 class UnexpectedCrashDumpArchiver extends EventListener { |
319 final archivedBinaries = new Set<String>(); | |
320 | |
321 void done(TestCase test) { | 319 void done(TestCase test) { |
322 if (test.unexpectedOutput && test.result == Expectation.CRASH) { | 320 if (test.unexpectedOutput && test.result == Expectation.CRASH) { |
323 final name = "core.${test.lastCommandOutput.pid}"; | 321 var name = "core.dart.${test.lastCommandOutput.pid}"; |
324 final file = new File(name); | 322 var file = new File(name); |
325 final exists = file.existsSync(); | 323 if (file.existsSync()) { |
326 if (exists) { | 324 // Find the binary - we assume this is the first part of the command |
327 // We have a coredump for the process. This coredump will be archived by | 325 var binName = test.lastCommandExecuted.toString().split(' ').first; |
328 // CoreDumpArchiver (see tools/utils.py). For debugging purposes we | 326 var binFile = new File(binName); |
329 // need to archive the crashed binary as well. To simplify the | 327 var binBaseName = new Path(binName).filename; |
330 // archiving code we simply copy binaries into current folder next to | |
331 // core dumps and name them `core.${mode}_${arch}_${binary_name}`. | |
332 final binName = test.lastCommandExecuted.executable; | |
333 final binFile = new File(binName); | |
334 final binBaseName = new Path(binName).filename; | |
335 if (archivedBinaries.contains(binBaseName)) { | |
336 return; | |
337 } | |
338 | |
339 if (binFile.existsSync()) { | 328 if (binFile.existsSync()) { |
340 final mode = test.configuration['mode']; | 329 var tmpPath = new Path(Directory.systemTemp.path); |
341 final arch = test.configuration['arch']; | 330 var dir = new Path(TestUtils |
342 TestUtils.copyFile(new Path(binName), | 331 .mkdirRecursive( |
343 new Path("core.${mode}_${arch}_${binBaseName}")); | 332 tmpPath, new Path('coredump_${test.lastCommandOutput.pid}')) |
344 archivedBinaries.add(binBaseName); | 333 .path); |
| 334 TestUtils.copyFile(new Path(name), dir.append(name)); |
| 335 TestUtils.copyFile(new Path(binName), dir.append(binBaseName)); |
| 336 print("\nCopied core dump and binary for unexpected crash to: " |
| 337 "$dir"); |
345 } | 338 } |
346 } | 339 } |
347 } | 340 } |
348 } | 341 } |
349 } | 342 } |
350 | 343 |
351 class SummaryPrinter extends EventListener { | 344 class SummaryPrinter extends EventListener { |
352 final bool jsonOnly; | 345 final bool jsonOnly; |
353 | 346 |
354 SummaryPrinter({bool jsonOnly}) | 347 SummaryPrinter({bool jsonOnly}) |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 return new VerboseProgressIndicator(startTime); | 690 return new VerboseProgressIndicator(startTime); |
698 case 'status': | 691 case 'status': |
699 return new ProgressIndicator(startTime); | 692 return new ProgressIndicator(startTime); |
700 case 'buildbot': | 693 case 'buildbot': |
701 return new BuildbotProgressIndicator(startTime); | 694 return new BuildbotProgressIndicator(startTime); |
702 default: | 695 default: |
703 assert(false); | 696 assert(false); |
704 return null; | 697 return null; |
705 } | 698 } |
706 } | 699 } |
OLD | NEW |