jeudi 19 janvier 2017

How to get the stdout from a Test::Script run?

I want to test of Perl script, say testme.pl, with the Test::Script module and get the stdout of the executed script. I get an undef so far.

Here is what I tried (test file test.t):

use Test::More tests => 2;
use Test::Script;       
use Data::Dumper;
script_compiles('testme.pl');
my $out;
script_runs(['testme.pl'], {"stdout"=>$out}, 'run_script');
print "Out is " . Dumper($out);

And the script to be tested (testme.pl)

print "catchme if you can\n";

boris@midkemia artif_get_file $ perl perl_test.pl 
1..2
ok 1 - Script testme.pl compiles
ok 2 - run_script
Out is $VAR1 = undef;

I also tried using an array ref \@out instead of $out, still no luck. Any idea? Thanks!

Aucun commentaire:

Enregistrer un commentaire