r24669: Add CSS to the test run HTML output. See http://samba.org/~jelmer/ for an
authorJelmer Vernooij <jelmer@samba.org>
Sun, 26 Aug 2007 16:56:41 +0000 (16:56 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 20:02:35 +0000 (15:02 -0500)
example of the current output.

source/main.mk
source/selftest/output/html.pm
source/selftest/output/plain.pm
source/selftest/output/testresults.css [new file with mode: 0644]
source/selftest/selftest.pl

index f2412d33d5162e1eaeda40ce1e87252b9284e30e..613d76e0b94869a16a1745cb43bddc0804df5a6e 100644 (file)
@@ -307,6 +307,9 @@ test-noswrap: everything
 quicktest: all
        $(SELFTEST) --quick --socket-wrapper --immediate $(TESTS)
 
+htmlquicktest: all
+       $(SELFTEST) --quick --socket-wrapper --format=html --immediate $(TESTS)
+
 quicktestone: all
        $(SELFTEST) --quick --socket-wrapper --one $(TESTS)
 
index d18151600203faf470e3fe76227ae4618863bcf0..5a7ee15af207be3c9a55bfaa0adf904bf2b5fb68 100644 (file)
@@ -16,14 +16,27 @@ sub new($$$$) {
                msg => ""
        };
 
+       link("selftest/output/testresults.css", "$dirname/testresults.css");
+
        open(INDEX, ">$dirname/index.html");
 
-       print INDEX "<html>\n";
+       print INDEX "<html lang=\"en\">\n";
+       print INDEX "<head>\n";
+       print INDEX "  <title>Samba Testsuite Run</title>\n";
+       print INDEX "  <link rel=\"stylesheet\" type=\"text/css\" href=\"testresults.css\"/>\n";
+       print INDEX "</head>\n";
        print INDEX "<body>\n";
-       print INDEX "<table>\n";
-       print INDEX "<tr><td>Test</td><td>Environment</td><td>Result</td><td>Duration</td></tr>\n";
-
-       $self->{INDEX} = *INDEX;
+       print INDEX "<table width=\"100%\" border=\"0\" cellspacing=\"0\">\n";
+       print INDEX "  <tr><td class=\"title\">Samba Testsuite Run</td></tr>\n";
+       print INDEX "  <tr><td>\n";
+       print INDEX "  <center>";
+       print INDEX "  <table>\n";
+       print INDEX "  <tr>\n";
+       print INDEX "    <td class=\"tableHead\">Test</td>\n";
+       print INDEX "    <td class=\"tableHead\">Environment</td>\n";
+       print INDEX "    <td class=\"tableHead\">Result</td>\n";
+       print INDEX "    <td class=\"tableHead\">Duration</td>\n";
+       print INDEX "  </tr>\n";
 
        bless($self, $class);
 }
@@ -35,13 +48,22 @@ sub start_testsuite($$)
        my ($self, $state) = @_;
 
        $state->{HTMLFILE} = "$state->{NAME}.html";
+       $state->{HTMLFILE} =~ s/[:\t\n \/]/_/g;
 
-       $state->{HTMLFILE} =~ s/[:\t\n ]/_/g;
+       open(TEST, ">$self->{dirname}/$state->{HTMLFILE}") or die("Unable to open $state->{HTMLFILE} for writing");
 
-       open(TEST, ">$self->{dirname}/$state->{HTMLFILE}");
+       my $title = "Test Results for $state->{NAME}";
 
-       print TEST "<html>\n";
+       print TEST "<html lang=\"en\">\n";
+       print TEST "<head>\n";
+       print TEST "  <title>$title</title>\n";
+       print TEST "  <link rel=\"stylesheet\" type=\"text/css\" href=\"testresults.css\"/>\n";
+       print TEST "</head>\n";
        print TEST "<body>\n";
+       print TEST "<table width=\"100%\" border=\"0\" cellspacing=\"0\">\n";
+       print TEST "  <tr><td class=\"title\">$title</td></tr>\n";
+       print TEST "  <tr><td>\n";
+       print TEST "  <table>\n";
 }
 
 sub output_msg($$$)
@@ -59,20 +81,21 @@ sub end_testsuite($$$$$)
 {
        my ($self, $state, $expected_ret, $ret, $envlog) = @_;
 
+       print TEST "</table>\n";
        print TEST "</body>\n";
        print TEST "</html>\n";
 
        close(TEST);
 
-       print INDEX "<tr><td><a href=\"$state->{HTMLFILE}\">$state->{NAME}</a></td><td>$state->{ENVNAME}</td>";
+       print INDEX "<tr><td class=\"testSuite\"><a href=\"$state->{HTMLFILE}\">$state->{NAME}</a></td><td class=\"environment\">$state->{ENVNAME}</td>";
 
        if ($ret == $expected_ret) {
-               print INDEX "<td bgcolor=\"green\">OK</td>";
+               print INDEX "<td class=\"resultOk\">OK</td>";
        } else {
-               print INDEX "<td bgcolor=\"red\">FAIL</td>";
+               print INDEX "<td class=\"resultFailure\">FAIL</td>";
        }
 
-       print INDEX "<td>" . (time() - $state->{START_TIME}) . "</td>\n";
+       print INDEX "<td class=\"duration\">" . (time() - $state->{START_TIME}) . "</td>\n";
 
        print INDEX "</tr>\n";
 }
@@ -81,8 +104,6 @@ sub start_test($$$)
 {
        my ($self, $state, $testname) = @_;
 
-       print TEST "<h3>$testname</h3>\n";
-
        $self->{active_test} = $testname;
        $self->{msg} = "";
 }
@@ -91,15 +112,21 @@ sub end_test($$$$$)
 {
        my ($self, $state, $testname, $result, $unexpected) = @_;
 
+       print TEST "<tr>";
+
        if ($result eq "skip") {
-               print TEST "<div bgcolor=\"yellow\">\n";
+               print TEST "<td class=\"outputSkipped\">\n";
        } elsif ($unexpected) {
-               print TEST "<div bgcolor=\"red\">\n";
+               print TEST "<td class=\"outputFailure\">\n";
+       } else {
+               print TEST "<td class=\"outputOk\">\n";
        }
 
+       print TEST "<h3>$testname</h3>\n";
+
        print TEST $self->{msg};
 
-       print TEST "</div>\n";
+       print TEST "</td></tr>\n";
 
        $self->{active_test} = undef;
 }
@@ -107,12 +134,13 @@ sub end_test($$$$$)
 sub summary($)
 {
        my ($self) = @_;
-       print INDEX "</table>\n";
-       print INDEX "FAILED ($self->{statistics}->{TESTS_UNEXPECTED_FAIL} failures and $self->{statistics}->{TESTS_ERROR} errors in $self->{statistics}->{SUITES_FAIL} testsuites)\n";
 
+       print INDEX "</table>\n";
+       print INDEX "</center>\n";
+       print INDEX "</td></tr>\n";
+       print INDEX "</table>\n";
        print INDEX "</body>\n";
        print INDEX "</html>\n";
-
        close(INDEX);
 }
 
@@ -127,7 +155,7 @@ sub skip_testsuite($$)
 {
        my ($self, $name) = @_;
 
-       print INDEX "<tr><td>$name</td><td>N/A</td><td bgcolor=\"yellow\">SKIPPED</td><td>N/A</td></tr>\n";
+       print INDEX "<tr><td class=\"testSuite\">$name</td><td class=\"environmentSkipped\">N/A</td><td class=\"resultSkipped\">SKIPPED</td><td class=\"durationSkipped\">N/A</td></tr>\n";
 }
 
 1;
index d3ffe228a7fc0b1c2660390122cbf4f0d27176ee..2aa01145d004be20a0b70afb02f7cdcdd7d91a6a 100644 (file)
@@ -88,7 +88,13 @@ sub summary($)
                }
        }
 
-       print "FAILED ($self->{statistics}->{TESTS_UNEXPECTED_FAIL} failures and $self->{statistics}->{TESTS_ERROR} errors in $self->{statistics}->{SUITES_FAIL} testsuites)\n";
+       if ($self->{statistics}->{SUITES_FAIL} == 0) {
+               my $ok = $self->{statistics}->{TESTS_EXPECTED_OK} + 
+                                $self->{statistics}->{TESTS_EXPECTED_FAIL};
+               print "ALL OK ($ok tests in $self->{statistics}->{SUITES_OK} testsuites)\n";
+       } else {
+               print "FAILED ($self->{statistics}->{TESTS_UNEXPECTED_FAIL} failures and $self->{statistics}->{TESTS_ERROR} errors in $self->{statistics}->{SUITES_FAIL} testsuites)\n";
+       }
 }
 
 sub missing_env($$$)
diff --git a/source/selftest/output/testresults.css b/source/selftest/output/testresults.css
new file mode 100644 (file)
index 0000000..b37f881
--- /dev/null
@@ -0,0 +1,92 @@
+/* Stylesheet for Samba test results. 
+ *
+ * Partially based on the CSS file from lcov.
+ */
+
+/* All views: main title format */
+td.title
+{
+       text-align:     center;
+       padding-bottom: 10px;
+       font-family:    sans-serif;
+       font-size:      20pt;
+       font-style:     italic;
+       font-weight:    bold;
+}
+
+/* Index table headers */
+td.tableHead
+{
+       text-align:       center;
+       color:            #FFFFFF;
+       background-color: #6688D4;
+       font-family:      sans-serif;
+       font-size:        120%;
+       font-weight:      bold;
+}
+
+/* Testsuite names */
+td.testSuite
+{
+       text-align:       left;
+       padding-left:     10px;
+       padding-right:    20px; 
+       color:            #284FA8;
+       background-color: #DAE7FE;
+       font-family:      monospace;
+}
+
+/* Successful */
+td.resultOk
+{
+       text-align:       right;
+       padding-left:     10px;
+       padding-right:    10px;
+       background-color: #A7FC9D;
+       font-weight:      bold;
+}
+
+/* Failure */
+td.resultFailure
+{
+       text-align:       right;
+       padding-left:     10px;
+       padding-right:    10px;
+       background-color: #FF0000;
+       font-weight:      bold;
+}
+
+/* Skipped */
+td.resultSkipped
+{
+       text-align:       right;
+       padding-left:     10px;
+       padding-right:    10px;
+       background-color: #FFEA20;
+       font-weight:      bold;
+}
+
+td.duration
+{
+       text-align: right;
+}
+
+td.durationSkipped
+{
+       text-align: right;
+}
+
+td.outputSkipped
+{
+       background-color: #FFEA20;
+}
+
+td.outputOk
+{
+       background-color: #A7FC9D;
+}
+
+td.outputFailure
+{
+       background-color: #FF0000;
+}
index 1dbb494edbc6e845617607c0242e71502cc3ba42..a10baebcf48d327f802a93eb529f2ce84d3debfe 100755 (executable)
@@ -777,14 +777,7 @@ $target->stop();
 
 $statistics->{END_TIME} = time();
 my $duration = ($statistics->{END_TIME}-$statistics->{START_TIME});
-my $numfailed = $statistics->{SUITES_FAIL};
-if ($numfailed == 0) {
-       my $ok = $statistics->{TESTS_EXPECTED_OK} + 
-                $statistics->{TESTS_EXPECTED_FAIL};
-       print "ALL OK ($ok tests in $statistics->{SUITES_OK} testsuites)\n";
-} else {
-       $msg_ops->summary();
-}
+$msg_ops->summary();
 print "DURATION: $duration seconds\n";
 
 my $failed = 0;
@@ -801,7 +794,7 @@ foreach (<$prefix/valgrind.log*>) {
 }
 
 if ($opt_format eq "buildfarm") {
-       print "TEST STATUS: $numfailed\n";
+       print "TEST STATUS: $statistics->{SUITES_FAIL}\n";
 }
 
-exit $numfailed;
+exit $statistics->{SUITES_FAIL};