t1020: avoid aborting entire test script when one test fails
Although `exit 1` is the proper way to signal a test failure from within a subshell, its use outside any subshell should be avoided since it aborts the entire script rather than aborting only the failed test. Instead, a simple `return 1` is the proper idiom for signaling failure outside a subshell since it aborts only the test in question, not the entire script. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Reviewed-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
afb31ad95f
commit
fe13adb17b
@ -22,7 +22,7 @@ test_expect_success 'update-index and ls-files' '
|
||||
git update-index --add one &&
|
||||
case "$(git ls-files)" in
|
||||
one) echo pass one ;;
|
||||
*) echo bad one; exit 1 ;;
|
||||
*) echo bad one; return 1 ;;
|
||||
esac &&
|
||||
(
|
||||
cd dir &&
|
||||
@ -34,7 +34,7 @@ test_expect_success 'update-index and ls-files' '
|
||||
) &&
|
||||
case "$(git ls-files)" in
|
||||
dir/two"$LF"one) echo pass both ;;
|
||||
*) echo bad; exit 1 ;;
|
||||
*) echo bad; return 1 ;;
|
||||
esac
|
||||
'
|
||||
|
||||
@ -57,7 +57,7 @@ test_expect_success 'diff-files' '
|
||||
echo d >>dir/two &&
|
||||
case "$(git diff-files --name-only)" in
|
||||
dir/two"$LF"one) echo pass top ;;
|
||||
*) echo bad top; exit 1 ;;
|
||||
*) echo bad top; return 1 ;;
|
||||
esac &&
|
||||
# diff should not omit leading paths
|
||||
(
|
||||
|
Loading…
Reference in New Issue
Block a user