Note that there are some explanatory texts on larger screens.

plurals
  1. POTesting Scripts in Distribution without Building
    primarykey
    data
    text
    <p>I am trying to test a script that I'm including in my Perl distribution. The script only outputs to files, so my tests check file contents after running it. I tried following the directions in <a href="http://blogs.perl.org/users/neilb/2012/09/testing-scripts-in-your-distribution-portably.html" rel="nofollow">this</a> post, but it doesn't quite work for me. The script that I'm testing uses a module in the same distribution, so running the script requires the location of the module to be added to <code>@INC</code> somehow. I noticed that <a href="https://metacpan.org/module/Test%3a%3aScript" rel="nofollow">Test::Script</a> adds <code>-Mblib</code> to the arguments, so I tried the same. However, it wouldn't work during development because there was no blib directory. Using <code>-Mblib</code> makes everything work only under <code>dzil test</code> or <code>make test</code>. While developing, I use either <code>prove</code> or simply <code>perl -Ilib t/test_script.pl</code>, and trying to use <code>-Mblib</code> results in failed tests and the warning <code>Cannot find blib even in C:\</code>. Considering this, I have a few lines of code that are missing one crucial piece:</p> <pre><code>my $script_path = catfile( $FindBin::Bin, updir(), qw(scripts my_script.pl) ); my $include = $HAS_BLIB &amp;&amp; '-Mblib' || '-I"' . catdir($FindBin::Bin, updir(), 'lib') . '"'; my $args = join ' ', map {qq["$_"]} @input_args; my $command = qq{"$^X" $include "$script_path" $args}; `$command`; #test that script worked here... </code></pre> <p>What do I put instead of the scalar <code>$HAS_BLIB</code>? I need a way to tell if I'm in the middle of building the distribution or not. Other input is welcome. Maybe there's a better way for me to go about doing this? I'd just like a way to test the script that passes with both <code>prove</code> and <code>make test</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload