some debugging and cosmetics
authorJason Etheridge <jason@equinoxinitiative.org>
Mon, 28 Jan 2019 08:26:31 +0000 (03:26 -0500)
committerJason Etheridge <jason@equinoxinitiative.org>
Mon, 28 Jan 2019 08:26:31 +0000 (03:26 -0500)
qa/test_output_webifier.pl

index 8e6a70e..9891fd3 100755 (executable)
@@ -3,10 +3,13 @@
 # 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;
@@ -14,6 +17,7 @@ my $subpage = '';
 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');
@@ -21,8 +25,10 @@ print MAIN_PAGE qq^[<a href="cronoutput.txt">test.sh output</a>]\n^;
 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";
@@ -38,6 +44,7 @@ sub open_subpage {
         $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);
@@ -50,6 +57,7 @@ sub close_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;
@@ -58,6 +66,7 @@ sub close_subpage {
 
 while (my $line = <>) {
     push @all_lines, $line;
+    print DEBUG "$state -- $line";
     if ($line =~ /Tip of OpenSRF: (.*)/) {
         $opensrf_tip = $1;
     }
@@ -107,6 +116,7 @@ while (my $line = <>) {
         ) {
             $class .= 'notok ';
             $error_count++;
+            print DEBUG "error counted, $error_count\n";
         }
         if ($line =~ /^not ok/ && $line =~ /TODO/) {
             $class .= 'todo ';
@@ -116,12 +126,14 @@ while (my $line = <>) {
         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 =~ /^#/
@@ -148,6 +160,7 @@ while (my $line = <>) {
         print SUB_PAGE "</pre>\n" . html_footer();
         close SUB_PAGE;
         $state = 'skipping';
+        print DEBUG "state = $state\n";
     }
 }
 close_subpage();
@@ -163,6 +176,8 @@ print MAIN_PAGE html_footer();
 close MAIN_PAGE;
 close PASS_FAIL;
 update_rss();
+sed_main_page();
+close DEBUG;
 
 sub html_header {
     my $title = shift;
@@ -207,7 +222,12 @@ sub print_pass_or_fail {
     }
     #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.";
@@ -217,7 +237,7 @@ sub print_pass_or_fail {
     } 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";
         }
     }
 }
@@ -300,3 +320,13 @@ sub update_rss {
     #}
     `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`;
+    }
+}