Skip to content

Commit fe13adb

Browse files
sunshinecogitster
authored andcommitted
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 <[email protected]> Reviewed-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent afb31ad commit fe13adb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

t/t1020-subdirectory.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ test_expect_success 'update-index and ls-files' '
2222
git update-index --add one &&
2323
case "$(git ls-files)" in
2424
one) echo pass one ;;
25-
*) echo bad one; exit 1 ;;
25+
*) echo bad one; return 1 ;;
2626
esac &&
2727
(
2828
cd dir &&
@@ -34,7 +34,7 @@ test_expect_success 'update-index and ls-files' '
3434
) &&
3535
case "$(git ls-files)" in
3636
dir/two"$LF"one) echo pass both ;;
37-
*) echo bad; exit 1 ;;
37+
*) echo bad; return 1 ;;
3838
esac
3939
'
4040

@@ -57,7 +57,7 @@ test_expect_success 'diff-files' '
5757
echo d >>dir/two &&
5858
case "$(git diff-files --name-only)" in
5959
dir/two"$LF"one) echo pass top ;;
60-
*) echo bad top; exit 1 ;;
60+
*) echo bad top; return 1 ;;
6161
esac &&
6262
# diff should not omit leading paths
6363
(

0 commit comments

Comments
 (0)