Last active
January 16, 2018 16:02
-
-
Save dpino/077f2b33ae7b8c9884b261ff59ea2349 to your computer and use it in GitHub Desktop.
Parses web-platform-test output and groups results by error message and list of files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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