Skip to content

Commit

Permalink
Merge pull request #12 from cv-library/mce_fix
Browse files Browse the repository at this point in the history
Apply fix from bug #9
  • Loading branch information
petdance authored Jan 10, 2018
2 parents 5f2e9ae + 8d70f66 commit 72814a7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/Test/Perl/Critic.pm
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ sub all_critic_ok {
my @files = Perl::Critic::Utils::all_perl_files(@dirs_or_files);
croak 'Nothing to critique' if not @files;

my $have_mce = eval {require MCE::Grep};
my $have_mce = eval { require MCE::Grep; MCE::Grep->import; 1 };
return $have_mce ? _test_parallel(@files) : _test_serial(@files);
}

Expand All @@ -109,13 +109,15 @@ sub _test_parallel {
# workers. So we disable the T::B sanity checks at the end of its life.
$TEST->no_ending(1);

my $okays = MCE::Grep::mce_grep { critic_ok($_) } @files;
my $okays = MCE::Grep->run( sub { critic_ok($_) }, @files );
my $pass = $okays == @files;

# To make Test::Harness happy, we must emit a test plan and a sensible exit
# status. Usually, T::B does this for us, but we disabled the ending above.
$pass || eval 'END { $? = 1 }'; ## no critic qw(Eval Interpolation)
return $TEST->done_testing(scalar @files);
$TEST->done_testing(scalar @files);

return $pass;
}

#---------------------------------------------------------------------------
Expand All @@ -126,6 +128,8 @@ sub _test_serial {
my $okays = grep {critic_ok($_)} @files;
my $pass = $okays == @files;

$TEST->done_testing(scalar @files);

return $pass;
}

Expand Down

0 comments on commit 72814a7

Please sign in to comment.