1 # Perl module for parsing and generating the Subunit protocol
2 # Copyright (C) 2008-2009 Jelmer Vernooij <jelmer@samba.org>
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 @EXPORT_OK = qw(filter_add_prefix);
26 sub filter_add_prefix
($$)
28 my ($prefix, $fh) = @_;
31 if (/^test: (.+)\n/) {
32 Subunit
::start_test
($prefix.$1);
33 } elsif (/^(success|successful|failure|fail|skip|knownfail|error|xfail): (.*?)( \[)?([ \t]*)( multipart)?\n/) {
35 my $testname = $prefix.$2;
39 # reason may be specified in next lines
42 if ($_ eq "]\n") { $terminated = 1; last; } else { $reason .= $_; }
45 unless ($terminated) {
47 $reason = "reason ($result) interrupted";
51 Subunit
::end_test
($testname, $result, $reason);
61 print "test: $testname\n";
70 print "$result: $name [\n";
72 if (substr($reason, -1, 1) ne "\n") { print "\n"; }
75 print "$result: $name\n";
82 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime($time);
83 $sec = ($time - int($time) + $sec);
84 my $msg = sprintf("%f", $sec);
85 if (substr($msg, 1, 1) eq ".") {
88 printf "time: %04d-%02d-%02d %02d:%02d:%s\n", $year+1900, $mon+1, $mday, $hour, $min, $msg;
93 print "progress: pop\n";
98 print "progress: push\n";
103 my ($count, $whence) = @_;
105 unless(defined($whence)) {
109 print "progress: $whence$count\n";
112 # The following are Samba extensions:
114 sub start_testsuite
($)
117 print "testsuite: $name\n";
120 sub skip_testsuite
($;$)
122 my ($name, $reason) = @_;
124 print "skip-testsuite: $name [\n$reason\n]\n";
126 print "skip-testsuite: $name\n";
130 sub end_testsuite
($$;$)
136 print "testsuite-$result: $name [\n";
140 print "testsuite-$result: $name\n";