add error message as a comment on the logs

BUG=

Review-Url: https://codereview.chromium.org/2996543002 .
This commit is contained in:
Sigmund Cherem 2017-08-04 13:21:33 -07:00
parent 5241f37143
commit 06a929434e
3 changed files with 22 additions and 10 deletions

View file

@ -14,6 +14,7 @@ List<Record> parse(String log) {
var config;
var expected;
var actual;
var reason;
bool reproIsNext = false;
for (var line in log.split('\n')) {
if (line.startsWith("FAILED: ")) {
@ -36,10 +37,13 @@ List<Record> parse(String log) {
if (line.startsWith("Actual: ")) {
actual = line.substring("Actual: ".length).trim();
}
if (line.startsWith("The compiler crashed:")) {
reason = line.substring("The compiler crashed:".length).trim();
}
if (reproIsNext) {
records
.add(new Record(suite, test, config, expected, actual, line.trim()));
suite = test = config = expected = actual = null;
records.add(new Record(
suite, test, config, expected, actual, reason, line.trim()));
suite = test = config = expected = actual = reason = null;
reproIsNext = false;
}
if (line.startsWith("Short reproduction command (experimental):")) {

View file

@ -14,6 +14,7 @@ class Record implements Comparable<Record> {
final String expected;
final String actual;
final String repro;
final String reason;
// TODO(sigmund): extract also a failure reason if any (e.g. a stack trace or
// error message for crashes).
@ -21,7 +22,7 @@ class Record implements Comparable<Record> {
bool get isPassing => actual == 'Pass';
Record(this.suite, this.test, this.config, this.expected, this.actual,
this.repro);
this.reason, this.repro);
int compareTo(Record other) {
if (suite == null && other.suite != null) return -1;

View file

@ -83,8 +83,9 @@ void updateLogs(String mode, String log) {
class ExistingEntry {
final String test;
final String status;
final bool hasComment;
ExistingEntry(this.test, this.status);
ExistingEntry(this.test, this.status, this.hasComment);
static parse(String line) {
var colonIndex = line.indexOf(':');
@ -94,7 +95,7 @@ class ExistingEntry {
if (commentIndex != -1) {
status = status.substring(0, commentIndex);
}
return new ExistingEntry(test, status);
return new ExistingEntry(test, status, commentIndex != -1);
}
}
@ -133,7 +134,8 @@ class ConfigurationInSuiteSection {
var newContents = new StringBuffer();
newContents.write(_contents.substring(0, _begin));
addFromRecord(Record record) {
newContents.writeln('${record.test}: ${record.actual}');
var comment = record.reason != null ? ' # ${record.reason}' : '';
newContents.writeln('${record.test}: ${record.actual}$comment');
}
int i = 0, j = 0;
@ -162,9 +164,14 @@ class ConfigurationInSuiteSection {
}
j++;
} else if (existing.status == record.actual) {
// This also should only happen if the patching has already been done.
// We don't complain to make this script idempotent.
newContents.writeln(existingLine);
if (!existing.hasComment && record.reason != null) {
addFromRecord(record);
changes++;
} else {
// This also should only happen if the patching has already been done.
// We don't complain to make this script idempotent.
newContents.writeln(existingLine);
}
ignored++;
i++;
j++;