Guys,

Okay, my Google-fu is failing me, so hopefully one of you guys can help me out.

For a test, I need to run a snippet of Perl and collect the output.
However, if it rus in the current interpreter, it will load a module
that I need not to be loaded ('cause I'm also going to test if my code
properly loads it).  So I want to run it in a separate instance of
Perl.

First (naive) attempt:

    my $output = `$^X -e '$cmd'`;

This works fine on Linux, but fails on Windows.  Happily, as soon as I
saw the failures, I recognized I had a quoting problem.  No worries, I
said: let's just bypass the shell altogether:

    use IPC::System::Simple qw<capturex>;
    my $output = capturex($^X, '-e', $cmd);

and then added IPC::System::Simple as a test_requires.  That certainly
_changed_ the Windows failures: :-/

C:\strawberry\perl\bin\perl.exe "-MExtUtils::Command::MM" "-e"
"test_harness(0, 'inc', 'blib\lib', 'blib\arch')" t/*.t
t/00.load.t .................. ok
The system cannot find the path specified.
t/data_printer.t ............. skipped: Data::Printer required for
testing pretty dumping
syntax error at -e line 1, at EOF
Execution of -e aborted due to compilation errors.
"C:\strawberry\perl\bin\perl.exe" unexpectedly returned exit value 255
at t/default_funcs.t line 30.
t/default_funcs.t ............
Dubious, test returned 255 (wstat 65280, 0xff00)
No subtests run

I assume the output is intermingled due to parallelization, but I
wanted to reproduce it faithfully.  This seems to be consistent
between ActiveState and Strawberry, but interestingly Cygwin has no
issues.  And all other OSes pass, so it's obviously not a syntax error
in my snippet.

So, generally speaking, how _should_ one go about spawning a separate
instance of perl -e inside a test, reliably, on Windows?


            -- Buddy

Reply via email to