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>(); | 319 final archivedBinaries = <String, String>{}; |
320 | 320 |
321 void done(TestCase test) { | 321 void done(TestCase test) { |
322 if (test.unexpectedOutput && | 322 if (test.unexpectedOutput && |
323 test.result == Expectation.CRASH && | 323 test.result == Expectation.CRASH && |
324 test.lastCommandExecuted is ProcessCommand) { | 324 test.lastCommandExecuted is ProcessCommand) { |
325 final name = "core.${test.lastCommandOutput.pid}"; | 325 final name = "core.${test.lastCommandOutput.pid}"; |
326 final file = new File(name); | 326 final file = new File(name); |
327 final exists = file.existsSync(); | 327 final exists = file.existsSync(); |
328 if (exists) { | 328 if (exists) { |
329 final lastCommand = test.lastCommandExecuted as ProcessCommand; | 329 final lastCommand = test.lastCommandExecuted as ProcessCommand; |
330 // We have a coredump for the process. This coredump will be archived by | 330 // We have a coredump for the process. This coredump will be archived by |
331 // CoreDumpArchiver (see tools/utils.py). For debugging purposes we | 331 // CoreDumpArchiver (see tools/utils.py). For debugging purposes we |
332 // need to archive the crashed binary as well. To simplify the | 332 // need to archive the crashed binary as well. To simplify the |
333 // archiving code we simply copy binaries into current folder next to | 333 // archiving code we simply copy binaries into current folder next to |
334 // core dumps and name them `core.${mode}_${arch}_${binary_name}`. | 334 // core dumps and name them `core.${mode}_${arch}_${binary_name}`. |
335 final binName = lastCommand.executable; | 335 final binName = lastCommand.executable; |
336 final binFile = new File(binName); | 336 final binFile = new File(binName); |
337 final binBaseName = new Path(binName).filename; | 337 final binBaseName = new Path(binName).filename; |
338 if (archivedBinaries.contains(binBaseName)) { | 338 if (!archivedBinaries.containsKey(binName) && |
339 return; | 339 binFile.existsSync()) { |
| 340 final mode = test.configuration['mode']; |
| 341 final arch = test.configuration['arch']; |
| 342 final archived = "binary.${mode}_${arch}_${binBaseName}"; |
| 343 TestUtils.copyFile(new Path(binName), new Path(archived)); |
| 344 archivedBinaries[binName] = archived; |
340 } | 345 } |
341 | 346 |
342 if (binFile.existsSync()) { | 347 if (archivedBinaries.containsKey(binName)) { |
343 final mode = test.configuration['mode']; | 348 // We have found and copied the binary. |
344 final arch = test.configuration['arch']; | 349 var coredumpsList; |
345 TestUtils.copyFile(new Path(binName), | 350 try { |
346 new Path("core.${mode}_${arch}_${binBaseName}")); | 351 coredumpsList = |
347 archivedBinaries.add(binBaseName); | 352 new File('coredumps').openSync(mode: FileMode.APPEND); |
| 353 coredumpsList.writeStringSync( |
| 354 "${test.displayName},${name},${archivedBinaries[binName]}\n"); |
| 355 } catch (e) { |
| 356 print('Failed to add crash to coredumps list: ${e}'); |
| 357 } finally { |
| 358 try { |
| 359 if (coredumpsList != null) |
| 360 coredumpsList.closeSync(); |
| 361 } catch (e) { |
| 362 print('Failed to close coredumps list: ${e}'); |
| 363 } |
| 364 } |
348 } | 365 } |
349 } | 366 } |
350 } | 367 } |
351 } | 368 } |
352 } | 369 } |
353 | 370 |
354 class SummaryPrinter extends EventListener { | 371 class SummaryPrinter extends EventListener { |
355 final bool jsonOnly; | 372 final bool jsonOnly; |
356 | 373 |
357 SummaryPrinter({bool jsonOnly}) | 374 SummaryPrinter({bool jsonOnly}) |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 return new VerboseProgressIndicator(startTime); | 717 return new VerboseProgressIndicator(startTime); |
701 case 'status': | 718 case 'status': |
702 return new ProgressIndicator(startTime); | 719 return new ProgressIndicator(startTime); |
703 case 'buildbot': | 720 case 'buildbot': |
704 return new BuildbotProgressIndicator(startTime); | 721 return new BuildbotProgressIndicator(startTime); |
705 default: | 722 default: |
706 assert(false); | 723 assert(false); |
707 return null; | 724 return null; |
708 } | 725 } |
709 } | 726 } |
OLD | NEW |