Skip to content

Commit

Permalink
Merge pull request #431 from willert/develop
Browse files Browse the repository at this point in the history
 Fixes --quiet for the exec command
  • Loading branch information
gugod committed Dec 10, 2014
2 parents 5acfeca + 366bff1 commit 818ed7d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/App/perlbrew.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2040,12 +2040,15 @@ sub run_command_exec {
# return 255 for case when process was terminated with signal, in that case real exit code is useless and weird
$exit_code = 255 if $exit_code > 255;
$overall_success = 0;
print "Command terminated with non-zero status.\n" unless $self->{quiet};

print STDERR "Command [" .
join(' ', map { /\s/ ? "'$_'" : $_ } @ARGV) . # trying reverse shell escapes - quote arguments containing spaces
"] terminated with exit code $exit_code (\$? = $err) under the following perl environment:\n";
print STDERR $self->format_info_output;
unless ($self->{quiet}) {
print "Command terminated with non-zero status.\n";

print STDERR "Command [" .
join(' ', map { /\s/ ? "'$_'" : $_ } @ARGV) . # trying reverse shell escapes - quote arguments containing spaces
"] terminated with exit code $exit_code (\$? = $err) under the following perl environment:\n";
print STDERR $self->format_info_output;
}

$self->do_exit_with_error_code($exit_code) if ($opts{'halt-on-error'});
}
Expand Down
11 changes: 11 additions & 0 deletions t/command-exec.t
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,17 @@ Command [perl -E 'somesub 42'] terminated with exit code 7 (\$? = 1792) under th
format_info_output_value
OUT
};
it "should be quiet if asked" => sub {
my $app = App::perlbrew->new(qw(exec --quiet --with), "perl-5.14.1", qw(perl -E), "somesub 42");
$app->expects("format_info_output")->exactly(0)->returns('should not be called!');
App::perlbrew->expects("do_exit_with_error_code")->exactly(1)->returns(sub {
die "simulate exit\n";
});
$app->expects("do_system_with_exit_code")->exactly(1)->returns(7<<8);
stderr_is sub {
eval { $app->run; 1; };
}, '';
};
it "should format info output for right perl" => sub {
my $app = App::perlbrew->new(qw(exec --with), "perl-5.14.1", qw(perl -E), "somesub 42");
$app->expects("format_info_output")->exactly(1)->returns(sub {
Expand Down

0 comments on commit 818ed7d

Please sign in to comment.