Skip to content

Instantly share code, notes, and snippets.

@dpino dpino/wpt-run-report.pl
Last active Jan 16, 2018

Embed
What would you like to do?
Parses web-platform-test output and groups results by error message and list of files
#!/usr/bin/env perl
# Reads out a web-platform-test run output and prints out a report were errors
# are grouped by text message and list of files. Reports also on total number
# of distinct errors and total number of failing files.
# Arguments:
# Agent: Actual the head of the string containing the test name. The rest of
# the string should the filename.
# Errorfile: web-platform-test output of a ./wpt run.
$agent=$ARGV[0];
$errorfile=$ARGV[1];
if (!$agent || !$errorfile) {
print "Usage: make-report <agent> <errorfile>";
exit(1);
}
$content=`cat $errorfile`;
#print($content);
my @lines = split("\n", $content);
my $open = 0, $i = 0;
my $num_files = 0, $num_errors = 0;
my %errors;
while ($i < scalar(@lines)) {
$line = $lines[$i];
if ($line =~ /Expected PASS, got FAIL/) {
$open = 1;
$error_message = trim($lines[++$i]);
}
if ($line =~ /^---/) {
$open = 0;
}
if ($open == 1 && $line =~ /^$agent:/) {
$line =~ s/[^:]+:\s(.*)$/$1/;
my $array = $errors{"$error_message"};
if ($array == undef) {
$errors{"$error_message"} = [$line];
$num_errors++;
} else {
push(@$array, $line);
$errors{"$error_message"} = $array;
}
$num_files++;
}
$i = $i + 1;
}
print "$agent\n";
print "Distinct errors: $num_errors\n";
print "Total files: $num_files\n";
print "\n";
foreach $key (keys %errors) {
print "$key\n";
foreach $value (@{$errors{$key}}) {
print "$value\n";
}
print "--\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.