7 use Test
::Harness
qw( execute_tests );
10 $OUTPUT_AUTOFLUSH = 1;
12 $Test::Harness
::Timer
= 1;
13 $Test::Harness
::switches
= '-MDevel::Cover=-silent,1';
14 $Test::Harness
::Verbose
= 1;
17 $ENV{RUN_ALL_TESTS
} = 1;
19 # delete the coverage database
22 my @test_files = glob("t/*/*.t");
23 push @test_files, glob("t/*.t");
25 my $revision = $ARGV[0];
26 $revision = sprintf("%04d", $revision);
29 # redirect test output to file
30 open STDOUT
, '>', "$revision" . '_output.txt';
31 open STDERR
, '>&STDOUT';
33 # execute tests and record the time it takes
34 my $t0 = Benchmark
->new();
35 my ($total, $failed) = execute_tests
(
36 tests
=> \
@test_files,
38 my $t1 = Benchmark
->new();
40 open my $SUMMARY, '>', $revision . "_summary.html";
42 my $color = '#ff9999'; # default color is red
43 if ($total->{bad
} == 0 && $total->{max
} > 0) {
44 # everything went well, change color to green
48 # calculate percentages
49 my $percentage_good_files = '0%';
50 my $percentage_bad_files = '0%';
52 if ($total->{files
} > 0) {
53 $percentage_good_files = sprintf("%2.2f%%", 100 * ($total->{good
} / $total->{files
}));
54 $percentage_bad_files = sprintf("%2.2f%%", 100 * ($total->{bad
} / $total->{files
}));
56 my $bad_tests = $total->{max
} - $total->{ok
};
58 my $percentage_good_tests = '0%';
59 my $percentage_bad_tests = '0%';
60 if ($total->{max
} > 0) {
61 $percentage_good_tests = sprintf("%2.2f%%", 100 * ($total->{ok
} / $total->{max
}));
62 $percentage_bad_tests = sprintf("%2.2f%%", 100 * ($bad_tests / $total->{max
}));
65 my $cpu_time = timestr
(timediff
($t1, $t0));
66 $cpu_time =~ s{.*(\d+\.\d+)\ CPU.*}{$1}xms;
68 my $revision_coverage_link = "<a href=\"$path/$revision" . '_coverage/coverage.html' . "\">Coverage report</a>";
70 my $output_bad_link = "<a href=\"$path/$revision" . '_output.txt' . "\">$total->{bad} ($percentage_bad_files)</a>";
71 my $output_good_link = "<a href=\"$path/$revision" . '_output.txt' . "\">$total->{good} ($percentage_good_files)</a>";
73 print $SUMMARY "<tr bgcolor=\"$color\"><td>$revision_coverage_link</td><td>$output_good_link</td><td>$output_bad_link</td><td>$total->{files} / $total->{tests}</td><td>$total->{skipped}</td><td>$total->{ok} ($percentage_good_tests)</td><td>$bad_tests ($percentage_bad_tests)</td><td>$total->{max}</td><td>$total->{todo}</td><td>$total->{bonus}</td><td>$total->{sub_skipped}</td><td>$cpu_time</td></tr>\n";
77 # generate coverage report
78 my $cover_cmd = "cover -silent -output $revision" . '_coverage';