From: Jason Etheridge <jason@esilibrary.com>
Date: Fri, 9 Aug 2013 21:58:00 +0000 (-0400)
Subject: have the output parser generate a set of HTML files
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=db60a4c3b02ebdb2e0a666f164e2c46792c95716;p=working%2Frandom.git

have the output parser generate a set of HTML files

Signed-off-by: Jason Etheridge <jason@esilibrary.com>
---

diff --git a/qa/test_output.css b/qa/test_output.css
index c70a5bea8..60f92d997 100644
--- a/qa/test_output.css
+++ b/qa/test_output.css
@@ -1,4 +1,4 @@
-* { color: gray; }
+.output { color: gray; }
 .comment { color: black; }
 .ok { color: green; font-weight: bold; }
 .error { color: red; font-weight: bold; }
diff --git a/qa/test_output_filter.pl b/qa/test_output_filter.pl
deleted file mode 100755
index 98f8e4b85..000000000
--- a/qa/test_output_filter.pl
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/usr/bin/perl
-
-my $state = 'skipping';
-my $error_count = 0;
-
-if ($0 =~ /html/) {
-    print "<html><head><title>test output</title>";
-    print "<link rel='stylesheet' type='text/css' href='test_output.css'>";
-    print "</head><body><a href='#error'>Jump to first error</a><pre>\n";
-}
-
-while (my $line = <>) {
-    if ($line =~ /_\.-~=/) {
-        $state = 'outputting';
-    }
-    if ($state eq 'outputting') {
-        if ($0 =~ /html/) {
-            my $class = '';
-            if ($line =~ /^ok/
-                || $line =~ /\. ok/
-                || $line =~ /^PASS/
-                || $line =~ /\* OK/
-                || $line =~ /\* Jabber successfully connected/
-                || $line =~ /\* Database has the expected server encoding /
-            ) {
-                $class .= 'ok ';
-            }
-            $class .= 'error ' if ($line =~ /^err/i); 
-            if (($line =~ /^not ok/ && !($line =~ /TODO/))
-                || $line =~ /\. not ok/
-                || $line =~ /\* ERROR/
-                || $line =~ /\* WARNING/
-            ) {
-                $class .= 'notok ';
-                $error_count++;
-            }
-            if ($line =~ /^not ok/ && $line =~ /TODO/) {
-                $class .= 'todo ';
-            }
-            $class .= 'result ' if ($line =~ /^Result:/); 
-            $class .= 'pass ' if ($line =~ /^Result: PASS/); 
-            if ($line =~ /^Result: FAIL/) {
-                $class .= 'fail ';
-                $error_count++;
-            }
-            if ($line =~ /^#/
-                || $line =~ /Checks:/
-                || $line =~ /_\.-~=/
-                || $line =~ /=~-\._/
-                || $line =~ / tests /
-                || $line =~ /Failed /
-                || $line =~ /Passed /
-                || $line =~ /Files=/
-            ) {
-                $class .= 'comment ';
-            }
-            chomp $line;
-            my $html_line = "<span class='$class'>$line</span>";
-            if ($error_count == 1) {
-                print "<a name='error'>$html_line</a>\n";
-            } else {
-                print "$html_line\n";
-            }
-        } else {
-            print $line;
-        }
-    }
-    if ($line =~ /=~-\._/) {
-        $state = 'skipping';
-    }
-}
-
-if ($0 =~ /html/) {
-    print "</pre></body></html>\n";
-}
diff --git a/qa/test_output_filter_html.pl b/qa/test_output_filter_html.pl
deleted file mode 120000
index a7c1b3fb5..000000000
--- a/qa/test_output_filter_html.pl
+++ /dev/null
@@ -1 +0,0 @@
-test_output_filter.pl
\ No newline at end of file
diff --git a/qa/test_output_webifier.pl b/qa/test_output_webifier.pl
new file mode 100755
index 000000000..c3e35fac9
--- /dev/null
+++ b/qa/test_output_webifier.pl
@@ -0,0 +1,106 @@
+#!/usr/bin/perl
+
+my $state = 'skipping';
+my $error_count = 0;
+my $subpage_count = 0;
+
+open  MAIN_PAGE, ">test.html";
+print MAIN_PAGE html_header('Test Output Summary');
+print MAIN_PAGE qq^<a href="$ARGV[0]">Raw Output</a>\n^;
+print MAIN_PAGE "<h1>Test Output Summary</h1>\n";
+print MAIN_PAGE 'HTML generated on ' . `date` . "\n";
+print MAIN_PAGE "<ul>\n";
+
+while (my $line = <>) {
+    if ($line =~ /_\.-~= (.*)$/) {
+        $state = 'outputting';
+        print_pass_or_fail();
+        $error_count = 0;
+        $subpage_count++;
+        print MAIN_PAGE qq^\n<li><a href="test.$subpage_count.html">$1</a>^;
+        open  SUB_PAGE, ">test.$subpage_count.html";
+        print SUB_PAGE html_header($1);
+        print SUB_PAGE "<h1>$1</h1>\n<pre>";
+    }
+    if ($state eq 'outputting') {
+        my $class = 'output ';
+        if ($line =~ /^ok/
+            || $line =~ /\. ok/
+            || $line =~ /^PASS/
+            || $line =~ /\* OK/
+            || $line =~ /\* Jabber successfully connected/
+            || $line =~ /\* Database has the expected server encoding /
+        ) {
+            $class .= 'ok ';
+        }
+        $class .= 'error ' if ($line =~ /^err/i); 
+        if (($line =~ /^not ok/ && !($line =~ /TODO/))
+            || $line =~ /\. not ok/
+            || $line =~ /\* ERROR/
+            || $line =~ /\* WARNING/
+        ) {
+            $class .= 'notok ';
+            $error_count++;
+        }
+        if ($line =~ /^not ok/ && $line =~ /TODO/) {
+            $class .= 'todo ';
+        }
+        $class .= 'result ' if ($line =~ /^Result:/); 
+        $class .= 'pass ' if ($line =~ /^Result: PASS/); 
+        if ($line =~ /^Result: FAIL/) {
+            $class .= 'fail ';
+            $error_count++;
+        }
+        if ($line =~ /^#/
+            || $line =~ /Checks:/
+            || $line =~ /_\.-~=/
+            || $line =~ /=~-\._/
+            || $line =~ / tests /
+            || $line =~ /Failed /
+            || $line =~ /Passed /
+            || $line =~ /Files=/
+        ) {
+            $class .= 'comment ';
+        }
+        chomp $line;
+        my $html_line = "<span class='$class'>$line</span>";
+        print SUB_PAGE "$html_line\n";
+    }
+    if ($line =~ /=~-\._/) {
+        print SUB_PAGE "</pre>\n" . html_footer();
+        close SUB_PAGE;
+        $state = 'skipping';
+    }
+}
+print_pass_or_fail();
+print MAIN_PAGE html_footer();
+close MAIN_PAGE;
+
+sub html_header {
+    my $title = shift;
+    return qq^
+<html>
+    <head>
+        <title>$title</title>
+        <link rel="stylesheet" type="text/css" href="test_output.css">
+    </head>
+    <body>
+    ^;
+}
+
+sub html_footer {
+    return q^
+    </body>
+</html>^;
+}
+
+sub print_pass_or_fail {
+    if ($error_count) {
+        print MAIN_PAGE ' - <span class="fail">Failed</span>';
+    } else {
+        if ($subpage_count) {
+            print MAIN_PAGE ' - <span class="pass">Passed</span>';
+        }
+    }
+}
+