From fe13adb17b7fcf0560139bb279d6d1274c84bec9 Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Thu, 9 Dec 2021 00:10:59 -0500 Subject: [PATCH] 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 Reviewed-by: Elijah Newren Signed-off-by: Junio C Hamano --- t/t1020-subdirectory.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh index c2df75e495..da19c06fb5 100755 --- a/t/t1020-subdirectory.sh +++ b/t/t1020-subdirectory.sh @@ -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 (