From 04e8c10f9e1dcd9edf94ae071a51f5e93ecc2a2e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 26 Aug 2007 19:07:46 +0000 Subject: r24671: More improvements to the HTML test suite results: hide control messages, improve summary, stylesheet. (This used to be commit fcc2320417707ec803d706a923a231fbd1bb72a7) --- source4/selftest/output/buildfarm.pm | 11 +++- source4/selftest/output/html.pm | 103 +++++++++++++++++++++++++++++--- source4/selftest/output/plain.pm | 11 +++- source4/selftest/output/testresults.css | 19 +++++- source4/selftest/selftest.pl | 36 +++++++---- 5 files changed, 156 insertions(+), 24 deletions(-) diff --git a/source4/selftest/output/buildfarm.pm b/source4/selftest/output/buildfarm.pm index a605f1736c..7d6c3a987a 100644 --- a/source4/selftest/output/buildfarm.pm +++ b/source4/selftest/output/buildfarm.pm @@ -41,6 +41,13 @@ sub output_msg($$$) $self->{test_output}->{$state->{NAME}} .= $output; } +sub control_msg($$$) +{ + my ($self, $state, $output) = @_; + + $self->{test_output}->{$state->{NAME}} .= $output; +} + sub end_testsuite($$$$$) { my ($self, $state, $expected_ret, $ret, $envlog) = @_; @@ -75,9 +82,9 @@ sub start_test($$$) my ($self, $state, $testname) = @_; } -sub end_test($$$$$) +sub end_test($$$$$$) { - my ($self, $state, $testname, $result, $expected) = @_; + my ($self, $state, $testname, $result, $expected, $reason) = @_; } sub summary($) diff --git a/source4/selftest/output/html.pm b/source4/selftest/output/html.pm index 5a7ee15af2..afbe63177a 100644 --- a/source4/selftest/output/html.pm +++ b/source4/selftest/output/html.pm @@ -13,6 +13,7 @@ sub new($$$$) { dirname => $dirname, statistics => $statistics, active_test => undef, + local_statistics => {}, msg => "" }; @@ -35,7 +36,6 @@ sub new($$$$) { print INDEX " Test\n"; print INDEX " Environment\n"; print INDEX " Result\n"; - print INDEX " Duration\n"; print INDEX " \n"; bless($self, $class); @@ -47,6 +47,13 @@ sub start_testsuite($$) { my ($self, $state) = @_; + $self->{local_statistics} = { + success => 0, + skip => 0, + error => 0, + failure => 0 + }; + $state->{HTMLFILE} = "$state->{NAME}.html"; $state->{HTMLFILE} =~ s/[:\t\n \/]/_/g; @@ -66,6 +73,13 @@ sub start_testsuite($$) print TEST " \n"; } +sub control_msg($$$) +{ + my ($self, $state, $output) = @_; + + $self->{msg} .= "$output
\n"; +} + sub output_msg($$$) { my ($self, $state, $output) = @_; @@ -82,21 +96,55 @@ sub end_testsuite($$$$$) my ($self, $state, $expected_ret, $ret, $envlog) = @_; print TEST "
\n"; + + print TEST "
Duration: " . (time() - $state->{START_TIME}) . "s
\n"; print TEST "\n"; print TEST "\n"; close(TEST); - print INDEX "{HTMLFILE}\">$state->{NAME}$state->{ENVNAME}"; + print INDEX "\n"; + print INDEX " {HTMLFILE}\">$state->{NAME}\n"; + print INDEX " $state->{ENVNAME}\n"; + my $st = $self->{local_statistics}; if ($ret == $expected_ret) { - print INDEX "OK"; + print INDEX " "; } else { - print INDEX "FAIL"; + print INDEX " "; } - print INDEX "" . (time() - $state->{START_TIME}) . "\n"; + my $l = 0; + if ($st->{success} > 0) { + print INDEX "$st->{success} ok"; + $l++; + } + if ($st->{skip} > 0) { + print INDEX ", " if ($l); + print INDEX "$st->{skip} skipped"; + $l++; + } + if ($st->{failure} > 0) { + print INDEX ", " if ($l); + print INDEX "$st->{failure} failures"; + $l++; + } + if ($st->{error} > 0) { + print INDEX ", " if ($l); + print INDEX "$st->{error} errors"; + $l++; + } + if ($l == 0) { + if ($ret == $expected_ret) { + print INDEX "OK"; + } else { + print INDEX "FAIL"; + } + } + + print INDEX ""; + print INDEX "\n"; } @@ -108,12 +156,14 @@ sub start_test($$$) $self->{msg} = ""; } -sub end_test($$$$$) +sub end_test($$$$$$) { - my ($self, $state, $testname, $result, $unexpected) = @_; + my ($self, $state, $testname, $result, $unexpected, $reason) = @_; print TEST ""; + $self->{local_statistics}->{$result}++; + if ($result eq "skip") { print TEST "\n"; } elsif ($unexpected) { @@ -126,6 +176,10 @@ sub end_test($$$$$) print TEST $self->{msg}; + if (defined($reason)) { + print TEST "
$reason
\n"; + } + print TEST "\n"; $self->{active_test} = undef; @@ -135,6 +189,36 @@ sub summary($) { my ($self) = @_; + my $st = $self->{statistics}; + print INDEX "\n"; + print INDEX " Total\n"; + print INDEX " \n"; + + if ($st->{SUITES_FAIL} == 0) { + print INDEX " "; + } else { + print INDEX " "; + } + print INDEX "$st->{TESTS_EXPECTED_OK} ok"; + if ($st->{TESTS_UNEXPECTED_OK} > 0) { + print INDEX " ($st->{TESTS_UNEXPECTED_OK})"; + } + print INDEX ""; + if ($st->{TESTS_SKIP} > 0) { + print INDEX ", $st->{TESTS_SKIP} skipped"; + } + print INDEX ", $st->{TESTS_EXPECTED_FAIL} failures"; + if ($st->{TESTS_UNEXPECTED_OK} > 0) { + print INDEX " ($st->{TESTS_UNEXPECTED_FAIL})"; + } + if ($st->{TESTS_ERROR} > 0) { + print INDEX ", $st->{TESTS_ERROR} errors"; + } + + print INDEX ""; + + print INDEX "\n"; + print INDEX "\n"; print INDEX "\n"; print INDEX "\n"; @@ -155,7 +239,10 @@ sub skip_testsuite($$) { my ($self, $name) = @_; - print INDEX "$nameN/ASKIPPEDN/A\n"; + print INDEX "\n"; + print INDEX " $name\n"; + print INDEX " SKIPPED\n"; + print INDEX "\n"; } 1; diff --git a/source4/selftest/output/plain.pm b/source4/selftest/output/plain.pm index 2aa01145d0..10d6eee215 100644 --- a/source4/selftest/output/plain.pm +++ b/source4/selftest/output/plain.pm @@ -49,6 +49,13 @@ sub output_msg($$$) } } +sub control_msg($$$) +{ + my ($self, $state, $output) = @_; + + $self->output_msg($state, $output); +} + sub end_testsuite($$$$$) { my ($self, $state, $expected_ret, $ret, $envlog) = @_; @@ -70,9 +77,9 @@ sub start_test($$) my ($state, $testname) = @_; } -sub end_test($$$$) +sub end_test($$$$$) { - my ($state, $testname, $result, $unexpected) = @_; + my ($state, $testname, $result, $unexpected, $reason) = @_; } sub summary($) diff --git a/source4/selftest/output/testresults.css b/source4/selftest/output/testresults.css index b37f881f20..9f3b6c9e82 100644 --- a/source4/selftest/output/testresults.css +++ b/source4/selftest/output/testresults.css @@ -59,7 +59,7 @@ td.resultFailure /* Skipped */ td.resultSkipped { - text-align: right; + text-align: center; padding-left: 10px; padding-right: 10px; background-color: #FFEA20; @@ -90,3 +90,20 @@ td.outputFailure { background-color: #FF0000; } + +div.reason +{ + text-align: center; + font-weight: bold; +} + +span.control +{ + display: none; +} + +div.duration +{ + text-align: right; + font-weight: bold; +} diff --git a/source4/selftest/selftest.pl b/source4/selftest/selftest.pl index a10baebcf4..b0b53a16f1 100755 --- a/source4/selftest/selftest.pl +++ b/source4/selftest/selftest.pl @@ -156,7 +156,8 @@ my $statistics = { TESTS_EXPECTED_OK => 0, TESTS_UNEXPECTED_FAIL => 0, TESTS_EXPECTED_FAIL => 0, - TESTS_ERROR => 0 + TESTS_ERROR => 0, + TESTS_SKIP => 0, }; sub expecting_failure($) @@ -218,45 +219,58 @@ sub parse_subunit_results($$$$) my $open_tests = {}; while(<$fh>) { - $msg_ops->output_msg($msg_state, $_); if (/^test: (.+)\n/) { + $msg_ops->control_msg($msg_state, $_); $open_tests->{$1} = 1; $msg_ops->start_test($msg_state, $1); - } elsif (/^(success|failure|skip|error): (.*?)( \[)?\n/) { + } elsif (/^(success|failure|skip|error): (.*?)( \[)?([ \t]*)\n/) { + $msg_ops->control_msg($msg_state, $_); + my $reason = undef; + if ($3) { + $reason = ""; + # reason may be specified in next lines + while(<$fh>) { + $msg_ops->control_msg($msg_state, $_); + if ($_ eq "]\n") { last; } else { $reason .= $_; } + } + } my $result = $1; if ($1 eq "success") { delete $open_tests->{$2}; if (expecting_failure("$msg_state->{NAME}/$2")) { $statistics->{TESTS_UNEXPECTED_OK}++; - $msg_ops->end_test($msg_state, $2, $1, 1); + $msg_ops->end_test($msg_state, $2, $1, 1, $reason); } else { $statistics->{TESTS_EXPECTED_OK}++; - $msg_ops->end_test($msg_state, $2, $1, 0); + $msg_ops->end_test($msg_state, $2, $1, 0, $reason); } } elsif ($1 eq "failure") { delete $open_tests->{$2}; if (expecting_failure("$msg_state->{NAME}/$2")) { $statistics->{TESTS_EXPECTED_FAIL}++; - $msg_ops->end_test($msg_state, $2, $1, 0); + $msg_ops->end_test($msg_state, $2, $1, 0, $reason); $expected_ret = 0; } else { $statistics->{TESTS_UNEXPECTED_FAIL}++; - $msg_ops->end_test($msg_state, $2, $1, 1); + $msg_ops->end_test($msg_state, $2, $1, 1, $reason); } } elsif ($1 eq "skip") { + $statistics->{TESTS_SKIP}++; delete $open_tests->{$2}; - $msg_ops->end_test($msg_state, $2, $1, 0); + $msg_ops->end_test($msg_state, $2, $1, 0, $reason); } elsif ($1 eq "error") { $statistics->{TESTS_ERROR}++; delete $open_tests->{$2}; - $msg_ops->end_test($msg_state, $2, $1, 1); + $msg_ops->end_test($msg_state, $2, $1, 1, $reason); } + } else { + $msg_ops->output_msg($msg_state, $_); } } foreach (keys %$open_tests) { - $msg_ops->end_test($msg_state, $_, "error", 1); - $msg_ops->output_msg($msg_state, "$_ was started but never finished!"); + $msg_ops->end_test($msg_state, $_, "error", 1, + "was started but never finished!"); $statistics->{TESTS_ERROR}++; } -- cgit