Newer
Older
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
#!/usr/bin/perl
use strict;
use warnings;
use English qw(-no_match_vars);
use IPC::Run qw(run);
use Test::More;
plan tests => 6;
my ($out, $err, $rc);
($out, $err, $rc) = run_executable('account-manager.pl', '--help');
ok($rc == 0, '--help exit status');
is($err, '', '--help stderr');
like(
$out,
qr/^Usage:/,
'--help stdout'
);
($out, $err, $rc) = run_executable('account-manager.pl');
ok($rc == 2, 'no action exit status');
like(
$err,
qr/no action given, aborting/,
'no action stderr'
);
is($out, '', 'no action stdout');
sub run_executable {
my ($executable, $args) = @_;
my @args = $args ? split(/\s+/, $args) : ();
run(
[ $EXECUTABLE_NAME, 'bin/' . $executable, @args ],
\my ($in, $out, $err)
);
return ($out, $err, $CHILD_ERROR >> 8);
}