summaryrefslogtreecommitdiffstats
path: root/selftest
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2010-09-14 00:22:55 +0200
committerJelmer Vernooij <jelmer@samba.org>2010-09-14 10:54:28 +0200
commit1e5ea0be8461ebde4fc52fedeebb0628e1eaf44d (patch)
treee3e8d426182a9a6f583d5b3d5eaefea932fec61c /selftest
parentc0923cfac1a15efddaadfb851d0eab93eba31ef3 (diff)
downloadsamba-1e5ea0be8461ebde4fc52fedeebb0628e1eaf44d.tar.gz
samba-1e5ea0be8461ebde4fc52fedeebb0628e1eaf44d.tar.xz
samba-1e5ea0be8461ebde4fc52fedeebb0628e1eaf44d.zip
subunit.pm: Fold Subunit::Filter into Subunit, trim further.
Diffstat (limited to 'selftest')
-rw-r--r--selftest/Subunit.pm74
-rw-r--r--selftest/Subunit/Filter.pm41
-rwxr-xr-xselftest/selftest.pl7
3 files changed, 11 insertions, 111 deletions
diff --git a/selftest/Subunit.pm b/selftest/Subunit.pm
index 429f770558f..a94eecd7e4b 100644
--- a/selftest/Subunit.pm
+++ b/selftest/Subunit.pm
@@ -19,23 +19,20 @@ use POSIX;
require Exporter;
@ISA = qw(Exporter);
-@EXPORT_OK = qw(parse_results);
+@EXPORT_OK = qw(filter_add_prefix);
use strict;
-sub parse_results($$)
+sub filter_add_prefix($$)
{
- my ($msg_ops, $fh) = @_;
- my $expected_fail = 0;
- my $open_tests = [];
+ my ($prefix, $fh) = @_;
while(<$fh>) {
if (/^test: (.+)\n/) {
- $msg_ops->start_test($1);
- push (@$open_tests, $1);
+ Subunit::start_test($prefix.$1);
} elsif (/^(success|successful|failure|fail|skip|knownfail|error|xfail): (.*?)( \[)?([ \t]*)( multipart)?\n/) {
my $result = $1;
- my $testname = $2;
+ my $testname = $prefix.$2;
my $reason = undef;
if ($3) {
$reason = "";
@@ -46,41 +43,16 @@ sub parse_results($$)
}
unless ($terminated) {
- $msg_ops->end_test($testname, "error",
- "reason ($result) interrupted\n");
- return 1;
+ print $reason;
+ $reason = "reason ($result) interrupted";
+ $result = "error";
}
}
- if ($result eq "success" or $result eq "successful") {
- pop(@$open_tests); #FIXME: Check that popped value == $testname
- $msg_ops->end_test($testname, "success", $reason);
- } elsif ($result eq "xfail" or $result eq "knownfail") {
- pop(@$open_tests); #FIXME: Check that popped value == $testname
- $msg_ops->end_test($testname, "xfail", $reason);
- $expected_fail++;
- } elsif ($result eq "failure" or $result eq "fail") {
- pop(@$open_tests); #FIXME: Check that popped value == $testname
- $msg_ops->end_test($testname, "failure", $reason);
- } elsif ($result eq "skip") {
- # Allow tests to be skipped without prior announcement of test
- my $last = pop(@$open_tests);
- if (defined($last) and $last ne $testname) {
- push (@$open_tests, $testname);
- }
- $msg_ops->end_test($testname, "skip", $reason);
- } elsif ($result eq "error") {
- pop(@$open_tests); #FIXME: Check that popped value == $testname
- $msg_ops->end_test($testname, "error", $reason);
- }
+ Subunit::end_test($testname, $result, $reason);
} else {
print $_;
}
}
-
- while ($#$open_tests+1 > 0) {
- $msg_ops->end_test(pop(@$open_tests), "error",
- "was started but never finished!\n");
- }
}
sub start_test($)
@@ -104,34 +76,6 @@ sub end_test($$;$)
}
}
-sub skip_test($;$)
-{
- my $name = shift;
- my $reason = shift;
- end_test($name, "skip", $reason);
-}
-
-sub fail_test($;$)
-{
- my $name = shift;
- my $reason = shift;
- end_test($name, "fail", $reason);
-}
-
-sub success_test($;$)
-{
- my $name = shift;
- my $reason = shift;
- end_test($name, "success", $reason);
-}
-
-sub xfail_test($;$)
-{
- my $name = shift;
- my $reason = shift;
- end_test($name, "xfail", $reason);
-}
-
sub report_time($)
{
my ($time) = @_;
diff --git a/selftest/Subunit/Filter.pm b/selftest/Subunit/Filter.pm
deleted file mode 100644
index e2b9d1c9ad6..00000000000
--- a/selftest/Subunit/Filter.pm
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/usr/bin/perl
-# Filter a subunit stream
-# Copyright (C) Jelmer Vernooij <jelmer@samba.org>
-# Published under the GNU GPL, v3 or later
-
-package Subunit::Filter;
-
-use strict;
-
-sub start_test($$)
-{
- my ($self, $testname) = @_;
-
- if (defined($self->{prefix})) {
- $testname = $self->{prefix}.$testname;
- }
-
- Subunit::start_test($testname);
-}
-
-sub end_test($$$$)
-{
- my ($self, $testname, $result, $reason) = @_;
-
- if (defined($self->{prefix})) {
- $testname = $self->{prefix}.$testname;
- }
-
- Subunit::end_test($testname, $result, $reason);
-}
-
-sub new {
- my ($class, $prefix) = @_;
-
- my $self = {
- prefix => $prefix,
- };
- bless($self, $class);
-}
-
-1;
diff --git a/selftest/selftest.pl b/selftest/selftest.pl
index 1483174d7a9..42852a192ad 100755
--- a/selftest/selftest.pl
+++ b/selftest/selftest.pl
@@ -130,8 +130,7 @@ use Getopt::Long;
use POSIX;
use Cwd qw(abs_path);
use lib "$RealBin";
-use Subunit qw(parse_results);
-use Subunit::Filter;
+use Subunit;
use SocketWrapper;
eval {
@@ -243,9 +242,7 @@ sub run_testsuite($$$$$)
open(RESULTS, "$cmd 2>&1|");
- my $msg_ops = new Subunit::Filter("$name\.");
-
- parse_results($msg_ops, *RESULTS);
+ Subunit::filter_add_prefix("$name\.", *RESULTS);
my $ret = 0;