# This script assumes git checkouts at ~/git/Evergreen and ~/git/OpenSRF that
# correspond to branches used to produce the test output being parsed.
+open DEBUG, ">debug.log";
+
use CGI qw(:standard escapeHTML);
my $q = CGI->new;
my $state = 'skipping';
+print DEBUG "state = $state\n";
my $error_count = 0;
my $subpage_return_value;
my $subpage_count = 0;
my $opensrf_tip = '';
my $evergreen_tip = '';
my @all_lines = ();
+my $first_failure = 0;
open MAIN_PAGE, ">test.html";
print MAIN_PAGE html_header('Test Output Summary');
print MAIN_PAGE qq^[<a href="$ARGV[0]">installer_installer.sh output</a>]\n^;
print MAIN_PAGE qq^[<a href="archive/">Previous Runs</a>]\n^;
print MAIN_PAGE qq^[<a href="http://git.evergreen-ils.org/?p=working/random.git;a=shortlog;h=refs/heads/collab/phasefx/eg_live_tests">Git</a>]\n^;
+print MAIN_PAGE qq^[<a href="#first_failure">First Failure</a>]\n^;
print MAIN_PAGE "<h1>Test Output Summary</h1>\n";
-print MAIN_PAGE 'HTML generated on ' . `date` . "\n";
+print MAIN_PAGE '<p>HTML generated on ' . `date` . "</p>\n";
+print MAIN_PAGE "<p>XXxxXX</p>\n";
print MAIN_PAGE "<ul>\n";
open PASS_FAIL, ">pass_fail.txt";
$subpage_count++;
$subpage_open = 1;
$state = 'outputting';
+ print DEBUG "state = $state\n";
print MAIN_PAGE qq^\n<li><a href="test.$subpage_count.html">$subpage</a>^;
open SUB_PAGE, ">test.$subpage_count.html";
print SUB_PAGE html_header($subpage);
if ($subpage_open) {
$subpage_open = 0;
$state = 'skipping';
+ print DEBUG "state = $state\n";
print STDOUT "outputting $prev_subpage with error_count = $error_count\n";
print_pass_or_fail($subpage,$subpage_count,$error_count,$subpage_return_value);
$error_count = 0;
while (my $line = <>) {
push @all_lines, $line;
+ print DEBUG "$state -- $line";
if ($line =~ /Tip of OpenSRF: (.*)/) {
$opensrf_tip = $1;
}
) {
$class .= 'notok ';
$error_count++;
+ print DEBUG "error counted, $error_count\n";
}
if ($line =~ /^not ok/ && $line =~ /TODO/) {
$class .= 'todo ';
if ($line =~ /^Result: FAIL/) {
$class .= 'fail ';
$error_count++;
+ print DEBUG "error counted, $error_count\n";
}
if ($line =~ /^Return Value = (.+)$/) {
$subpage_return_value = $1;
if ($1 ne '0') {
$class .= 'fail ';
$error_count++;
+ print DEBUG "error counted, $error_count\n";
}
}
if ($line =~ /^#/
print SUB_PAGE "</pre>\n" . html_footer();
close SUB_PAGE;
$state = 'skipping';
+ print DEBUG "state = $state\n";
}
}
close_subpage();
close MAIN_PAGE;
close PASS_FAIL;
update_rss();
+sed_main_page();
+close DEBUG;
sub html_header {
my $title = shift;
}
#print "subpage = <$p_subpage> error_count = $p_error_count\n";
if ($p_error_count && $p_error_count != $exception{$p_subpage} ) {
- print MAIN_PAGE ' - <span class="fail">Failed</span>';
+ if (!$first_failure) {
+ $first_failure = 1;
+ print MAIN_PAGE ' - <span class="fail"><a name="first_failure">Failed</a></span>';
+ } else {
+ print MAIN_PAGE ' - <span class="fail">Failed</span>';
+ }
print PASS_FAIL "$p_subpage_count $p_error_count Failed $p_subpage";
if ($exception{$p_subpage} > 0) {
print MAIN_PAGE " - Expected $exception{$p_subpage} errors but encountered $p_error_count.";
} else {
if ($p_subpage_count) {
print MAIN_PAGE ' - <span class="pass">Passed</span>';
- print PASS_FAIL "Passed\n";
+ print PASS_FAIL "$p_subpage_count $p_error_count Passed $p_subpage\n";
}
}
}
#}
`mv pass_fail.txt pass_fail.txt.prev`;
}
+
+sub sed_main_page {
+ my $fail = `grep Failed pass_fail.txt.prev`;
+ my $fail_count = `grep Failed pass_fail.txt.prev | wc -l`; chomp $fail_count;
+ if (!$fail) {
+ `sed -i "s/XXxxXX/All Tests Passed/" test.html`;
+ } else {
+ `sed -i "s/XXxxXX/$fail_count Tests Failed/" test.html`;
+ }
+}