svn commit: samba r24671 - in branches/SAMBA_4_0: . source/selftest source/selftest/output

jelmer at samba.org jelmer at samba.org
Sun Aug 26 19:07:47 GMT 2007


Author: jelmer
Date: 2007-08-26 19:07:46 +0000 (Sun, 26 Aug 2007)
New Revision: 24671

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24671

Log:
More improvements to the HTML test suite results: hide 
control messages, improve summary, stylesheet.

Modified:
   branches/SAMBA_4_0/
   branches/SAMBA_4_0/source/selftest/output/buildfarm.pm
   branches/SAMBA_4_0/source/selftest/output/html.pm
   branches/SAMBA_4_0/source/selftest/output/plain.pm
   branches/SAMBA_4_0/source/selftest/output/testresults.css
   branches/SAMBA_4_0/source/selftest/selftest.pl


Changeset:

Property changes on: branches/SAMBA_4_0
___________________________________________________________________
Name: bzr:revision-info
...skipped...
Name: bzr:revision-id:v3-trunk0
...skipped...

Modified: branches/SAMBA_4_0/source/selftest/output/buildfarm.pm
===================================================================
--- branches/SAMBA_4_0/source/selftest/output/buildfarm.pm	2007-08-26 18:24:12 UTC (rev 24670)
+++ branches/SAMBA_4_0/source/selftest/output/buildfarm.pm	2007-08-26 19:07:46 UTC (rev 24671)
@@ -41,6 +41,13 @@
 	$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 @@
 	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($)

Modified: branches/SAMBA_4_0/source/selftest/output/html.pm
===================================================================
--- branches/SAMBA_4_0/source/selftest/output/html.pm	2007-08-26 18:24:12 UTC (rev 24670)
+++ branches/SAMBA_4_0/source/selftest/output/html.pm	2007-08-26 19:07:46 UTC (rev 24671)
@@ -13,6 +13,7 @@
 		dirname => $dirname,
 		statistics => $statistics,
 		active_test => undef,
+		local_statistics => {},
 		msg => ""
 	};
 
@@ -35,7 +36,6 @@
 	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);
@@ -47,6 +47,13 @@
 {
 	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 @@
 	print TEST "  <table>\n";
 }
 
+sub control_msg($$$)
+{
+	my ($self, $state, $output) = @_;
+
+	$self->{msg} .=  "<span class=\"control\">$output<br/></span>\n";
+}
+
 sub output_msg($$$)
 {
 	my ($self, $state, $output) = @_;
@@ -82,21 +96,55 @@
 	my ($self, $state, $expected_ret, $ret, $envlog) = @_;
 
 	print TEST "</table>\n";
+
+	print TEST "<div class=\"duration\">Duration: " . (time() - $state->{START_TIME}) . "s</div>\n";
 	print TEST "</body>\n";
 	print TEST "</html>\n";
 
 	close(TEST);
 
-	print INDEX "<tr><td class=\"testSuite\"><a href=\"$state->{HTMLFILE}\">$state->{NAME}</a></td><td class=\"environment\">$state->{ENVNAME}</td>";
+	print INDEX "<tr>\n";
+	print INDEX "  <td class=\"testSuite\"><a href=\"$state->{HTMLFILE}\">$state->{NAME}</a></td>\n";
+	print INDEX "  <td class=\"environment\">$state->{ENVNAME}</td>\n";
+	my $st = $self->{local_statistics};
 
 	if ($ret == $expected_ret) {
-		print INDEX "<td class=\"resultOk\">OK</td>";
+		print INDEX "  <td class=\"resultOk\">";
 	} else {
-		print INDEX "<td class=\"resultFailure\">FAIL</td>";
+		print INDEX "  <td class=\"resultFailure\">";
 	}
 
-	print INDEX "<td class=\"duration\">" . (time() - $state->{START_TIME}) . "</td>\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 "</td>";
+		
 	print INDEX "</tr>\n";
 }
 
@@ -108,12 +156,14 @@
 	$self->{msg} = "";
 }
 
-sub end_test($$$$$)
+sub end_test($$$$$$)
 {
-	my ($self, $state, $testname, $result, $unexpected) = @_;
+	my ($self, $state, $testname, $result, $unexpected, $reason) = @_;
 
 	print TEST "<tr>";
 
+	$self->{local_statistics}->{$result}++;
+
 	if ($result eq "skip") {
 		print TEST "<td class=\"outputSkipped\">\n";
 	} elsif ($unexpected) {
@@ -126,6 +176,10 @@
 
 	print TEST $self->{msg};
 
+	if (defined($reason)) {
+		print TEST "<div class=\"reason\">$reason</div>\n";
+	}
+
 	print TEST "</td></tr>\n";
 
 	$self->{active_test} = undef;
@@ -135,6 +189,36 @@
 {
 	my ($self) = @_;
 
+	my $st = $self->{statistics};
+	print INDEX "<tr>\n";
+	print INDEX "  <td class=\"testSuiteTotal\">Total</td>\n";
+	print INDEX "  <td></td>\n";
+
+	if ($st->{SUITES_FAIL} == 0) {
+		print INDEX "  <td class=\"resultOk\">";
+	} else {
+		print INDEX "  <td class=\"resultFailure\">";
+	}
+	print INDEX "$st->{TESTS_EXPECTED_OK} ok";
+	if ($st->{TESTS_UNEXPECTED_OK} > 0) {
+		print INDEX " ($st->{TESTS_UNEXPECTED_OK})";
+	}
+	print INDEX "</td>";
+	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 "</td>";
+
+	print INDEX "</tr>\n";
+
 	print INDEX "</table>\n";
 	print INDEX "</center>\n";
 	print INDEX "</td></tr>\n";
@@ -155,7 +239,10 @@
 {
 	my ($self, $name) = @_;
 
-	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";
+	print INDEX "<tr>\n";
+	print INDEX "  <td class=\"testSuite\">$name</td>\n";
+	print INDEX "  <td class=\"resultSkipped\" colspan=\"2\">SKIPPED</td>\n";
+	print INDEX "</tr>\n";
 }
 
 1;

Modified: branches/SAMBA_4_0/source/selftest/output/plain.pm
===================================================================
--- branches/SAMBA_4_0/source/selftest/output/plain.pm	2007-08-26 18:24:12 UTC (rev 24670)
+++ branches/SAMBA_4_0/source/selftest/output/plain.pm	2007-08-26 19:07:46 UTC (rev 24671)
@@ -49,6 +49,13 @@
 	}
 }
 
+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 @@
 	my ($state, $testname) = @_;
 }
 
-sub end_test($$$$)
+sub end_test($$$$$)
 {
-	my ($state, $testname, $result, $unexpected) = @_;
+	my ($state, $testname, $result, $unexpected, $reason) = @_;
 }
 
 sub summary($)

Modified: branches/SAMBA_4_0/source/selftest/output/testresults.css
===================================================================
--- branches/SAMBA_4_0/source/selftest/output/testresults.css	2007-08-26 18:24:12 UTC (rev 24670)
+++ branches/SAMBA_4_0/source/selftest/output/testresults.css	2007-08-26 19:07:46 UTC (rev 24671)
@@ -59,7 +59,7 @@
 /* Skipped */
 td.resultSkipped
 {
-	text-align:       right;
+	text-align:       center;
 	padding-left:     10px;
 	padding-right:    10px;
 	background-color: #FFEA20;
@@ -90,3 +90,20 @@
 {
 	background-color: #FF0000;
 }
+
+div.reason
+{
+	text-align: center;
+	font-weight: bold;
+}
+
+span.control
+{
+	display: none;
+}
+
+div.duration
+{
+	text-align: right;
+	font-weight: bold;
+}

Modified: branches/SAMBA_4_0/source/selftest/selftest.pl
===================================================================
--- branches/SAMBA_4_0/source/selftest/selftest.pl	2007-08-26 18:24:12 UTC (rev 24670)
+++ branches/SAMBA_4_0/source/selftest/selftest.pl	2007-08-26 19:07:46 UTC (rev 24671)
@@ -156,7 +156,8 @@
 	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 @@
 	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}++;
 	}
 



More information about the samba-cvs mailing list