This is a follow-up simplification. * lib/tap-driver (console_output): Renamed ... (report): ... to this, and extended to appropriately register the test results when needed. (testsuite_error, handle_tap_comment, handle_tap_test, handle_tap_plan): Adjusted accordingly. --- ChangeLog | 10 ++++++++++ lib/tap-driver | 14 ++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog index 01357d1..9cf06aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2011-07-18 Stefano Lattarini <stefano.lattar...@gmail.com> + tap: some preparatory refactoring (2) + This is a follow-up simplification. + * lib/tap-driver (console_output): Renamed ... + (report): ... to this, and extended to appropriately register + the test results when needed. + (testsuite_error, handle_tap_comment, handle_tap_test, + handle_tap_plan): Adjusted accordingly. + +2011-07-18 Stefano Lattarini <stefano.lattar...@gmail.com> + tap: some preparatory refactoring (1) This refactoring is aimed at simplifying the introduction of colored console output for the TAP driver. diff --git a/lib/tap-driver b/lib/tap-driver index eb505de..b669292 100755 --- a/lib/tap-driver +++ b/lib/tap-driver @@ -211,12 +211,13 @@ sub stringify_test_result ($) die "INTERNAL ERROR"; # NOTREACHED } -sub console_output ($;$) +sub report ($;$) { my ($msg, $result, $explanation) = (undef, @_); if ($result =~ /^(?:X?(?:PASS|FAIL)|SKIP|ERROR)/) { $msg = "$result: $test_script_name"; + add_test_result $result; } elsif ($result eq "#") { @@ -236,8 +237,7 @@ sub console_output ($;$) sub testuite_error ($) { - add_test_result "ERROR"; - console_output "ERROR", "- $_[0]"; + report "ERROR", "- $_[0]"; } sub handle_tap_test ($) @@ -268,8 +268,7 @@ sub handle_tap_test ($) $string .= " $explanation"; } } - add_test_result $test_result; - console_output $test_result, $string; + report $test_result, $string; } sub handle_tap_plan ($) @@ -288,8 +287,7 @@ sub handle_tap_plan ($) if not defined $plan->directive && length ($plan->directive) > 0; my $explanation = $plan->explanation ? "- " . $plan->explanation : undef; - add_test_result "SKIP"; - console_output "SKIP", $explanation; + report "SKIP", $explanation; finish; } @@ -305,7 +303,7 @@ sub handle_tap_comment ($) { return unless $cfg{comments}; my $comment = $_[0]->comment; - console_output "#", "$comment" if length $comment; + report "#", "$comment" if length $comment; } sub main (@) -- 1.7.2.3