summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2009-06-05 13:16:46 +0200
committerJelmer Vernooij <jelmer@samba.org>2009-06-11 19:59:58 +0200
commit4308e69084c3455072a4e256c84bf3b2b013f31e (patch)
tree4d98adee84fee5c68282e3ab5d596b401903139a
parentc278ee50eeb59f74b960036803e3288c8b329c72 (diff)
downloadsamba-4308e69084c3455072a4e256c84bf3b2b013f31e.tar.gz
samba-4308e69084c3455072a4e256c84bf3b2b013f31e.tar.bz2
samba-4308e69084c3455072a4e256c84bf3b2b013f31e.zip
selftest: Fix subunit stream to include the right prefixes rather than
extending the subunit protocol.
-rw-r--r--selftest/README35
-rwxr-xr-xselftest/filter-subunit.pl (renamed from selftest/filter-xfail.pl)27
-rwxr-xr-xselftest/selftest.pl2
-rw-r--r--source4/selftest/config.mk2
4 files changed, 52 insertions, 14 deletions
diff --git a/selftest/README b/selftest/README
index 83a3e6fd49..a8c5101a61 100644
--- a/selftest/README
+++ b/selftest/README
@@ -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
============
diff --git a/selftest/filter-xfail.pl b/selftest/filter-subunit.pl
index f41bb77f44..9a2c6f556c 100755
--- a/selftest/filter-xfail.pl
+++ b/selftest/filter-subunit.pl
@@ -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";
}
diff --git a/selftest/selftest.pl b/selftest/selftest.pl
index 38ea0df39b..2387904b7a 100755
--- a/selftest/selftest.pl
+++ b/selftest/selftest.pl
@@ -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;
diff --git a/source4/selftest/config.mk b/source4/selftest/config.mk
index cc8a283b41..3271e70311 100644
--- a/source4/selftest/config.mk
+++ b/source4/selftest/config.mk
@@ -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