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