720fe7285cc09d3f47eeadbf1e5452cffd926740
[ira/wip.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 start_testsuite($$)
37 {
38         my ($self, $name) = @_;
39
40         $self->{NAME} = $name;
41         
42         print "test: $self->{NAME}\n";
43 }
44
45 sub output_msg($$)
46 {
47         my ($self, $output) = @_;
48
49         print $output;
50 }
51
52 sub control_msg($$)
53 {
54         my ($self, $output) = @_;
55 }
56
57 sub end_testsuite($$$$$$)
58 {
59         my ($self, $name, $result, $unexpected, $reason) = @_;
60
61         if ($result eq "failure" and not $unexpected) { $result = "xfail"; }
62
63         if ($reason) {
64                 print "$result: $name [ $reason ]\n";
65         } else {
66                 print "$result: $name\n";
67         }
68 }
69
70 sub start_test($$$)
71 {
72         my ($self, $parents, $testname) = @_;
73
74         print "test: $testname\n";
75 }
76
77 sub end_test($$$$$)
78 {
79         my ($self, $parents, $testname, $result, $unexpected, $reason) = @_;
80
81         if ($result eq "fail" and not $unexpected) { $result = "xfail"; }
82
83         if ($reason) {
84                 print "$result: $testname [ $reason ]\n";
85         } else {
86                 print "$result: $testname\n";
87         }
88 }
89
90 sub summary($)
91 {
92         my ($self) = @_;
93 }
94
95 sub skip_testsuite($$$$)
96 {
97         my ($self, $name, $reason) = @_;
98
99         print "skip: $name\n";
100 }
101
102 1;