tj_thompson has asked for the wisdom of the Perl Monks concerning the following question:
Hello monks,
I have a module using Module::Build. There is one test file that is failing under 'Build test' but does not fail under 'perl -Mblib <test_file>'. My print debugging was showing identical things happening during test in both cases, so I decided to run under the debugger and have a look.
I found that while I could insert breakpoints when running via 'perl -d -Mblib <test_file>', the same breakpoints would not stop execution while running under 'perl -d Build test'.
Here's some simple code showing the issue I'm seeing:
#pm file package BPTest; use strict; use warnings; sub do_stuff { $DB::single = 1; my $x = 10; return $x; } 1; #test file use Test::More tests => 2; BEGIN { use_ok( 'BPTest' ); } is( BPTest->do_stuff, 10, 'do_stuff returns 10' )
Here is what happens under 'perl -Mblib <test_file>':
plxc16479> perl -d -Mblib t/001_load.t Loading DB routines from perl5db.pl version 1.33 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. 1..2 ok 1 - use BPTest; main::(t/001_load.t:9): is( main::(t/001_load.t:10): BPTest->do_stuff, main::(t/001_load.t:11): 10, main::(t/001_load.t:12): 'do_stuff returns 10' main::(t/001_load.t:13): ) DB<1> c + BPTest::do_stuff(/nfs/pdx/disks/nehalem.pde.077/tmp/BPTest/blib/lib/BP +Test.pm:7): 7: my $x = 10; DB<1>
I'm stopped at my breakpoint like I expect. Here's what happens under 'perl -d Build test':
plxc16479> perl -d Build test Loading DB routines from perl5db.pl version 1.33 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(Build:17): my $progname; DB<1> c + t/001_load.t .. ok All tests successful. Files=1, Tests=2, 0 wallclock secs ( 0.03 usr 0.00 sys + 0.02 cusr + 0.00 csys = 0.05 CPU) Result: PASS Debugged program terminated. Use q to quit or R to restart, use o inhibit_exit to avoid stopping after program termination, h q, h R or h o to get additional info. DB<1>
Here I did not stop at the breakpoint. This is making debug difficult since the test failure only occurs under 'Build test'. I have tried to set the breakpoint from the debugger via 'b <sub_name>' and 'b <line>', but both are ignored the same as $DB::single.
So the questions: What is happening under 'Build test' that prevents breakpoints from being honored? At a higher level, what does 'Build test' do differently regarding test files as compared to 'perl -Mblib <file>'?
I appreciate the help and any time spent looking over my question :)
UPDATE: I have resolved the underlying problem causing the test failure. Turns out the @INC array was in a different order when executing 'Build test' vs 'perl -Mblib <test_file>' and was picking up a non test version of one of my modules. However, I'm still interested in why the breakpoints do not seem to work from Build test :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Module::Build's Build test does not stop at breakpoints (exec)
by tye (Sage) on Jan 28, 2014 at 01:58 UTC | |
|
Re: Module::Build's Build test does not stop at breakpoints
by LanX (Saint) on Jan 27, 2014 at 20:23 UTC | |
by tj_thompson (Monk) on Jan 27, 2014 at 21:10 UTC | |
by LanX (Saint) on Jan 27, 2014 at 21:46 UTC |