File: 12_systemx.t

package info (click to toggle)
libipc-system-simple-perl 1.30-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid
  • size: 256 kB
  • sloc: perl: 908; makefile: 4
file content (58 lines) | stat: -rw-r--r-- 1,063 bytes parent folder | download | duplicates (6)
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
57
58
#!/usr/bin/perl -w
use strict;

use IPC::System::Simple qw(system systemx capture capturex);
use Config;
use Test::More tests => 7;

my $perl_path = $Config{perlpath};

if ($^O ne 'VMS') {
        $perl_path .= $Config{_exe}
                unless $perl_path =~ m/$Config{_exe}$/i;
}

chdir("t");     # Ignore return, since we may already be in t/

my $exit_test = "$perl_path exiter.pl 0";

eval {
    system($exit_test);
};

is($@,"","system invokes the shell");

eval {
    systemx($exit_test);
};
ok($@,"systemx does not invoke the shell");

eval {
    systemx($perl_path, "exiter.pl", 0);
};
is($@,"", "multi-arg systemx works");

my $output_test = "$perl_path output.pl";

my $output;

eval {
    $output = capture($output_test);
};
like($output, qr/Hello/, "capture invokes the shell");

undef $output;

eval {
    $output = capturex($output_test);
};

ok($@, "capturex does not invoke the shell");

eval {
    $output = capturex($perl_path, "output.pl");
};

is($@,"","multi-arg capturex works");

like($output, qr/Hello/, "multi-arg capturex captures");