Hacking Test::Harness
- So we need to change Test::Harness.
- Now where's the summary line?
sub _show_results {
my($tot, $failedtests) = @_;
my $pct;
my $bonusmsg = _bonusmsg($tot);
if (_all_ok($tot)) {
print "All tests successful$bonusmsg.\n"; # <--- here
}
elsif (!$tot->{tests}){
die "FAILED--no tests were run for some reason.\n";
}
elsif (!$tot->{max}) {
my $blurb = $tot->{tests}==1 ? "script" : "scripts";
die "FAILED--$tot->{tests} test $blurb could be run, ".
"alas--no output ever seen\n";
}
else {
$pct = sprintf("%.2f", $tot->{good} / $tot->{tests} * 100);
my $percent_ok = 100*$tot->{ok}/$tot->{max};
my $subpct = sprintf " %d/%d subtests failed, %.2f%% okay.",
$tot->{max} - $tot->{ok}, $tot->{max},
$percent_ok;
my($fmt_top, $fmt) = _create_fmts($failedtests);
# Now write to formats
for my $script (sort keys %$failedtests) {
$Curtest = $failedtests->{$script};
write;
}
if ($tot->{bad}) {
$bonusmsg =~ s/^,\s*//;
print "$bonusmsg.\n" if $bonusmsg;
die "Failed $tot->{bad}/$tot->{tests} test scripts, $pct% okay.".
"$subpct\n";
}
}
printf("Files=%d, Tests=%d, %s\n",
$tot->{files}, $tot->{max}, timestr($tot->{bench}, 'nop'));
}
Problems
- A monolithic function with just one line to change.
- There isn't an object instance for easy inheritance and
over-riding.
- A lot of similar issues in the rest of the code.