subunit: Move more Subunit printing logic to Subunit.pm.
[samba.git] / selftest / output / subunit.pm
1 #!/usr/bin/perl
2 # Subunit output for selftest
3 # Copyright (C) 2009 Jelmer Vernooij <jelmer@samba.org>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 package output::subunit;
19
20 use Exporter;
21 @ISA = qw(Exporter);
22
23 use FindBin qw($RealBin);
24 use lib "$RealBin/..";
25
26 use Subunit qw(parse_results);
27
28 use strict;
29
30 sub new($) {
31         my ($class) = @_;
32         my $self = { };
33         bless($self, $class);
34 }
35
36 sub report_time($$)
37 {
38         my ($self, $time) = @_;
39         Subunit::report_time($time);
40 }
41
42 sub start_testsuite($$)
43 {
44         my ($self, $name) = @_;
45
46         $self->{NAME} = $name;
47         
48         Subunit::start_test($self->{NAME});
49 }
50
51 sub output_msg($$)
52 {
53         my ($self, $output) = @_;
54
55         print $output;
56 }
57
58 sub control_msg($$)
59 {
60         my ($self, $output) = @_;
61 }
62
63 sub end_testsuite($$$$$$)
64 {
65         my ($self, $name, $result, $unexpected, $reason) = @_;
66
67         if ($result eq "failure" and not $unexpected) { $result = "xfail"; }
68
69         Subunit::end_test($name, $result, $reason);
70 }
71
72 sub start_test($$$)
73 {
74         my ($self, $parents, $testname) = @_;
75
76         Subunit::start_test($testname);
77 }
78
79 sub end_test($$$$$)
80 {
81         my ($self, $parents, $testname, $result, $unexpected, $reason) = @_;
82
83         if ($result eq "fail" and not $unexpected) { $result = "xfail"; }
84
85         Subunit::end_test($testname, $result, $reason);
86 }
87
88 sub summary($)
89 {
90         my ($self) = @_;
91 }
92
93 sub skip_testsuite($$$$)
94 {
95         my ($self, $name, $reason) = @_;
96
97         Subunit::start_test($name);
98         Subunit::end_test($name, "skip");
99 }
100
101 1;