Skip to content

Commit

Permalink
t: Ensure proper output catching
Browse files Browse the repository at this point in the history
  • Loading branch information
okurz committed Nov 1, 2016
1 parent b17c423 commit 402ebd9
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions t/16-utils-runcmd.t
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,21 @@ my $res = run_cmd_with_log_return_error([qw/echo Hallo Welt/]);
ok($res->{status}, 'status ok');
is($res->{stderr}, 'Hallo Welt', 'cmd output returned');

$res = run_cmd_with_log_return_error([qw/false/]);
stderr_like {
$res = run_cmd_with_log_return_error([qw/false/]);
}
qr/.*\[ERROR\] cmd returned non-zero value/i;
ok(!$res->{status}, 'status not ok (non-zero status returned)');

$res = commit_git_return_error {
dir => '/some/dir',
cmd => 'status',
message => 'test',
user => $schema->resultset('Users')->first
};
stderr_like {
$res = commit_git_return_error {
dir => '/some/dir',
cmd => 'status',
message => 'test',
user => $schema->resultset('Users')->first
};
}
qr/fatal: Not a git repository.*\n.*cmd returned non-zero value/i;
is($res, 'Unable to commit via Git: fatal: Not a git repository: \'/some/dir/.git\'', 'Git error message returned');

done_testing();

0 comments on commit 402ebd9

Please sign in to comment.