2009-06-03 20:10:15 +04:00
#!/usr/bin/perl
2009-06-05 15:16:46 +04:00
# Filter a subunit stream
2009-06-03 20:10:15 +04:00
# Copyright (C) Jelmer Vernooij <jelmer@samba.org>
# Published under the GNU GPL, v3 or later
= pod
= head1 NAME
2009-06-05 15:16:46 +04:00
filter - subunit - Filter a subunit stream
2009-06-03 20:10:15 +04:00
= head1 SYNOPSIS
2009-06-05 15:16:46 +04:00
filter - subunit - - help
2009-06-03 20:10:15 +04:00
2009-06-05 15:16:46 +04:00
filter - subunit - - prefix = PREFIX - - known - failures = FILE < in - stream > out - stream
2009-06-03 20:10:15 +04:00
= head1 DESCRIPTION
Simple Subunit stream filter that will change failures to known failures
based on a list of regular expressions .
= head1 OPTIONS
= over 4
2009-06-05 15:16:46 +04:00
= item I <--prefix>
Add the specified prefix to all test names .
2009-06-03 20:10:15 +04:00
= item I <--expected-failures>
Specify a file containing a list of tests that are expected to fail . Failures
for these tests will be counted as successes , successes will be counted as
failures .
The format for the file is , one entry per line:
TESTSUITE - NAME . TEST - NAME
The reason for a test can also be specified , by adding a hash sign ( #) and the reason
after the test name .
= head1 LICENSE
selftest is licensed under the GNU General Public License L <http://www.gnu.org/licenses/gpl.html> .
= head1 AUTHOR
Jelmer Vernooij
= cut
use Getopt::Long ;
use strict ;
use FindBin qw( $RealBin $Script ) ;
use lib "$RealBin" ;
use Subunit qw( parse_results ) ;
2009-06-05 18:32:52 +04:00
use Subunit::Filter ;
2009-06-03 20:10:15 +04:00
my $ opt_expected_failures = undef ;
2009-06-04 15:49:11 +04:00
my $ opt_help = 0 ;
2009-06-05 15:16:46 +04:00
my $ opt_prefix = undef ;
2009-06-03 20:10:15 +04:00
my @ expected_failures = ( ) ;
my $ result = GetOptions (
'expected-failures=s' = > \ $ opt_expected_failures ,
2009-06-05 15:16:46 +04:00
'prefix=s' = > \ $ opt_prefix ,
2009-06-04 15:49:11 +04:00
'help' = > \ $ opt_help ,
2009-06-03 20:10:15 +04:00
) ;
exit ( 1 ) if ( not $ result ) ;
2009-06-04 15:49:11 +04:00
if ( $ opt_help ) {
2009-06-05 15:16:46 +04:00
print "Usage: filter-subunit [--prefix=PREFIX] [--expected-failures=FILE]... < instream > outstream\n" ;
2009-06-04 15:49:11 +04:00
exit ( 0 ) ;
}
2009-06-03 20:10:15 +04:00
if ( defined ( $ opt_expected_failures ) ) {
2009-06-05 18:32:52 +04:00
@ expected_failures = Subunit::Filter:: read_test_regexes ( $ opt_expected_failures ) ;
2009-06-03 20:10:15 +04:00
}
my $ statistics = {
TESTS_UNEXPECTED_OK = > 0 ,
TESTS_EXPECTED_OK = > 0 ,
TESTS_UNEXPECTED_FAIL = > 0 ,
TESTS_EXPECTED_FAIL = > 0 ,
TESTS_ERROR = > 0 ,
TESTS_SKIP = > 0 ,
} ;
2009-06-05 18:32:52 +04:00
my $ msg_ops = new Subunit:: Filter ( $ opt_prefix , \ @ expected_failures ) ;
2009-06-03 20:10:15 +04:00
2009-06-05 18:36:10 +04:00
parse_results ( $ msg_ops , $ statistics , * STDIN ) ;
2009-06-03 20:10:15 +04:00
0 ;