小编Bor*_*ari的帖子

如何从Test :: Script运行stdout?

我想用Test :: Script模块测试Perl脚本,比如testme.pl,并获取执行脚本的标准输出.undef到目前为止我得到了一个.

这是我试过的(测试文件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);
Run Code Online (Sandbox Code Playgroud)

和要测试的脚本(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;
Run Code Online (Sandbox Code Playgroud)

我也尝试使用数组ref\@out而不是$ out,仍然没有运气.任何的想法?谢谢!

testing perl

1
推荐指数
1
解决办法
56
查看次数

标签 统计

perl ×1

testing ×1