+++ /dev/null
-#!/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";
-}
--- /dev/null
+#!/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>';
+ }
+ }
+}
+