Skip to content

Instantly share code, notes, and snippets.

@dpino dpino/make-report.pl
Created Jan 28, 2018

Embed
What would you like to do?
#!/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.
my $agent=$ARGV[0];
my $errorfile=$ARGV[1];
if (!$agent || !$errorfile) {
print "Usage: make-report <agent> <errorfile>";
exit(1);
}
sub trim {
my($arg) = @_;
$arg =~ s/^\s+//;
$arg =~ s/\s+$//;
return $arg;
}
my $content=`cat $errorfile`;
my @lines = split("\n", $content);
my $open = 0, $i = 0;
my $num_files = 0, $num_errors = 0;
my %errors;
while ($i < scalar(@lines)) {
my $line = $lines[$i];
if ($lines[$i] =~ /^$agent:/ && $lines[$i+1] =~ /^---/) {
my ($agent, $filename) = split(": ", $lines[$i]);
my $error_message = trim($lines[$i+3]);
my $array = $errors{"$error_message"};
if ($array == undef) {
$array = [$filename];
$errors{"$error_message"} = $array;
$num_errors++;
} else {
push(@$array, $filename);
$errors{"$error_message"} = $array;
}
$num_files++;
$i += 4;
} else {
$i++;
}
}
print "$agent\n";
print "Distinct errors: $num_errors\n";
print "Total files: $num_files\n";
print "\n";
local @messages = sort(keys %errors);
foreach $key (@messages) {
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.