diff options
author | Junio C Hamano <gitster@pobox.com> | 2019-12-17 00:08:47 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-12-17 00:08:47 +0300 |
commit | 8bc481f4f6d79a7925263da1fc2050c4cecba618 (patch) | |
tree | 0029190a909e5dbebc3b146b08884c299bc74f80 /t/t9300-fast-import.sh | |
parent | 011fc2e88e9ab13760c571330737ffaf0986e4ef (diff) | |
parent | 0d9b0d78859b5a6d91d57609305b1c6eb326bf7e (diff) |
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/t9300-fast-import.sh')
-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 |