diff options
author | Junio C Hamano <gitster@pobox.com> | 2019-12-16 13:08:47 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-12-16 13:08:47 -0800 |
commit | 8bc481f4f6d79a7925263da1fc2050c4cecba618 (patch) | |
tree | 0029190a909e5dbebc3b146b08884c299bc74f80 /t | |
parent | Merge branch 'js/add-i-a-bit-more-tests' (diff) | |
parent | t9300-fast-import: don't hang if background fast-import exits too early (diff) | |
download | tgif-8bc481f4f6d79a7925263da1fc2050c4cecba618.tar.xz |
Merge branch 'sg/t9300-robustify'
The test on "fast-import" used to get stuck when "fast-import" died
in the middle.
* sg/t9300-robustify:
t9300-fast-import: don't hang if background fast-import exits too early
t9300-fast-import: store the PID in a variable instead of pidfile
Diffstat (limited to 't')
-rwxr-xr-x | t/t9300-fast-import.sh | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index 05f07a1671..ae9950a9c2 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -3191,13 +3191,22 @@ background_import_then_checkpoint () { exec 9<>V.output rm V.output - git fast-import $options <&8 >&9 & - echo $! >V.pid + ( + git fast-import $options <&8 >&9 & + echo $! >&9 + wait $! + echo >&2 "background fast-import terminated too early with exit code $?" + # Un-block the read loop in the main shell process. + echo >&9 UNEXPECTED + ) & + sh_pid=$! + read fi_pid <&9 # We don't mind if fast-import has already died by the time the test # ends. test_when_finished " exec 8>&-; exec 9>&-; - kill $(cat V.pid) && wait $(cat V.pid) + kill $sh_pid && wait $sh_pid + kill $fi_pid && wait $fi_pid true" # Start in the background to ensure we adhere strictly to (blocking) @@ -3217,6 +3226,9 @@ background_import_then_checkpoint () { then error=0 break + elif test "$output" = "UNEXPECTED" + then + break fi # otherwise ignore cruft echo >&2 "cruft: $output" @@ -3229,7 +3241,7 @@ background_import_then_checkpoint () { } background_import_still_running () { - if ! kill -0 "$(cat V.pid)" + if ! kill -0 "$fi_pid" then echo >&2 "background fast-import terminated too early" false |