Skip to content

Commit

Permalink
Fix duplicate test count id
Browse files Browse the repository at this point in the history
Uses `cas(...)` instead of atomic operators/types so that this
should not break on the JVM as well as be backwards compatible
with older rakudos (these platforms will still experience
the duplicate test count id, however). This does not fix the
output order, but it does fix the plan output (thereby fixing
issues where a plan 200 is used, but the output would be 1..197

See: https://irclog.perlgeek.de/perl6-dev/2017-08-29#i_15086510
  • Loading branch information
ugexe committed Aug 29, 2017
1 parent eb99bbc commit c19e810
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/Test.pm6
Expand Up @@ -675,16 +675,16 @@ sub eval_exception($code) {
sub proclaim(Bool(Mu) $cond, $desc is copy, $unescaped-prefix = '') {
_init_io() unless $output;
# exclude the time spent in proclaim from the test time
$num_of_tests_run = $num_of_tests_run + 1;
my $current_tests_run = cas $num_of_tests_run, -> $i { $i + 1 };

my $tap = $indents;
unless $cond {
$tap ~= "not ";

$num_of_tests_failed = $num_of_tests_failed + 1
unless $num_of_tests_run <= $todo_upto_test_num;
cas( $num_of_tests_failed, -> $i { $i + 1 } )
unless $current_tests_run <= $todo_upto_test_num;

$pseudo_fails = $pseudo_fails + 1 if $subtest_todo_reason;
cas( $pseudo_fails, -> $i { $i + 1 } ) if $subtest_todo_reason;
}

# TAP parsers do not like '#' in the description, they'd miss the '# TODO'
Expand All @@ -696,11 +696,11 @@ sub proclaim(Bool(Mu) $cond, $desc is copy, $unescaped-prefix = '') {
nqp::split('#', $desc.Str))))
!! '';

$tap ~= $todo_reason && $num_of_tests_run <= $todo_upto_test_num
?? "ok $num_of_tests_run - $unescaped-prefix$desc$todo_reason"
$tap ~= $todo_reason && $current_tests_run <= $todo_upto_test_num
?? "ok $current_tests_run - $unescaped-prefix$desc$todo_reason"
!! (! $cond && $subtest_todo_reason)
?? "ok $num_of_tests_run - $unescaped-prefix$desc$subtest_todo_reason"
!! "ok $num_of_tests_run - $unescaped-prefix$desc";
?? "ok $current_tests_run - $unescaped-prefix$desc$subtest_todo_reason"
!! "ok $current_tests_run - $unescaped-prefix$desc";

$tap ~= ("\n$indents# t=" ~ ceiling(($time_after - $time_before)*1_000_000))
if nqp::iseq_i($perl6_test_times,1);
Expand Down

0 comments on commit c19e810

Please sign in to comment.