Simon Wistow (deflatermouse) wrote,
Simon Wistow
deflatermouse

Module::Pluggable

... which had a tiny but significant bug to do with running under tests.

Richard Clamp diagnosed a problem as being due to the fact that we exclude anything not from blib if there was blib.pm is in %INC.

    my @SEARCHDIR = exists $INC{"blib.pm"} ? grep {/blib/} @INC : @INC;

Of course if the module being tested used another module that used Module::Pluggable then the second module would fail because none of its plugins would work either..

So, fixed it by checking to see if the caller had (^|/)blib/ in their filename.

    my $filename = (caller)[1];
    my @SEARCHDIR = exists $INC{"blib.pm"} && $filename =~ m!(^|/)blib/! ? 
                    grep {/blib/} @INC : @INC;

Which seems to fix everything.

Tags: blib, bug, clamp, exclude, plugins, running, tests
Subscribe

  • Can I have some remedy?

    Because I'm weird and a bit of a misanthrope I've eschewed any of the more popular Java logging utils and rolled my own. Ornery is not just…

  • With these ropes I tied can we do no wrong?

    Last week I did a big refactor of some Java code, massively simplifying the flow and making things clearer, faster, more extensible and more secure.…

  • I get knocked down, but I get up again

    Warning! Achtung! けいせい! Ranting ahead. Much of it rendered somewhat incoherent by some sort of devil lurgy that has infested my mitochondria forcing…

  • Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 0 comments