Giter Site home page Giter Site logo

Comments (5)

xtaran avatar xtaran commented on June 11, 2024

Since I just ran into this issue with another project again, here's the Test::Critic::Perl-relevant part of my analysis on the culprit as posted in the mentioned Debian bug report back then:

I'm actually not sure if the bug is really in Test::Perl::Critic. We actually [have several] options where the bug could be:

  • [Skipping solutions in affected packages]
  • libtest-simple-perl: Test::More's subtest, because it doesn't seem to be thread-safe.
  • libmce-perl: MCE::Grep's mce_grep seems to have no option to enforce the using of plain grep upon request.
  • libtest-perl-critic-perl, because Test::Perl::Critic uses mce_grep unconditionally (replacing it with plain grep solves the issue, too.) and its fiddling with Test::Builder's internals ignores $builder->{Test_Results} which is used by subtest.

So a working and tested patch is the following:

diff --git a/lib/Test/Perl/Critic.pm b/lib/Test/Perl/Critic.pm
index 2fdf32b..021e0f7 100644
--- a/lib/Test/Perl/Critic.pm
+++ b/lib/Test/Perl/Critic.pm
@@ -101,7 +101,7 @@ sub all_critic_ok {
     # workers. So we disable the T::B sanity checks at the end of its life.
     $TEST->no_ending(1);
 
-    my $okays = mce_grep { critic_ok($_) } @files;
+    my $okays = grep { critic_ok($_) } @files;
     my $pass = $okays == @files;
 
     # To make Test::Harness happy, we must emit a test plan and a sensible exit

I was tempted to apply that patch [in Debian] and upload it […] but this removes all gain which was added by using MCE::Grep, so that's likely not the right solution. [This] is something upstream must fix — if it is a bug in Test::Perl::Critic at all.

from test-perl-critic.

petdance avatar petdance commented on June 11, 2024

Can someone please describe the problem? I'm seeing all these code examples, but I don't understand what you're seeing.

What is the behavior you're seeing and what are you expecting it to be doing instead?

from test-perl-critic.

xtaran avatar xtaran commented on June 11, 2024

Embedding all_critic_ok(…); inside a Test::More 'subtest "test name", sub { …; }' always fails despite the tests by all_critic_ok(…); were ok and that work around should have helped against all_critic_ok() calling its own done_testing() or equivalent. (And it didn't do that in the past.)

I might come up with a full working example later, if the above explanation doesn't suffice.

from test-perl-critic.

edmundadjei avatar edmundadjei commented on June 11, 2024

I suspect this is corrected by the fix to #9

I tested it with and without MCE and both permutations work

Test file below:


use Test::More;
use Test::Perl::Critic;

my @libs = qw!/home/eadjei/lib_1/ /home/eadjei/cvl/lib_2/!;

for my $lib( @libs ){

subtest "Critic all code in $lib" => sub {
    all_critic_ok($lib);
    done_testing;
};

}
done_testing;

from test-perl-critic.

gregoa avatar gregoa commented on June 11, 2024

from test-perl-critic.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.