Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
.say aver line of TAP ouput in one go
Otherwise warnings or other messages can slip in between the indentation
of a subtest or can get in between a 'nok ' and 'ok'.
  • Loading branch information
FROGGS committed May 22, 2015
1 parent 7b0ce69 commit 8f8cc0e
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions lib/Test.pm
Expand Up @@ -70,8 +70,7 @@ multi sub plan($number_of_tests) is export {
$num_of_tests_planned = $number_of_tests;
$no_plan = 0;

$output.print: $indents;
$output.say: '1..' ~ $number_of_tests;
$output.say: $indents ~ '1..' ~ $number_of_tests;
}
# Get two successive timestamps to say how long it takes to read the
# clock, and to let the first test timing work just like the rest.
Expand All @@ -80,10 +79,9 @@ multi sub plan($number_of_tests) is export {
# lot slower than the non portable nqp::time_n.
$time_before = nqp::time_n;
$time_after = nqp::time_n;
$output.print: $indents
$output.say: $indents
~ '# between two timestamps '
~ ceiling(($time_after-$time_before)*1_000_000) ~ ' microseconds'
~ "\n"
if $perl6_test_times;
# Take one more reading to serve as the begin time of the first test
$time_before = nqp::time_n;
Expand Down Expand Up @@ -484,25 +482,24 @@ sub proclaim($cond, $desc) {
# exclude the time spent in proclaim from the test time
$num_of_tests_run = $num_of_tests_run + 1;

$output.print: $indents;
my $tap = $indents;
unless $cond {
$output.print: "not ";
$tap ~= "not ";
unless $num_of_tests_run <= $todo_upto_test_num {
$num_of_tests_failed = $num_of_tests_failed + 1
}
}
if $todo_reason and $num_of_tests_run <= $todo_upto_test_num {
# TAP parsers do not like '#' in the description, they'd miss the '# TODO'
$output.print: "ok ", $num_of_tests_run, " - ", $desc.subst('#', '', :g), $todo_reason;
$tap ~= "ok $num_of_tests_run - " ~ $desc.subst('#', '', :g) ~ $todo_reason;
}
else {
$output.print: "ok ", $num_of_tests_run, " - ", $desc;
$tap ~= "ok $num_of_tests_run - $desc";
}
$output.print: "\n";
$output.print: $indents
$output.say: $tap;
$output.say: $indents
~ "# t="
~ ceiling(($time_after-$time_before)*1_000_000)
~ "\n"
if $perl6_test_times;

unless $cond {
Expand Down Expand Up @@ -536,8 +533,7 @@ sub done() is export {

if $no_plan {
$num_of_tests_planned = $num_of_tests_run;
$output.print: $indents;
$output.say: "1..$num_of_tests_planned";
$output.say: $indents ~ "1..$num_of_tests_planned";
}

if ($num_of_tests_planned != $num_of_tests_run) { ##Wrong quantity of tests
Expand Down

0 comments on commit 8f8cc0e

Please sign in to comment.