1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-30 06:50:24 +03:00

subunit.pm: Fold Subunit::Filter into Subunit, trim further.

This commit is contained in:
Jelmer Vernooij 2010-09-14 00:22:55 +02:00
parent c0923cfac1
commit 1e5ea0be84
3 changed files with 11 additions and 111 deletions

View File

@ -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) = @_;

View File

@ -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;

View File

@ -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;