summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--selftest/Subunit.pm33
-rw-r--r--selftest/Subunit/Filter.pm122
-rwxr-xr-xselftest/format-subunit7
-rwxr-xr-xselftest/selftest.pl16
4 files changed, 19 insertions, 159 deletions
diff --git a/selftest/Subunit.pm b/selftest/Subunit.pm
index 693de1550e..0f1f2844d6 100644
--- a/selftest/Subunit.pm
+++ b/selftest/Subunit.pm
@@ -23,9 +23,9 @@ require Exporter;
use strict;
-sub parse_results($$$)
+sub parse_results($$)
{
- my ($msg_ops, $statistics, $fh) = @_;
+ my ($msg_ops, $fh) = @_;
my $expected_fail = 0;
my $open_tests = [];
@@ -47,9 +47,8 @@ sub parse_results($$$)
$msg_ops->control_msg($_);
if ($_ eq "]\n") { $terminated = 1; last; } else { $reason .= $_; }
}
-
+
unless ($terminated) {
- $statistics->{TESTS_ERROR}++;
$msg_ops->end_test($testname, "error", 1,
"reason ($result) interrupted\n");
return 1;
@@ -57,19 +56,15 @@ sub parse_results($$$)
}
if ($result eq "success" or $result eq "successful") {
pop(@$open_tests); #FIXME: Check that popped value == $testname
- $statistics->{TESTS_EXPECTED_OK}++;
$msg_ops->end_test($testname, "success", 0, $reason);
} elsif ($result eq "xfail" or $result eq "knownfail") {
pop(@$open_tests); #FIXME: Check that popped value == $testname
- $statistics->{TESTS_EXPECTED_FAIL}++;
$msg_ops->end_test($testname, "xfail", 0, $reason);
$expected_fail++;
} elsif ($result eq "failure" or $result eq "fail") {
pop(@$open_tests); #FIXME: Check that popped value == $testname
- $statistics->{TESTS_UNEXPECTED_FAIL}++;
$msg_ops->end_test($testname, "failure", 1, $reason);
} elsif ($result eq "skip") {
- $statistics->{TESTS_SKIP}++;
# Allow tests to be skipped without prior announcement of test
my $last = pop(@$open_tests);
if (defined($last) and $last ne $testname) {
@@ -77,7 +72,6 @@ sub parse_results($$$)
}
$msg_ops->end_test($testname, "skip", 0, $reason);
} elsif ($result eq "error") {
- $statistics->{TESTS_ERROR}++;
pop(@$open_tests); #FIXME: Check that popped value == $testname
$msg_ops->end_test($testname, "error", 1, $reason);
} elsif ($result eq "skip-testsuite") {
@@ -90,7 +84,7 @@ sub parse_results($$$)
$msg_ops->end_testsuite($testname, "xfail", $reason);
} elsif ($result eq "testsuite-error") {
$msg_ops->end_testsuite($testname, "error", $reason);
- }
+ }
} elsif (/^testsuite: (.*)\n/) {
$msg_ops->start_testsuite($1);
} else {
@@ -101,20 +95,7 @@ sub parse_results($$$)
while ($#$open_tests+1 > 0) {
$msg_ops->end_test(pop(@$open_tests), "error", 1,
"was started but never finished!\n");
- $statistics->{TESTS_ERROR}++;
- }
-
- # if the Filter module is in use, it will have the right counts
- if (defined($msg_ops->{total_error})) {
- $statistics->{TESTS_ERROR} = $msg_ops->{total_error};
- $statistics->{TESTS_UNEXPECTED_FAIL} = $msg_ops->{total_fail};
- $statistics->{TESTS_EXPECTED_FAIL} = $msg_ops->{total_xfail};
}
-
- return 1 if $statistics->{TESTS_ERROR} > 0;
- return 1 if $statistics->{TESTS_UNEXPECTED_FAIL} > 0;
-
- return 0;
}
sub start_test($)
@@ -171,7 +152,11 @@ sub report_time($)
my ($time) = @_;
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime($time);
$sec = ($time - int($time) + $sec);
- printf "time: %04d-%02d-%02d %02d:%02d:%02f\n", $year+1900, $mon+1, $mday, $hour, $min, $sec;
+ my $msg = sprintf("%f", $sec);
+ if (substr($msg, 1, 1) eq ".") {
+ $msg = "0" . $msg;
+ }
+ printf "time: %04d-%02d-%02d %02d:%02d:%s\n", $year+1900, $mon+1, $mday, $hour, $min, $msg;
}
sub progress_pop()
diff --git a/selftest/Subunit/Filter.pm b/selftest/Subunit/Filter.pm
index 4a94f258f1..1c48426995 100644
--- a/selftest/Subunit/Filter.pm
+++ b/selftest/Subunit/Filter.pm
@@ -7,59 +7,15 @@ package Subunit::Filter;
use strict;
-sub read_test_regexes($)
-{
- my ($name) = @_;
- my @ret = ();
- open(LF, "<$name") or die("unable to read $name: $!");
- while (<LF>) {
- chomp;
- next if (/^#/);
- next if (/^$/);
- if (/^(.*?)([ \t]+)\#([\t ]*)(.*?)$/) {
- push (@ret, [$1, $4]);
- } else {
- s/^(.*?)([ \t]+)\#([\t ]*)(.*?)$//;
- push (@ret, [$_, undef]);
- }
- }
- close(LF);
- return @ret;
-}
-
-sub find_in_list($$)
-{
- my ($list, $fullname) = @_;
-
- foreach (@$list) {
- if ($fullname =~ /$$_[0]/) {
- return ($$_[1]) if ($$_[1]);
- return "";
- }
- }
-
- return undef;
-}
-
sub control_msg()
{
# We regenerate control messages, so ignore this
}
-sub report_time($$)
-{
- my ($self, $time) = @_;
- Subunit::report_time($time);
-}
-
sub output_msg($$)
{
my ($self, $msg) = @_;
- unless(defined($self->{output})) {
- print $msg;
- } else {
- $self->{output}.=$msg;
- }
+ print $msg;
}
sub start_test($$)
@@ -70,10 +26,6 @@ sub start_test($$)
$testname = $self->{prefix}.$testname;
}
- if ($self->{strip_ok_output}) {
- $self->{output} = "";
- }
-
Subunit::start_test($testname);
}
@@ -85,36 +37,6 @@ sub end_test($$$$$)
$testname = $self->{prefix}.$testname;
}
- if (($result eq "fail" or $result eq "failure") and not $unexpected) {
- $result = "xfail";
- $self->{xfail_added}++;
- $self->{total_xfail}++;
- }
- my $xfail_reason = find_in_list($self->{expected_failures}, $testname);
- if (defined($xfail_reason) and ($result eq "fail" or $result eq "failure")) {
- $result = "xfail";
- $self->{xfail_added}++;
- $self->{total_xfail}++;
- $reason .= $xfail_reason;
- }
-
- if ($result eq "fail" or $result eq "failure") {
- $self->{fail_added}++;
- $self->{total_fail}++;
- }
-
- if ($result eq "error") {
- $self->{error_added}++;
- $self->{total_error}++;
- }
-
- if ($self->{strip_ok_output}) {
- unless ($result eq "success" or $result eq "xfail" or $result eq "skip") {
- print $self->{output}
- }
- }
- $self->{output} = undef;
-
Subunit::end_test($testname, $result, $reason);
}
@@ -128,57 +50,19 @@ sub start_testsuite($;$)
{
my ($self, $name) = @_;
Subunit::start_testsuite($name);
-
- $self->{error_added} = 0;
- $self->{fail_added} = 0;
- $self->{xfail_added} = 0;
}
sub end_testsuite($$;$)
{
my ($self, $name, $result, $reason) = @_;
- my $xfail = 0;
-
- $xfail = 1 if ($self->{xfail_added} > 0);
- $xfail = 0 if ($self->{fail_added} > 0);
- $xfail = 0 if ($self->{error_added} > 0);
-
- if ($xfail and ($result eq "fail" or $result eq "failure")) {
- $result = "xfail";
- }
-
- if ($self->{fail_added} > 0 and $result ne "failure") {
- $result = "failure";
- $reason = "Subunit/Filer Reason" unless defined($reason);
- $reason .= "\n failures[$self->{fail_added}]";
- }
-
- if ($self->{error_added} > 0 and $result ne "error") {
- $result = "error";
- $reason = "Subunit/Filer Reason" unless defined($reason);
- $reason .= "\n errors[$self->{error_added}]";
- }
-
Subunit::end_testsuite($name, $result, $reason);
}
-sub testsuite_count($$)
-{
- my ($self, $count) = @_;
- Subunit::testsuite_count($count);
-}
-
sub new {
- my ($class, $prefix, $expected_failures, $strip_ok_output) = @_;
+ my ($class, $prefix) = @_;
- my $self = {
+ my $self = {
prefix => $prefix,
- expected_failures => $expected_failures,
- strip_ok_output => $strip_ok_output,
- xfail_added => 0,
- total_xfail => 0,
- total_error => 0,
- total_fail => 0
};
bless($self, $class);
}
diff --git a/selftest/format-subunit b/selftest/format-subunit
index 067fb06610..43cdf096f2 100755
--- a/selftest/format-subunit
+++ b/selftest/format-subunit
@@ -45,6 +45,7 @@ class PlainFormatter(subunithelper.TestsuiteEnabledTestResult):
self.name = None
self._progress_level = 0
self.totalsuites = totaltests
+ self.last_time = None
def progress(self, offset, whence):
if whence == subunit.PROGRESS_POP:
@@ -65,9 +66,6 @@ class PlainFormatter(subunithelper.TestsuiteEnabledTestResult):
def start_testsuite(self, name):
self.index += 1
self.name = name
- testsuite_start_time = self.last_time
-
- duration = testsuite_start_time - self.start_time
if not self.verbose:
self.test_output[name] = ""
@@ -75,7 +73,8 @@ class PlainFormatter(subunithelper.TestsuiteEnabledTestResult):
out = "[%d" % self.index
if self.totalsuites is not None:
out += "/%d" % self.totalsuites
- out += " in " + format_time(duration)
+ if self.start_time is not None:
+ out += " in " + format_time(self.last_time - self.start_time)
if self.suitesfailed:
out += ", %d errors" % (len(self.suitesfailed),)
out += "] %s" % name
diff --git a/selftest/selftest.pl b/selftest/selftest.pl
index 75110708cc..1483174d7a 100755
--- a/selftest/selftest.pl
+++ b/selftest/selftest.pl
@@ -242,18 +242,10 @@ sub run_testsuite($$$$$)
Subunit::report_time(time());
open(RESULTS, "$cmd 2>&1|");
- my $statistics = {
- TESTS_UNEXPECTED_OK => 0,
- TESTS_EXPECTED_OK => 0,
- TESTS_UNEXPECTED_FAIL => 0,
- TESTS_EXPECTED_FAIL => 0,
- TESTS_ERROR => 0,
- TESTS_SKIP => 0,
- };
-
- my $msg_ops = new Subunit::Filter("$name\.", []);
-
- parse_results($msg_ops, $statistics, *RESULTS);
+
+ my $msg_ops = new Subunit::Filter("$name\.");
+
+ parse_results($msg_ops, *RESULTS);
my $ret = 0;