Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

critic_ok() in xt/96_perlcritic.t doesn't work with MCE running #9

Open
petdance opened this issue May 26, 2017 · 2 comments
Open

critic_ok() in xt/96_perlcritic.t doesn't work with MCE running #9

petdance opened this issue May 26, 2017 · 2 comments

Comments

@petdance
Copy link
Member

When MCE is installed, xt/96_perlcritic.t fails because no filenames get passed to critic_ok

$ prove -b xt/96_perlcritic.t 
[23:07:49] xt/96_perlcritic.t .. no file specified at xt/96_perlcritic.t line 15.
[23:07:49] xt/96_perlcritic.t .. Dubious, test returned 255 (wstat 65280, 0xff00)
No subtests run 
[23:07:51]
@marioroy
Copy link

Hi @petdance. The following resolves the issue. Also, added missing line in _test_serial.

--- Test/Perl/Critic.pm	2017-07-04 12:01:15.421579849 -0500
+++ Test/Perl/Critic.pm.fix	2017-11-21 21:30:50.478096779 -0600
@@ -92,7 +92,7 @@
     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);
 }

@@ -109,13 +109,15 @@
       # 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;
 }

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

+  $TEST->done_testing(scalar @files);
+
   return $pass;
 }

I tested Test-Perl-Critic without and with MCE 1.827 through 1.832.

colinnewell added a commit to cv-library/Test-Perl-Critic that referenced this issue Jan 3, 2018
petdance added a commit that referenced this issue Jan 10, 2018
@petdance
Copy link
Member Author

Applied. Thank.s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants