selftest: Use filter-xfail for known failures
[ira/wip.git] / selftest / format-subunit.pl
1 #!/usr/bin/perl
2 # Pretty-format subunit output
3 # Copyright (C) Jelmer Vernooij <jelmer@samba.org>
4 # Published under the GNU GPL, v3 or later
5
6 use Getopt::Long;
7 use strict;
8 use FindBin qw($RealBin $Script);
9 use lib "$RealBin";
10 use Subunit qw(parse_results);
11
12 my $opt_format = "plain";
13 my $opt_help = undef;
14 my $opt_verbose = 0;
15 my $opt_immediate = 0;
16 my $opt_prefix = ".";
17
18 my $result = GetOptions (
19                 'help|h|?' => \$opt_help,
20                 'format=s' => \$opt_format,
21                 'verbose' => \$opt_verbose,
22                 'immediate' => \$opt_immediate,
23                 'prefix:s' => \$opt_prefix,
24             );
25
26 exit(1) if (not $result);
27
28 if (defined($ENV{RUN_FROM_BUILD_FARM}) and 
29         ($ENV{RUN_FROM_BUILD_FARM} eq "yes")) {
30         $opt_format = "buildfarm";
31 }
32
33 my $msg_ops;
34
35 my $statistics = {
36         SUITES_FAIL => 0,
37
38         TESTS_UNEXPECTED_OK => 0,
39         TESTS_EXPECTED_OK => 0,
40         TESTS_UNEXPECTED_FAIL => 0,
41         TESTS_EXPECTED_FAIL => 0,
42         TESTS_ERROR => 0,
43         TESTS_SKIP => 0,
44 };
45
46 if ($opt_format eq "buildfarm") {
47         require output::buildfarm;
48         $msg_ops = new output::buildfarm($statistics);
49 } elsif ($opt_format eq "plain") {
50         require output::plain;
51         $msg_ops = new output::plain("$opt_prefix/summary", $opt_verbose, $opt_immediate, $statistics, undef);
52 } elsif ($opt_format eq "html") {
53         require output::html;
54         mkdir("test-results", 0777);
55         $msg_ops = new output::html("test-results", $statistics);
56 } elsif ($opt_format eq "subunit") {
57         require output::subunit;
58         $msg_ops = new output::subunit();
59 } else {
60         die("Invalid output format '$opt_format'");
61 }
62
63 my $expected_ret = parse_results(
64         $msg_ops, $statistics, *STDIN, []);
65
66 $msg_ops->summary();
67
68 exit($expected_ret);