Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: How do track down underlying reason for smoke test failure

by bliako (Monsignor)
on Sep 12, 2019 at 10:35 UTC ( [id://11106055]=note: print w/replies, xml ) Need Help??


in reply to How do track down underlying reason for smoke test failure

I have managed to reproduce the problem (Perl 5.26.2, fedora linux) when I omitted ./ from INC dir - as Test::Classifier requires t::TestMods::Test::Processor :

prove -Iblib/lib -It/TestMods t/01-file-collector.t
t/01-file-collector.t .. # Running my tests t/01-file-collector.t .. 1/13 # Failed test 'creates an object' # at t/01-file-collector.t line 30. # died: Test::Classifier is not a Role::Tiny at /home/andreas/Download +s/File-Collector-0.037/blib/lib/File/Collector.pm line 391. # Failed test 'has files property' # at t/01-file-collector.t line 34. # Failed test 'has common_dir property' # at t/01-file-collector.t line 38. Can't call method "get_count" on unblessed reference at t/01-file-coll +ector.t line 41. # Looks like your test exited with 2 just after 4.

This works fine on my system:

prove -Iblib/lib -It/TestMods -I. t/01-file-collector.t

Could it be that some of the modules in t/TestMods do not load correctly under certain circumstances?


A comment on your code if I may (File-Collector-0.037 / lib / File / Collector.pm):

# eval class code foreach my $class ( @$classes ) { eval "require $class"; }

Adding a check on eval will tell you if requireed class was not found or failed to load. e.g. from eval, e.g. eval "xyz"; die $@ if $@;

I make this comment because the test fails when constructor sets @classes to contain Test::Classifier. Does this module load OK?

Same goes for AUTOLOAD in said file:

my $obj = $class->new($s->{_files}{all}, \($s->{selected}), $s->{_files}{"${cat}_files"}{_files}); return $obj;

You may want to check whether $obj materialised before returning instead of relying on caller checking if got undef.

bw, bliako

Replies are listed 'Best First'.
Re^2: How do track down underlying reason for smoke test failure
by nysus (Parson) on Sep 12, 2019 at 11:16 UTC

    Nice find. Thanks. That led me to see that the failed tester has PERL_USE_UNSAFE_INC = 0 in the reports. In one of the reports that passed, it is set to "1".

    I'm not completely clear why it fails, though. My test file has use lib 't/TestMods'; in it. So I would think the File::Collector would be able to find my module in there. I don't quite follow how the non-existence of '.' in @INC causes the test to fail.

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
    $nysus = $PM . ' ' . $MCF;
    Click here if you love Perl Monks

      I'm not completely clear why it fails, though. My test file has use lib 't/TestMods'; in it. So I would think the File::Collector would be able to find my module in there. I don't quite follow how existence of '.' in @INC plays into this.

      If my theory is right, loading Test::Classifier fails under certain INC. Because requiring these:

      use t::TestMods::Test::Processor; use t::TestMods::Test::TestObj;

      in t/TestMods/Test/Classifier.pm, requires an INC of ./

      bw, bliako

      edit: changed pre to blockquote

        OK, so I guess a simple fix would be to just throw a use lib '.'; into Test::Classifier.

        $PM = "Perl Monk's";
        $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
        $nysus = $PM . ' ' . $MCF;
        Click here if you love Perl Monks

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11106055]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (1)
As of 2024-04-25 00:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found