reduce use of globals and pass more data to the rss generator
authorJason Etheridge <jason@equinoxinitiative.org>
Thu, 13 Dec 2018 07:18:33 +0000 (02:18 -0500)
committerJason Etheridge <jason@equinoxinitiative.org>
Thu, 13 Dec 2018 07:18:33 +0000 (02:18 -0500)
Signed-off-by: Jason Etheridge <jason@equinoxinitiative.org>
qa/test_output_webifier.pl

index 0949eed..f0416f0 100755 (executable)
@@ -37,11 +37,12 @@ while (my $line = <>) {
     }
     if ($line =~ /_\.-~= (.*)$/) {
         $prev_subpage = $subpage;
-        $subpage = $1;
+        $prev_subpage_count = $subpage_count;
         $state = 'outputting';
         print STDOUT "outputting $prev_subpage with error_count = $error_count\n";
-        print_pass_or_fail($prev_subpage);
+        print_pass_or_fail($prev_subpage,$prev_subpage_count,$error_count,$subpage_return_value);
         $error_count = 0;
+        $subpage = $1;
         $subpage_count++;
         print MAIN_PAGE qq^\n<li><a href="test.$subpage_count.html">$subpage</a>^;
         open  SUB_PAGE, ">test.$subpage_count.html";
@@ -149,31 +150,34 @@ sub html_footer {
 }
 
 sub print_pass_or_fail {
-    my $subpage = shift;
+    my $p_subpage = shift;
+    my $p_subpage_count = shift;
+    my $p_error_count = shift;
+    my $p_subpage_return_value = shift;
     my $exception = {}; # keyed on subpage, value = # of expected errors
     $exception{'Log Output: osrfsys.log'} = 3; # open-ils.cstore ERROR from live_t/08-lp1366964-libdbi-error.t (and related)
     $exception{'Running Evergreen browser client build/test'} = 6; # Cannot connect to offline DB: Error: http://google.github.io/lovefield/error_lookup/src/error_lookup.html
-    if (! defined $exception{$subpage}) {
-        $exception{$subpage} = 0;
+    if (! defined $exception{$p_subpage}) {
+        $exception{$p_subpage} = 0;
     }
     # just consider the final Return Value for the following subpages:
-    if ($subpage eq 'Installing Evergreen pre-requisites') {
-        $error_count = 0;
-        if ($subpage_return_value ne '0') {
-            $error_count = 1;
+    if ($p_subpage eq 'Installing Evergreen pre-requisites') {
+        $p_error_count = 0;
+        if ($p_subpage_return_value ne '0') {
+            $p_error_count = 1;
         }
     }
-    #print "subpage = <$subpage> error_count = $error_count\n";
-    if ($error_count && $error_count != $exception{$subpage} ) {
+    #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>';
-        print PASS_FAIL "Failed $subpage";
-        if ($exception{$subpage} > 0) {
-            print MAIN_PAGE " - Expected $exception{$subpage} errors but encountered $error_count.";
-            print PASS_FAIL " - Expected $exception{$subpage} errors but encountered $error_count.";
+        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.";
+            print PASS_FAIL " - Expected $exception{$p_subpage} errors but encountered $p_error_count.";
         }
        print PASS_FAIL "\n";
     } else {
-        if ($subpage_count) {
+        if ($p_subpage_count) {
             print MAIN_PAGE ' - <span class="pass">Passed</span>';
             print PASS_FAIL "Passed\n";
         }
@@ -238,13 +242,18 @@ sub update_rss {
        }
        my $fidx = 0;
        foreach my $f (split /\n/, $fail) {
+                if ($f =~ /^(\d+) (\d+) (.+)$/) {
+                    $f_subpage_count = $1;
+                    $f_error_count = $2;
+                    $f_details = $3;
+                }
                print RSS_FILE q^
      <entry>
-       <title>^ . $f . q^</title>
-       <link href="http://testing.evergreen-ils.org/~live#^ . `date -Ins` . '-' . ($fidx++) . q^"/>
-       <id>http://testing.evergreen-ils.org/~live#^ . `date -Ins` . '-' . ($fidx++) . q^</id>
+       <title>^ . $f_details . q^</title>
+       <link href="http://testing.evergreen-ils.org/~live/test.^ . $f_subpage_count . q^.html#^ . `date -Ins` . '-' . ($fidx++) . q^"/>
+       <id>http://testing.evergreen-ils.org/~live/test.^ . $f_subpage_count . q^.html#^ . `date -Ins` . '-' . ($fidx++) . q^</id>
        <updated>^ . `date -Iseconds` . q^</updated>
-       <summary>^ . $f . q^</summary>
+       <summary>^ . $f_details . q^</summary>
      </entry>
                ^;
        }