Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Git::Deploy::Test: support -1 argument for a wanted exit code for any…

… non-0

Sometimes we want a command to fail but we don't care what exit code
it emits when doing so, introduce the magic -1 exit code for all non-0
exit codes being OK.
  • Loading branch information...
commit 7ec8acff127082fcbb7fb483ee611e6f553b286a 1 parent ea6941b
Ævar Arnfjörð Bjarmason avar authored
Showing with 3 additions and 1 deletion.
  1. +3 −1 t/lib/Git/Deploy/Test.pm
4 t/lib/Git/Deploy/Test.pm
View
@@ -20,7 +20,9 @@ sub _system {
my $raw_exit_code = system $cmd;
my $exit_code = $raw_exit_code >> 8;
- if ($exit_code != $wanted_exit_code) {
+ if ($exit_code != 0 && $wanted_exit_code == -1) {
+ pass "The command <$cmd> exited with code <$exit_code>, which is non-0 like we wanted";
+ } elsif ($exit_code != $wanted_exit_code) {
fail "The command <$cmd> exited with <$exit_code>, but we wanted <$wanted_exit_code>: $!"
} else {
pass "The command <$cmd> exited with code <$exit_code> like we wanted";
Please sign in to comment.
Something went wrong with that request. Please try again.