File: 25-refopts.t

package info (click to toggle)
libsystem-command-perl 1.122-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 228 kB
  • sloc: perl: 550; makefile: 2
file content (22 lines) | stat: -rw-r--r-- 553 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use strict;
use warnings;
use Test::More;
use System::Command;

my @cmd = ( $^X, '-eexit+shift' );
my @codes = ( 0 .. 2, 127 .. 129 );

plan tests => 3 * @codes;

for my $code ( @codes ) {
    my $cmd = System::Command->new(@cmd, $code, { exit => \my $exit } );
    sleep 1 while !$cmd->is_terminated;

    # ensure waitpid isn't called twice, thus clobbering $?
    $cmd->close;
    is( $? >> 8, $code, "\$? >> 8 is $code" );

    # check the exit value
    is( $cmd->exit, $code, "\$cmd->exit is $code" );
    is( $exit, $code, "\$exit is $code" );
}