in reply to Test module to assist sytem()
The disadvantage here is the mixed output from the test script and the system() calls. I cannot simply add ">/dev/null" to @cmd. My real script parameters rely on not using a Shell for system().#!/usr/bin/perl -w use strict; use Test::Simple tests => 3; systest( 0, ("who") ); systest( 0, ("who", "am", "i") ); systest( 1, ("bash", "-c", "exit 1") ); sub systest { my $expected = shift; my @cmd = @_; system @cmd; my $sysres = $? >> 8; ok( $sysres == $expected, "'@cmd' returned $sysres" ); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Test module to assist sytem()
by Anonymous Monk on Nov 29, 2002 at 21:45 UTC |