+2011-07-18 Stefano Lattarini <stefano.lattarini@gmail.com>
+
+ tap: some preparatory refactoring (1)
+ This refactoring is aimed at simplifying the introduction of
+ colored console output for the TAP driver.
+ * lib/tap-driver (console_output): Now accept two arguments, the
+ first one indicating which kind of thing is to be displayed (for
+ now only a test result or a diagnostic comment), and the second
+ one (if present) the message associated to it.
+ (handle_tap_test, handle_tap_comment, handle_tap_plan,
+ testsuite_error): Adapt to the new `console_output' interface.
+
2011-07-18 Stefano Lattarini <stefano.lattarini@gmail.com>
tap: add experimental TAP-aware driver
die "INTERNAL ERROR"; # NOTREACHED
}
-sub console_output (@)
+sub console_output ($;$)
{
- return unless @_ > 0;
- my $msg = join ("\n", @_) . "\n";
+ my ($msg, $result, $explanation) = (undef, @_);
+ if ($result =~ /^(?:X?(?:PASS|FAIL)|SKIP|ERROR)/)
+ {
+ $msg = "$result: $test_script_name";
+ }
+ elsif ($result eq "#")
+ {
+ $msg = "# $test_script_name:";
+ }
+ else
+ {
+ die "INTERNAL ERROR"; # NOTREACHED
+ }
+ $msg .= " $explanation" if defined $explanation;
+ $msg .= "\n";
print OLDOUT $msg;
# Log the result in the log file too, to help debugging (this is
# especially true when said result is a TAP error or "Bail out!").
sub testuite_error ($)
{
add_test_result "ERROR";
- console_output "ERROR: $test_script_name - $_[0]";
+ console_output "ERROR", "- $_[0]";
}
sub handle_tap_test ($)
my $test = shift;
my $test_result = stringify_test_result $test;
- my $string = "$test_result: $test_script_name " . $test->number;
+ my $string = $test->number;
if (my $description = $test->description)
{
}
}
add_test_result $test_result;
- console_output $string;
+ console_output $test_result, $string;
}
sub handle_tap_plan ($)
# Nothing more to do, unless the plan contains a SKIP directive.
return
if not defined $plan->directive && length ($plan->directive) > 0;
- my $string = "SKIP: $test_script_name";
- if (my $explanation = $plan->explanation)
- {
- $string .= " - $explanation";
- }
+ my $explanation = $plan->explanation ?
+ "- " . $plan->explanation : undef;
add_test_result "SKIP";
- console_output $string;
+ console_output "SKIP", $explanation;
finish;
}
{
return unless $cfg{comments};
my $comment = $_[0]->comment;
- console_output "# $test_script_name: $comment"
- if length $comment;
+ console_output "#", "$comment" if length $comment;
}
sub main (@)