Skip to content

Commit db89a82

Browse files
avargitster
authored andcommitted
rm tests: actually test for SIGPIPE in SIGPIPE test
Change a test initially added in 50cd31c (t3600: comment on inducing SIGPIPE in `git rm`, 2019-11-27) to explicitly test for SIGPIPE using a pattern initially established in 7559a1b (unblock and unignore SIGPIPE, 2014-09-18). The problem with using that pattern is that it requires us to skip the test on MINGW[1]. If we kept the test with its initial semantics[2] we'd get coverage there, at the cost of not checking whether we actually had SIGPIPE outside of MinGW. Arguably we should just remove this test. Between the test added in 7559a1b and the change made in 12e0437 (common-main: call restore_sigpipe_to_default(), 2016-07-01) it's a bit arbitrary to only check this for "git rm". But in lieu of having wider test coverage for other "git" subcommands let's refactor this to explicitly test for SIGPIPE outside of MinGW, and then just that we remove the ".git/index.lock" (as before) on all platforms. 1. https://lore.kernel.org/git/[email protected]/ 2. 0693f9d (Make sure lockfiles are unlocked when dying on SIGPIPE, 2008-12-18) Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6012799 commit db89a82

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

t/t3600-rm.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ test_expect_success 'refresh index before checking if it is up-to-date' '
240240
test_path_is_missing frotz/nitfol
241241
'
242242

243-
test_expect_success 'choking "git rm" should not let it die with cruft' '
243+
choke_git_rm_setup() {
244244
git reset -q --hard &&
245245
test_when_finished "rm -f .git/index.lock && git reset -q --hard" &&
246246
i=0 &&
@@ -249,12 +249,24 @@ test_expect_success 'choking "git rm" should not let it die with cruft' '
249249
do
250250
echo "100644 $hash 0 some-file-$i"
251251
i=$(( $i + 1 ))
252-
done | git update-index --index-info &&
252+
done | git update-index --index-info
253+
}
254+
255+
test_expect_success 'choking "git rm" should not let it die with cruft (induce SIGPIPE)' '
256+
choke_git_rm_setup &&
253257
# git command is intentionally placed upstream of pipe to induce SIGPIPE
254258
git rm -n "some-file-*" | : &&
255259
test_path_is_missing .git/index.lock
256260
'
257261

262+
263+
test_expect_success !MINGW 'choking "git rm" should not let it die with cruft (induce and check SIGPIPE)' '
264+
choke_git_rm_setup &&
265+
OUT=$( ((trap "" PIPE; git rm -n "some-file-*"; echo $? 1>&3) | :) 3>&1 ) &&
266+
test_match_signal 13 "$OUT" &&
267+
test_path_is_missing .git/index.lock
268+
'
269+
258270
test_expect_success 'Resolving by removal is not a warning-worthy event' '
259271
git reset -q --hard &&
260272
test_when_finished "rm -f .git/index.lock msg && git reset -q --hard" &&

0 commit comments

Comments
 (0)