have the output parser generate a set of HTML files
authorJason Etheridge <jason@esilibrary.com>
Fri, 9 Aug 2013 21:58:00 +0000 (17:58 -0400)
committerJason Etheridge <jason@esilibrary.com>
Fri, 9 Aug 2013 21:58:00 +0000 (17:58 -0400)
Signed-off-by: Jason Etheridge <jason@esilibrary.com>
qa/test_output.css
qa/test_output_filter.pl [deleted file]
qa/test_output_filter_html.pl [deleted symlink]
qa/test_output_webifier.pl [new file with mode: 0755]

index c70a5be..60f92d9 100644 (file)
@@ -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 (executable)
index 98f8e4b..0000000
+++ /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 (symlink)
index a7c1b3f..0000000
+++ /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 (executable)
index 0000000..c3e35fa
--- /dev/null
@@ -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>';
+        }
+    }
+}
+