summaryrefslogtreecommitdiff
path: root/t/t0008-ignores.sh
diff options
context:
space:
mode:
authorAdam Spiers <git@adamspiers.org>2013-04-29 22:55:25 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-04-29 23:08:33 (GMT)
commitb96114edb36e16d214af1e7945a1d19b8a5e1686 (patch)
tree515aa4c4e6abea2cad467f5d6b94a09739d1da2f /t/t0008-ignores.sh
parentf1ed7fea7974218db15155f3b8d2e29d3fe0971c (diff)
downloadgit-b96114edb36e16d214af1e7945a1d19b8a5e1686.zip
git-b96114edb36e16d214af1e7945a1d19b8a5e1686.tar.gz
git-b96114edb36e16d214af1e7945a1d19b8a5e1686.tar.bz2
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>
Diffstat (limited to 't/t0008-ignores.sh')
-rwxr-xr-xt/t0008-ignores.sh38
1 files changed, 17 insertions, 21 deletions
diff --git a/t/t0008-ignores.sh b/t/t0008-ignores.sh
index fbf12ae..a56db80 100755
--- a/t/t0008-ignores.sh
+++ b/t/t0008-ignores.sh
@@ -688,27 +688,23 @@ do
'
done
-test_expect_success 'setup: have stdbuf?' '
- if which stdbuf >/dev/null 2>&1
- then
- test_set_prereq STDBUF
- fi
-'
-
-test_expect_success STDBUF 'streaming support for --stdin' '
- (
- echo one
- sleep 2
- echo two
- ) | stdbuf -oL git check-ignore -v -n --stdin >out &
- pid=$! &&
- sleep 1 &&
- grep "^\.gitignore:1:one one" out &&
- test $( wc -l <out ) = 1 &&
- sleep 2 &&
- grep "^:: two" out &&
- test $( wc -l <out ) = 2 &&
- ( wait $pid || kill $pid || : ) 2>/dev/null
+test_expect_success PIPE 'streaming support for --stdin' '
+ mkfifo in out &&
+ (git check-ignore -n -v --stdin <in >out &) &&
+
+ # We cannot just "echo >in" because check-ignore would get EOF
+ # after echo exited; instead we open the descriptor in our
+ # shell, and then echo to the fd. We make sure to close it at
+ # the end, so that the subprocess does get EOF and dies
+ # properly.
+ exec 9>in &&
+ test_when_finished "exec 9>&-" &&
+ echo >&9 one &&
+ read response <out &&
+ echo "$response" | grep "^\.gitignore:1:one one" &&
+ echo >&9 two &&
+ read response <out &&
+ echo "$response" | grep "^:: two"
'
test_done