2 # Filter a subunit stream
3 # Copyright (C) Jelmer Vernooij <jelmer@samba.org>
4 # Published under the GNU GPL, v3 or later
6 package Subunit::Filter;
10 sub read_test_regexes($)
14 open(LF, "<$name") or die("unable to read $name: $!");
18 if (/^(.*?)([ \t]+)\#([\t ]*)(.*?)$/) {
19 push (@ret, [$1, $4]);
21 s/^(.*?)([ \t]+)\#([\t ]*)(.*?)$//;
22 push (@ret, [$_, undef]);
31 my ($list, $fullname) = @_;
34 if ($fullname =~ /$$_[0]/) {
35 return ($$_[1]) if ($$_[1]);
46 TESTS_UNEXPECTED_OK => 0,
47 TESTS_EXPECTED_OK => 0,
48 TESTS_UNEXPECTED_FAIL => 0,
49 TESTS_EXPECTED_FAIL => 0,
56 # We regenerate control messages, so ignore this
61 my ($self, $time) = @_;
62 Subunit::report_time($time);
67 my ($self, $msg) = @_;
73 my ($self, $testname) = @_;
75 if (defined($self->{prefix})) {
76 $testname = $self->{prefix}.$testname;
79 Subunit::start_test($testname);
84 my ($self, $testname, $result, $unexpected, $reason) = @_;
86 if (defined($self->{prefix})) {
87 $testname = $self->{prefix}.$testname;
90 if (($result eq "fail" or $result eq "failure") and not $unexpected) { $result = "xfail"; }
91 my $xfail_reason = find_in_list($self->{expected_failures}, $testname);
92 if (defined($xfail_reason) and ($result eq "fail" or $result eq "failure")) {
94 $reason .= $xfail_reason;
97 Subunit::end_test($testname, $result, $reason);
100 sub skip_testsuite($;$)
102 Subunit::skip_testsuite(@_);
105 sub start_testsuite($;$)
107 my ($self, $name) = @_;
108 Subunit::start_testsuite($name);
111 sub end_testsuite($$;$)
113 my ($self, $name, $result, $reason) = @_;
114 Subunit::end_testsuite($name, $result, $reason);
117 sub testsuite_count($$)
119 my ($self, $count) = @_;
120 Subunit::testsuite_count($count);
124 my ($class, $prefix, $expected_failures) = @_;
128 expected_failures => $expected_failures,
130 bless($self, $class);