| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 status_files.log_parser; | 5 library status_files.log_parser; |
| 6 | 6 |
| 7 import 'record.dart'; | 7 import 'record.dart'; |
| 8 | 8 |
| 9 final RegExp _stackRE = new RegExp('#[0-9]* '); | 9 final RegExp _stackRE = new RegExp('#[0-9]* '); |
| 10 final RegExp _assertionFileRE = new RegExp(r"'file:[^']*/sdk/pkg/"); |
| 11 final String _assertionFileReplacement = r"'file:*/pkg/"; |
| 10 | 12 |
| 11 /// Extracts test records from a test.py [log]. | 13 /// Extracts test records from a test.py [log]. |
| 12 List<Record> parse(String log) { | 14 List<Record> parse(String log) { |
| 13 var records = []; | 15 var records = []; |
| 14 var suite; | 16 var suite; |
| 15 var test; | 17 var test; |
| 16 var config; | 18 var config; |
| 17 var expected; | 19 var expected; |
| 18 var actual; | 20 var actual; |
| 19 var reason; | 21 var reason; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 37 .replaceAll('release_x64', ''); | 39 .replaceAll('release_x64', ''); |
| 38 } | 40 } |
| 39 if (line.startsWith("Expected: ")) { | 41 if (line.startsWith("Expected: ")) { |
| 40 expected = line.substring("Expected: ".length).trim(); | 42 expected = line.substring("Expected: ".length).trim(); |
| 41 } | 43 } |
| 42 if (line.startsWith("Actual: ")) { | 44 if (line.startsWith("Actual: ")) { |
| 43 actual = line.substring("Actual: ".length).trim(); | 45 actual = line.substring("Actual: ".length).trim(); |
| 44 } | 46 } |
| 45 if (line.startsWith("The compiler crashed:")) { | 47 if (line.startsWith("The compiler crashed:")) { |
| 46 reason = line.substring("The compiler crashed:".length).trim(); | 48 reason = line.substring("The compiler crashed:".length).trim(); |
| 49 reason = reason.replaceFirst(_assertionFileRE, _assertionFileReplacement); |
| 47 paragraph.clear(); | 50 paragraph.clear(); |
| 48 } | 51 } |
| 49 | 52 |
| 50 if (line.startsWith(_stackRE)) { | 53 if (line.startsWith(_stackRE)) { |
| 51 stack.add(line); | 54 stack.add(line); |
| 52 fullReason ??= paragraph.take(5).join('\n'); | 55 fullReason ??= paragraph.take(5).join('\n'); |
| 53 paragraph.clear(); | 56 paragraph.clear(); |
| 54 } else { | 57 } else { |
| 55 paragraph.add(line); | 58 paragraph.add(line); |
| 56 } | 59 } |
| 57 | 60 |
| 58 if (reproIsNext) { | 61 if (reproIsNext) { |
| 59 records.add(new Record(suite, test, config, expected, actual, reason, | 62 records.add(new Record(suite, test, config, expected, actual, reason, |
| 60 line.trim(), fullReason, stack)); | 63 line.trim(), fullReason, stack)); |
| 61 suite = test = config = expected = actual = reason = null; | 64 suite = test = config = expected = actual = reason = null; |
| 62 stack = []; | 65 stack = []; |
| 63 fullReason = null; | 66 fullReason = null; |
| 64 paragraph.clear(); | 67 paragraph.clear(); |
| 65 reproIsNext = false; | 68 reproIsNext = false; |
| 66 } | 69 } |
| 67 if (line.startsWith("Short reproduction command (experimental):")) { | 70 if (line.startsWith("Short reproduction command (experimental):")) { |
| 68 reproIsNext = true; | 71 reproIsNext = true; |
| 69 } | 72 } |
| 70 } | 73 } |
| 71 return records; | 74 return records; |
| 72 } | 75 } |
| OLD | NEW |