# New Ticket Created by "brian d foy" # Please include the string: [perl #130653] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/Ticket/Display.html?id=130653 >
It seems that the exit value that a Proc object returns isn't always what I expect. In the calls where I specify :out, the exit code seems to always be 0. use Test; my $program = '/usr/bin/false'; # maybe yours is different ok $program.IO.e, 'program exists'; subtest { my $proc = run $program; is $proc.exitcode, 1, 'No arguments'; }, 'run with no arguments'; subtest { my $proc = run $program, :out; is $proc.exitcode, 1, 'Output specified, check exit before read'; # is it finished running? $proc.out.slurp-rest; }, 'run with :out argument, read after'; subtest { my $proc = run $program, :out; $proc.out.slurp-rest; is $proc.exitcode, 1, 'Output, check exit after read'; }, 'run with :out argument, read first'; subtest { my $null = $*SPEC.devnull.IO.open; # the program shouldn't compile and perl6 should return 1 my $proc = run $*EXECUTABLE, '-c', $program, :out, :err($null); $proc.out.slurp-rest; is $proc.exitcode, 1, 'Output, check exit after read'; }, 'compile check, read first'; done-testing(); And, the output: ok 1 - program exists ok 1 - No arguments 1..1 ok 2 - run with no arguments not ok 1 - Output specified, check exit before read 1..1 not ok 3 - run with :out argument, read after not ok 1 - Output, check exit after read 1..1 not ok 4 - run with :out argument, read first not ok 1 - Output, check exit after read 1..1 not ok 5 - run with :out argument, read first 1..5 # Failed test 'Output specified, check exit before read' # at /Users/brian/Desktop/false.p6 line 18 # expected: '1' # got: '0' # Looks like you failed 1 test of 1 # Failed test 'run with :out argument, read after' # at /Users/brian/Desktop/false.p6 line 16 # Failed test 'Output, check exit after read' # at /Users/brian/Desktop/false.p6 line 25 # expected: '1' # got: '0' # Looks like you failed 1 test of 1 # Failed test 'run with :out argument, read first' # at /Users/brian/Desktop/false.p6 line 22 # Failed test 'Output, check exit after read' # at /Users/brian/Desktop/false.p6 line 33 # expected: '1' # got: '0' # Looks like you failed 1 test of 1 # Failed test 'run with :out argument, read first' # at /Users/brian/Desktop/false.p6 line 28 # Looks like you failed 3 tests of 5 The details: $ perl6 -v && uname -a This is Rakudo version 2016.11 built on MoarVM version 2016.11 implementing Perl 6.c. Darwin macpro.local 14.5.0 Darwin Kernel Version 14.5.0