t0008: use named pipe (FIFO) to test check-ignore streaming
sleeps in the check-ignore test suite are not ideal since they can fail when the system is under load, or when a tool like valgrind is used which drastically alters the timing. Therefore we replace them with a more robust solution using a named pipe (FIFO). Thanks to Jeff King for coming up with the redirection wizardry required to make this work. http://article.gmane.org/gmane.comp.version-control.git/220916 Signed-off-by: Adam Spiers <git@adamspiers.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
f1ed7fea79
commit
b96114edb3
@ -688,27 +688,23 @@ do
|
|||||||
'
|
'
|
||||||
done
|
done
|
||||||
|
|
||||||
test_expect_success 'setup: have stdbuf?' '
|
test_expect_success PIPE 'streaming support for --stdin' '
|
||||||
if which stdbuf >/dev/null 2>&1
|
mkfifo in out &&
|
||||||
then
|
(git check-ignore -n -v --stdin <in >out &) &&
|
||||||
test_set_prereq STDBUF
|
|
||||||
fi
|
|
||||||
'
|
|
||||||
|
|
||||||
test_expect_success STDBUF 'streaming support for --stdin' '
|
# We cannot just "echo >in" because check-ignore would get EOF
|
||||||
(
|
# after echo exited; instead we open the descriptor in our
|
||||||
echo one
|
# shell, and then echo to the fd. We make sure to close it at
|
||||||
sleep 2
|
# the end, so that the subprocess does get EOF and dies
|
||||||
echo two
|
# properly.
|
||||||
) | stdbuf -oL git check-ignore -v -n --stdin >out &
|
exec 9>in &&
|
||||||
pid=$! &&
|
test_when_finished "exec 9>&-" &&
|
||||||
sleep 1 &&
|
echo >&9 one &&
|
||||||
grep "^\.gitignore:1:one one" out &&
|
read response <out &&
|
||||||
test $( wc -l <out ) = 1 &&
|
echo "$response" | grep "^\.gitignore:1:one one" &&
|
||||||
sleep 2 &&
|
echo >&9 two &&
|
||||||
grep "^:: two" out &&
|
read response <out &&
|
||||||
test $( wc -l <out ) = 2 &&
|
echo "$response" | grep "^:: two"
|
||||||
( wait $pid || kill $pid || : ) 2>/dev/null
|
|
||||||
'
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
Reference in New Issue
Block a user