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); |
kustermann
2017/01/20 14:56:55
Instead of doing this for every test, how about op
Vyacheslav Egorov (Google)
2017/01/20 16:44:45
I wanted to do it for each test so that even if te
| |
353 coredumpsList.writeStringSync( | |
354 "${test.displayName},${name},${archivedBinaries[binName]}\n"); | |
355 } finally { | |
356 if (coredumpsList != null) | |
kustermann
2017/01/20 14:56:55
You could as well move the 'new File(...') out of
Vyacheslav Egorov (Google)
2017/01/20 16:44:45
I wanted to catch and ignore exceptions from openS
| |
357 coredumpsList.close(); | |
358 } | |
348 } | 359 } |
349 } | 360 } |
350 } | 361 } |
351 } | 362 } |
352 } | 363 } |
353 | 364 |
354 class SummaryPrinter extends EventListener { | 365 class SummaryPrinter extends EventListener { |
355 final bool jsonOnly; | 366 final bool jsonOnly; |
356 | 367 |
357 SummaryPrinter({bool jsonOnly}) | 368 SummaryPrinter({bool jsonOnly}) |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
700 return new VerboseProgressIndicator(startTime); | 711 return new VerboseProgressIndicator(startTime); |
701 case 'status': | 712 case 'status': |
702 return new ProgressIndicator(startTime); | 713 return new ProgressIndicator(startTime); |
703 case 'buildbot': | 714 case 'buildbot': |
704 return new BuildbotProgressIndicator(startTime); | 715 return new BuildbotProgressIndicator(startTime); |
705 default: | 716 default: |
706 assert(false); | 717 assert(false); |
707 return null; | 718 return null; |
708 } | 719 } |
709 } | 720 } |
OLD | NEW |