1#!/usr/bin/perl 2# Filter a subunit stream 3# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 4# Published under the GNU GPL, v3 or later 5 6=pod 7 8=head1 NAME 9 10filter-subunit - Filter a subunit stream 11 12=head1 SYNOPSIS 13 14filter-subunit --help 15 16filter-subunit --prefix=PREFIX --known-failures=FILE < in-stream > out-stream 17 18=head1 DESCRIPTION 19 20Simple Subunit stream filter that will change failures to known failures 21based on a list of regular expressions. 22 23=head1 OPTIONS 24 25=over 4 26 27=item I<--prefix> 28 29Add the specified prefix to all test names. 30 31=item I<--expected-failures> 32 33Specify a file containing a list of tests that are expected to fail. Failures 34for these tests will be counted as successes, successes will be counted as 35failures. 36 37The format for the file is, one entry per line: 38 39TESTSUITE-NAME.TEST-NAME 40 41The reason for a test can also be specified, by adding a hash sign (#) and the reason 42after the test name. 43 44=head1 LICENSE 45 46selftest is licensed under the GNU General Public License L<http://www.gnu.org/licenses/gpl.html>. 47 48 49=head1 AUTHOR 50 51Jelmer Vernooij 52 53=cut 54 55use Getopt::Long; 56use strict; 57use FindBin qw($RealBin $Script); 58use lib "$RealBin"; 59use Subunit qw(parse_results); 60use Subunit::Filter; 61 62my $opt_expected_failures = undef; 63my $opt_help = 0; 64my $opt_prefix = undef; 65my $opt_strip_ok_output = 0; 66my @expected_failures = (); 67 68my $result = GetOptions( 69 'expected-failures=s' => \$opt_expected_failures, 70 'strip-passed-output' => \$opt_strip_ok_output, 71 'prefix=s' => \$opt_prefix, 72 'help' => \$opt_help, 73 ); 74exit(1) if (not $result); 75 76if ($opt_help) { 77 print "Usage: filter-subunit [--prefix=PREFIX] [--expected-failures=FILE]... < instream > outstream\n"; 78 exit(0); 79} 80 81if (defined($opt_expected_failures)) { 82 @expected_failures = Subunit::Filter::read_test_regexes($opt_expected_failures); 83} 84 85my $statistics = { 86 TESTS_UNEXPECTED_OK => 0, 87 TESTS_EXPECTED_OK => 0, 88 TESTS_UNEXPECTED_FAIL => 0, 89 TESTS_EXPECTED_FAIL => 0, 90 TESTS_ERROR => 0, 91 TESTS_SKIP => 0, 92}; 93 94my $msg_ops = new Subunit::Filter($opt_prefix, \@expected_failures, 95 $opt_strip_ok_output); 96 97exit(parse_results($msg_ops, $statistics, *STDIN)); 98