@matheusbsbs / matheus-bagliano / commits / 8c33b4cf67
Fork 0

tests: Fix race condition in t7006-pager

Pagers that do not consume their input are dangerous: for example, $ GIT_PAGER=: git log $ echo $? 141 $ The only reason these tests were able to work before was that 'git log' would write to the pipe (and not fill it) before the pager had time to terminate and close the pipe. Fix it by using a program that consumes its input, namely wc (as suggested by Johannes). Reported-by: Johannes Sixt <j.sixt@viscovery.net> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Feb 22, 2010 at 02:46 UTC 8c33b4cf67f47ee46fe0984751fd40c4cf7cf392
1 file changed +6 -6
t/t7006-pager.sh
+6 -6
@@ -137,7 +137,7 @@ rm -f default_pager_used
137 test_expect_success SIMPLEPAGER 'default pager is used by default' '
138 cat > $less <<-EOF &&
139 #!$SHELL_PATH
140 - : > default_pager_used
140 + wc > default_pager_used
141 EOF
142 chmod +x $less &&
143 PATH=.:$PATH test_terminal git log &&
@@ -148,7 +148,7 @@ unset GIT_PAGER
148 git config --unset core.pager
149 rm -f PAGER_used
150 test_expect_success TTY 'PAGER overrides default pager' '
151 - PAGER=": > PAGER_used" &&
151 + PAGER="wc > PAGER_used" &&
152 export PAGER &&
153 test_terminal git log &&
154 test -e PAGER_used
@@ -157,17 +157,17 @@ test_expect_success TTY 'PAGER overrides default pager' '
157 unset GIT_PAGER
158 rm -f core.pager_used
159 test_expect_success TTY 'core.pager overrides PAGER' '
160 - PAGER=: &&
160 + PAGER=wc &&
161 export PAGER &&
162 - git config core.pager ": > core.pager_used" &&
162 + git config core.pager "wc > core.pager_used" &&
163 test_terminal git log &&
164 test -e core.pager_used
165 '
166
167 rm -f GIT_PAGER_used
168 test_expect_success TTY 'GIT_PAGER overrides core.pager' '
169 - git config core.pager : &&
170 - GIT_PAGER=": > GIT_PAGER_used" &&
169 + git config core.pager wc &&
170 + GIT_PAGER="wc > GIT_PAGER_used" &&
171 export GIT_PAGER &&
172 test_terminal git log &&
173 test -e GIT_PAGER_used