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>
Eric Sunshine committed
Dec 9, 2021 at 00:10 UTC
fe13adb17b7fcf0560139bb279d6d1274c84bec9
1 file changed
+3
-3
t/t1020-subdirectory.sh
+3
-3
@@ -22,7 +22,7 @@ test_expect_success 'update-index and ls-files' '
22
git update-index --add one &&
23
case "$(git ls-files)" in
24
one) echo pass one ;;
25
- *) echo bad one; exit 1 ;;
25
+ *) echo bad one; return 1 ;;
26
esac &&
27
(
28
cd dir &&
@@ -34,7 +34,7 @@ test_expect_success 'update-index and ls-files' '
34
) &&
35
case "$(git ls-files)" in
36
dir/two"$LF"one) echo pass both ;;
37
- *) echo bad; exit 1 ;;
37
+ *) echo bad; return 1 ;;
38
esac
39
'
40
@@ -57,7 +57,7 @@ test_expect_success 'diff-files' '
57
echo d >>dir/two &&
58
case "$(git diff-files --name-only)" in
59
dir/two"$LF"one) echo pass top ;;
60
- *) echo bad top; exit 1 ;;
60
+ *) echo bad top; return 1 ;;
61
esac &&
62
# diff should not omit leading paths
63
(