From 9e108009d0d4ec97a4b9cf989e3cb2cbc74f4ded Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 3 Jun 2009 18:03:45 +0200 Subject: subunit: Move more Subunit printing logic to Subunit.pm. --- selftest/Subunit.pm | 25 +++++++++++++++++++++++++ selftest/output/subunit.pm | 22 +++++++--------------- 2 files changed, 32 insertions(+), 15 deletions(-) (limited to 'selftest') diff --git a/selftest/Subunit.pm b/selftest/Subunit.pm index fc1a3d1d97d..0bbb795c8c2 100644 --- a/selftest/Subunit.pm +++ b/selftest/Subunit.pm @@ -113,4 +113,29 @@ sub parse_results($$$$$) return 1; } +sub start_test($) +{ + my ($testname) = @_; + print "test: $testname\n"; +} + +sub end_test($$;$) +{ + my $name = shift; + my $result = shift; + my $reason = shift; + if ($reason) { + print "$result: $name [ $reason ]\n"; + } else { + print "$result: $name\n"; + } +} + +sub report_time($) +{ + my ($time) = @_; + my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime($time); + printf "time: %04d-%02d-%02d %02d:%02d:%02dZ\n", $year+1900, $mon, $mday, $hour, $min, $sec; +} + 1; diff --git a/selftest/output/subunit.pm b/selftest/output/subunit.pm index e99b76c1b9d..a7ca5d943d1 100644 --- a/selftest/output/subunit.pm +++ b/selftest/output/subunit.pm @@ -36,8 +36,7 @@ sub new($) { sub report_time($$) { my ($self, $time) = @_; - my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime($time); - printf "time: %04d-%02d-%02d %02d:%02d:%02dZ\n", $year+1900, $mon, $mday, $hour, $min, $sec; + Subunit::report_time($time); } sub start_testsuite($$) @@ -46,7 +45,7 @@ sub start_testsuite($$) $self->{NAME} = $name; - print "test: $self->{NAME}\n"; + Subunit::start_test($self->{NAME}); } sub output_msg($$) @@ -67,18 +66,14 @@ sub end_testsuite($$$$$$) if ($result eq "failure" and not $unexpected) { $result = "xfail"; } - if ($reason) { - print "$result: $name [ $reason ]\n"; - } else { - print "$result: $name\n"; - } + Subunit::end_test($name, $result, $reason); } sub start_test($$$) { my ($self, $parents, $testname) = @_; - print "test: $testname\n"; + Subunit::start_test($testname); } sub end_test($$$$$) @@ -87,11 +82,7 @@ sub end_test($$$$$) if ($result eq "fail" and not $unexpected) { $result = "xfail"; } - if ($reason) { - print "$result: $testname [ $reason ]\n"; - } else { - print "$result: $testname\n"; - } + Subunit::end_test($testname, $result, $reason); } sub summary($) @@ -103,7 +94,8 @@ sub skip_testsuite($$$$) { my ($self, $name, $reason) = @_; - print "skip: $name\n"; + Subunit::start_test($name); + Subunit::end_test($name, "skip"); } 1; -- cgit