Skip to content

Commit

Permalink
Merge branch 'jk/test-must-fail-missing'
Browse files Browse the repository at this point in the history
* jk/test-must-fail-missing:
  tests: make test_might_fail fail on missing commands
  tests: make test_might_fail more verbose
  tests: make test_must_fail fail on missing commands
  tests: make test_must_fail more verbose
  • Loading branch information
Junio C Hamano committed Sep 8, 2010
2 parents 1d86cb8 + d0b8a61 commit 1080be2
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions t/test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,18 @@ test_path_is_missing () {

test_must_fail () {
"$@"
test $? -gt 0 -a $? -le 129 -o $? -gt 192
exit_code=$?
if test $exit_code = 0; then
echo >&2 "test_must_fail: command succeeded: $*"
return 1
elif test $exit_code -gt 129 -a $exit_code -le 192; then
echo >&2 "test_must_fail: died by signal: $*"
return 1
elif test $exit_code = 127; then
echo >&2 "test_must_fail: command not found: $*"
return 1
fi
return 0
}

# Similar to test_must_fail, but tolerates success, too. This is
Expand All @@ -636,7 +647,15 @@ test_must_fail () {

test_might_fail () {
"$@"
test $? -ge 0 -a $? -le 129 -o $? -gt 192
exit_code=$?
if test $exit_code -gt 129 -a $exit_code -le 192; then
echo >&2 "test_might_fail: died by signal: $*"
return 1
elif test $exit_code = 127; then
echo >&2 "test_might_fail: command not found: $*"
return 1
fi
return 0
}

# test_cmp is a helper function to compare actual and expected output.
Expand Down

0 comments on commit 1080be2

Please sign in to comment.