IPC::Run or something else?
Hello, I'm a beginner, please forgive me b/c of the simple questions. I'd like to test that that a batch file (starting a Java app) gives me the expected output or not. What I have now: use strict; use warnings; use IPC::Run 'run'; my $out; my @ls = ( '\/perl\/Feb\/packager\/bin\/package.bat' ) ; run [EMAIL PROTECTED], \undef, \$out or die bat returned $? ; like($out, qr/Usage/, 'Usage message' ); is( $out =~ /config/, 'this is like that'); -- The outcome: C:\perl\Feb\packager\binprove -v Run2.t Run21..2 Usage: -config[Configuration XML URL] -request [Request XML URL] --help not ok 1 - Usage message # Failed test 'Usage message' # in Run2.t at line 8. # ' # # # ' # doesn't match '(?-xism:Usage)' not ok 2 # Failed test in Run2.t at line 9. # got: '' # expected: 'this is like that' # Looks like you failed 2 tests of 2. It seems I couldn't redirect the output. Maybe IPC::Run is not a good choice? If I try it under LINUX (using package.sh instead of package.bat) I'm having the same issue. Could you please help me what direction I should go, what module should I use? Thank you Tamas - Yahoo! Mail - Helps protect you from nasty viruses.
Re: IPC::Run or something else?
Tamas Dober [EMAIL PROTECTED] wrote: Hello, I'm a beginner, please forgive me b/c of the simple questions. I'd like to test that that a batch file (starting a Java app) gives me the expected output or not. I really like IPC::Run, but it is a bit of a heavy package to make users install just for your test cases. If your module is already using it for something else, go for it! Otherwise i'd suggest just opening a pipe if you don't need bidirectional communication; open(my $fh, '-|', @ls); my $out = join('', $fh); ... Cheers, Tyler use warnings; use IPC::Run 'run'; my $out; my @ls = ( '\/perl\/Feb\/packager\/bin\/package.bat' ) ; run [EMAIL PROTECTED], \undef, \$out or die bat returned $? ; like($out, qr/Usage/, 'Usage message' ); is( $out =~ /config/, 'this is like that'); -- The outcome: C:\perl\Feb\packager\binprove -v Run2.t Run21..2 Usage: -config[Configuration XML URL] -request [Request XML URL] --help not ok 1 - Usage message # Failed test 'Usage message' # in Run2.t at line 8. # ' # # # ' # doesn't match '(?-xism:Usage)' not ok 2 # Failed test in Run2.t at line 9. # got: '' # expected: 'this is like that' # Looks like you failed 2 tests of 2. It seems I couldn't redirect the output. Maybe IPC::Run is not a good choice? If I try it under LINUX (using package.sh instead of package.bat) I'm having the same issue. Could you please help me what direction I should go, what module should I use? Thank you Tamas - Yahoo! Mail - Helps protect you from nasty viruses.
Re: IPC::Run or something else?
Tamas Dober wrote: I'd like to test that that a batch file (starting a Java app) gives me the expected output or not. Could you please help me what direction I should go, what module should I use? I've had good experiences with IPC::Run3. It's pretty lightweight and intuitive. If you would like to see examples of how I have used it, look at the test files for ExtUtils::ModuleMaker::TT -- particularly t/20_makeperlmod.t and t/CLI.pm. Best of luck, David Golden
Re: IPC::Run or something else?
On Sun, Feb 05, 2006 at 15:42:26 -0800, Tamas Dober wrote: It seems I couldn't redirect the output. This is probably because the program prints on STDERR. Look into the redirect examples, and try to also capture \$err after \$out - see if that helps Maybe IPC::Run is not a good choice? I think it's a very good choice. -- () Yuval Kogman [EMAIL PROTECTED] 0xEBD27418 perl hacker /\ kung foo master: /me does a karate-chop-flip: neeyah!! pgpBJNCaqSLbk.pgp Description: PGP signature
Re: IPC::Run or something else?
On Mon, Feb 06, 2006 at 18:38:32 +1100, Adam Kennedy wrote: I second this. IPC::Run3 has treated me well on a few occasions, and I'm gradually porting various things of mine over to IPC::Run3 as they come to my attention for other issues. It looks like the ugprade path from IPC::Run3 to IPC::Run is quite easy. If you sever do need weird callbacks, several processes at a time, or PTY support it should be an easy switch. However, for the mean while IPC::Run3 is probably just what you need. -- () Yuval Kogman [EMAIL PROTECTED] 0xEBD27418 perl hacker /\ kung foo master: *shu*rik*en*sh*u*rik*en*s*hur*i*ke*n*: neeyah pgpSkk9Ri9Pkg.pgp Description: PGP signature