Skip to content

Commit 8bc481f

Browse files
committed
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
2 parents 011fc2e + 0d9b0d7 commit 8bc481f

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

t/t9300-fast-import.sh

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3191,13 +3191,22 @@ background_import_then_checkpoint () {
31913191
exec 9<>V.output
31923192
rm V.output
31933193

3194-
git fast-import $options <&8 >&9 &
3195-
echo $! >V.pid
3194+
(
3195+
git fast-import $options <&8 >&9 &
3196+
echo $! >&9
3197+
wait $!
3198+
echo >&2 "background fast-import terminated too early with exit code $?"
3199+
# Un-block the read loop in the main shell process.
3200+
echo >&9 UNEXPECTED
3201+
) &
3202+
sh_pid=$!
3203+
read fi_pid <&9
31963204
# We don't mind if fast-import has already died by the time the test
31973205
# ends.
31983206
test_when_finished "
31993207
exec 8>&-; exec 9>&-;
3200-
kill $(cat V.pid) && wait $(cat V.pid)
3208+
kill $sh_pid && wait $sh_pid
3209+
kill $fi_pid && wait $fi_pid
32013210
true"
32023211

32033212
# Start in the background to ensure we adhere strictly to (blocking)
@@ -3217,6 +3226,9 @@ background_import_then_checkpoint () {
32173226
then
32183227
error=0
32193228
break
3229+
elif test "$output" = "UNEXPECTED"
3230+
then
3231+
break
32203232
fi
32213233
# otherwise ignore cruft
32223234
echo >&2 "cruft: $output"
@@ -3229,7 +3241,7 @@ background_import_then_checkpoint () {
32293241
}
32303242

32313243
background_import_still_running () {
3232-
if ! kill -0 "$(cat V.pid)"
3244+
if ! kill -0 "$fi_pid"
32333245
then
32343246
echo >&2 "background fast-import terminated too early"
32353247
false

0 commit comments

Comments
 (0)