summaryrefslogtreecommitdiff
path: root/selftest/format-subunit
blob: 2224b71191cdc0871857db8824795799422391ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/perl
# Pretty-format subunit output
# Copyright (C) Jelmer Vernooij <jelmer@samba.org>
# Published under the GNU GPL, v3 or later

=pod

=head1 NAME

format-subunit [--immediate] < instream > outstream

=head1 SYNOPSIS

Format the output of a subunit stream.

=head1 OPTIONS

=over 4

=item I<--immediate>

Show errors as soon as they happen rather than at the end of the test run.

=head1 LICENSE

GNU General Public License, version 3 or later.

=head1 AUTHOR

Jelmer Vernooij <jelmer@samba.org>
		
=cut

use Getopt::Long;
use strict;
use FindBin qw($RealBin $Script);
use lib "$RealBin";
use Subunit qw(parse_results);

my $opt_help = undef;
my $opt_verbose = 0;
my $opt_immediate = 0;
my $opt_prefix = ".";

my $result = GetOptions (
		'help|h|?' => \$opt_help,
		'verbose' => \$opt_verbose,
		'immediate' => \$opt_immediate,
		'prefix:s' => \$opt_prefix,
	    );

exit(1) if (not $result);

my $msg_ops;

# we want unbuffered output
$| = 1;

my $statistics = {
	SUITES_FAIL => 0,

	TESTS_UNEXPECTED_OK => 0,
	TESTS_EXPECTED_OK => 0,
	TESTS_UNEXPECTED_FAIL => 0,
	TESTS_EXPECTED_FAIL => 0,
	TESTS_ERROR => 0,
	TESTS_SKIP => 0,
};

require output::plain;
$msg_ops = new output::plain("$opt_prefix/summary", $opt_verbose, $opt_immediate, $statistics, undef);

my $expected_ret = parse_results($msg_ops, $statistics, *STDIN);

$msg_ops->summary();

exit($expected_ret);