1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
#!/usr/bin/perl -w
use strict;
use Test::More tests => 28;
use Config;
# We want to invoke our sub-commands using Perl.
my $perl_path = $Config{perlpath};
if ($^O ne 'VMS') {
$perl_path .= $Config{_exe}
unless $perl_path =~ m/$Config{_exe}$/i;
}
use IPC::System::Simple qw(run EXIT_ANY);
chdir("t"); # Ignore return, since we may already be in t/
run($perl_path,"exiter.pl",0);
ok(1,"Multi-arg implicit zero allowed");
foreach (1..5,250..255) {
eval {
run($perl_path,"exiter.pl",$_);
};
like($@, qr/unexpectedly returned exit value $_/ );
}
# Single arg tests
run("$perl_path exiter.pl 0");
ok(1,"Implicit zero allowed");
foreach (1..5,250..255) {
eval {
run("$perl_path exiter.pl $_");
};
like($@, qr/unexpectedly returned exit value $_/ );
}
# Testing allowable return values
run([0], "$perl_path exiter.pl 0");
ok(1,"Explcit zero allowed");
run([1], "$perl_path exiter.pl 1");
ok(1,"Explicit allow of exit status 1");
run([-1], "$perl_path exiter.pl 5");
ok(1,"Exit-all emulation via [-1] allowed");
run(EXIT_ANY, "$perl_path exiter.pl 5");
ok(1,"Exit-all via EXIT_ANY constant");
|