selftest: Fix subunit stream to include the right prefixes rather than
authorJelmer Vernooij <jelmer@samba.org>
Fri, 5 Jun 2009 11:16:46 +0000 (13:16 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Thu, 11 Jun 2009 17:59:58 +0000 (19:59 +0200)
extending the subunit protocol.

selftest/README
selftest/filter-subunit.pl [moved from selftest/filter-xfail.pl with 82% similarity]
selftest/selftest.pl
source4/selftest/config.mk

index 83a3e6fd491164608c718821e132a1954847ea3a..a8c5101a61deca7ffbaa5d0ae259a4b214b067a1 100644 (file)
@@ -77,12 +77,37 @@ time: YYYY-MM-DD HH:mm:ssZ
 Announce the current time. This may be used to calculate the duration of 
 various tests.
 
-prefix
-~~~~~~
-prefix: Prefix
+The following are Samba extensions to Subunit:
 
-Change the global prefix for test names. To unset the prefix, specify an empty 
-string.
+testsuite-count
+~~~~~~~~~~~~~~~
+testsuite-count: number
+
+Announce the number of tests that is going to be run.
+
+start-testsuite
+~~~~~~~~~
+start-testsuite: name
+
+The testsuite name is used as prefix for all containing tests.
+
+skip-testsuite
+~~~~~~~~~~~~~~
+skip-testsuite: name
+
+Mark the testsuite with the specified name as skipped.
+
+testsuite-success
+~~~~~~~~~~~~~~~~~
+testsuite-success: name
+
+Indicate that the testsuite has succeeded successfully.
+
+testsuite-fail
+~~~~~~~~~~~~~~
+testsuite-fail: name
+
+Indicate that a testsuite has failed.
 
 Environments
 ============
similarity index 82%
rename from selftest/filter-xfail.pl
rename to selftest/filter-subunit.pl
index f41bb77f44f7ac68c0fb5b2cba584fe70b280da2..9a2c6f556c70b4d43e752cce952f033c2775696e 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/perl
-# Fix fail -> xfail in subunit streams based on a list of regular expressions
+# Filter a subunit stream
 # Copyright (C) Jelmer Vernooij <jelmer@samba.org>
 # Published under the GNU GPL, v3 or later
 
@@ -7,13 +7,13 @@
 
 =head1 NAME
 
-filter-xfail - Filter known failures in a subunit stream
+filter-subunit - Filter a subunit stream
 
 =head1 SYNOPSIS
 
-filter-xfail --help
+filter-subunit --help
 
-filter-xfail --known-failures=FILE < in-stream > out-stream
+filter-subunit --prefix=PREFIX --known-failures=FILE < in-stream > out-stream
 
 =head1 DESCRIPTION
 
@@ -24,6 +24,10 @@ based on a list of regular expressions.
 
 =over 4
 
+=item I<--prefix>
+
+Add the specified prefix to all test names.
+
 =item I<--expected-failures>
 
 Specify a file containing a list of tests that are expected to fail. Failures 
@@ -57,16 +61,18 @@ use Subunit qw(parse_results);
 
 my $opt_expected_failures = undef;
 my $opt_help = 0;
+my $opt_prefix = undef;
 my @expected_failures = ();
 
 my $result = GetOptions(
                'expected-failures=s' => \$opt_expected_failures,
+               'prefix=s' => \$opt_prefix,
                'help' => \$opt_help,
        );
 exit(1) if (not $result);
 
 if ($opt_help) {
-       print "Usage: filter-xfail [--expected-failures=FILE]... < instream > outstream\n";
+       print "Usage: filter-subunit [--prefix=PREFIX] [--expected-failures=FILE]... < instream > outstream\n";
        exit(0);
 }
 
@@ -145,6 +151,10 @@ sub start_test($$$)
 {
        my ($self, $parents, $testname) = @_;
 
+       if (defined($opt_prefix)) {
+               $testname = $opt_prefix.$testname;
+       }
+
        Subunit::start_test($testname);
 }
 
@@ -152,9 +162,12 @@ sub end_test($$$$$)
 {
        my ($self, $parents, $testname, $result, $unexpected, $reason) = @_;
 
+       if (defined($opt_prefix)) {
+               $testname = $opt_prefix.$testname;
+       }
+
        if (($result eq "fail" or $result eq "failure") and not $unexpected) { $result = "xfail"; }
-       my $fullname = join(".", @$parents) . ".$testname";
-       if (expecting_failure($fullname) and ($result eq "fail" or $result eq "failure")) {
+       if (expecting_failure($testname) and ($result eq "fail" or $result eq "failure")) {
                $result = "xfail";
        }
 
index 38ea0df39bdbe6d9583b5634792a46e3d847a812..2387904b7ad2af02016071465ac28d1e41e44057 100755 (executable)
@@ -220,7 +220,7 @@ sub run_testsuite($$$$$)
        Subunit::prefix($name);
        Subunit::start_test($name);
 
-       my $ret = system("$cmd 2>&1");
+       my $ret = system("$cmd | $RealBin/filter-subunit.pl --prefix \"$name.\" 2>&1");
        if ($ret == -1) {
                Subunit::end_test($name, "error", "Unable to run $cmd: $!");
                return 0;
index cc8a283b41ef9505744f25326e93224a727ec562..3271e7031122fab37738b263f35e7e6c7edc6969 100644 (file)
@@ -8,7 +8,7 @@ SELFTEST = $(LD_LIBPATH_OVERRIDE) PYTHON=$(PYTHON) \
 
 SELFTEST_NOSLOW_OPTS = --exclude=$(srcdir)/selftest/slow
 SELFTEST_QUICK_OPTS = $(SELFTEST_NOSLOW_OPTS) --quick --include=$(srcdir)/selftest/quick
-FILTER_XFAIL = $(PERL) $(selftestdir)/filter-xfail.pl --expected-failures=$(srcdir)/selftest/knownfail
+FILTER_XFAIL = $(PERL) $(selftestdir)/filter-subunit.pl --expected-failures=$(srcdir)/selftest/knownfail
 FORMAT_TEST_OUTPUT = $(FILTER_XFAIL) | $(PERL) $(selftestdir)/format-subunit.pl --format=$(TEST_FORMAT)
 
 subunittest:: everything