2 # Copyright (C) 2001-2005, Parrot Foundation.
7 use lib qw( . lib ../lib ../../lib );
9 use Parrot::Test tests => 7;
13 t/op/spawnw.t - Run OS commands and tell about the exit code
21 Tests spawning external commands.
23 spawnw does not capture STDOUT and STDERR from the spawned command.
24 So only the exit code can be tested.
26 The returned value is actually returned from the 'waitpid' system call.
27 In order to get the exit code from the spawned process, it needs to be right
30 TT #1271: Do not rely on the existence of Perl5 here. Spawn Parrot or some
31 other program which will exist on the target platform
35 Test negative return codes.
39 The special variable $? in Perl5.
43 Nigel Sandever - L<nigelsandever@btconnect.com>
47 # perl command coded this way to avoid platform
50 # test string version of spawnw
52 pasm_output_is( <<'CODE', <<'OUTPUT', "exit code: 0" );
53 set S1, 'perl -e "exit(0)"'
65 pasm_output_is( <<'CODE', <<'OUTPUT', "exit code: 123" );
66 set S1, 'perl -e "exit(123)"'
78 pasm_output_is( <<'CODE', <<'OUTPUT', "exit code: 3" );
79 set S1, 'perl -e "exit(3)"'
91 # test array version of spawnw
93 pasm_output_is( <<'CODE', <<'OUTPUT', "exit code: 0" );
94 new P0, 'ResizablePMCArray'
102 print "return code: "
110 pasm_output_is( <<'CODE', <<'OUTPUT', "exit code: 123" );
111 new P0, 'ResizablePMCArray'
115 set P0[2], "exit(123)"
119 print "return code: "
127 pasm_output_is( <<'CODE', <<'OUTPUT', "exit code: 3" );
128 new P0, 'ResizablePMCArray'
136 print "return code: "
144 pir_output_is( <<'CODE', <<'OUTPUT', "grow argv buffer" );
148 $S0 = "exit length(qq{"
151 if $I0 >= 1000 goto end
152 $S0 = concat $S0, "A"
156 $S0 = concat $S0, "}) / 100"
157 new args, 'ResizablePMCArray'
163 print "return code: "
174 # cperl-indent-level: 4
177 # vim: expandtab shiftwidth=4: