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
This commit is contained in:
Junio C Hamano 2019-12-16 13:08:47 -08:00
commit 8bc481f4f6

View File

@ -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