mirror of
https://github.com/robertkrimen/otto
synced 2025-10-12 20:27:30 +08:00
47 lines
761 B
Perl
Executable File
47 lines
761 B
Perl
Executable File
#!/usr/bin/env perl
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
use Modern::Perl;
|
|
|
|
use JSON;
|
|
my $json = JSON->new->pretty;
|
|
|
|
my $digest = $json->decode(join '', <STDIN>);
|
|
|
|
my %tally = (
|
|
pass => 0,
|
|
fail => 0,
|
|
panic => 0,
|
|
total => 0,
|
|
);
|
|
|
|
my @panic;
|
|
|
|
for my $test (@$digest) {
|
|
$tally{total} += 1;
|
|
if ($test->{pass}) {
|
|
$tally{pass} += 1;
|
|
} else {
|
|
$tally{fail} += 1;
|
|
if ($test->{panic}) {
|
|
$tally{panic} += 1;
|
|
push @panic, $test->{test};
|
|
}
|
|
}
|
|
}
|
|
|
|
my $pass_percentage = sprintf "%.2f", 100 * ($tally{pass} / $tally{total});
|
|
|
|
print <<_END_;
|
|
Passing $pass_percentage%: $tally{pass} / $tally{total} ($tally{panic}!)
|
|
_END_
|
|
|
|
if (@panic) {
|
|
print <<_END_;
|
|
Panicking:
|
|
_END_
|
|
say join "\n", @panic;
|
|
}
|