t7006: use test_config helpers

In some cases, this is just making the test script a little shorter and easier to read. However, there are several places where we didn't take proper precautions against polluting downstream tests with our config; this fixes them, too. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Aug 17, 2011 at 22:02 UTC 8d68a6d59378760c6bd5c7e0af75fe71c6ed78e7
1 file changed +18 -21
t/t7006-pager.sh
+18 -21
@@ -13,7 +13,7 @@ cleanup_fail() {
13
14 test_expect_success 'setup' '
15 sane_unset GIT_PAGER GIT_PAGER_IN_USE &&
16 - test_might_fail git config --unset core.pager &&
16 + test_unconfig core.pager &&
17
18 PAGER="cat >paginated.out" &&
19 export PAGER &&
@@ -94,21 +94,19 @@ test_expect_success TTY 'no pager with --no-pager' '
94
95 test_expect_success TTY 'configuration can disable pager' '
96 rm -f paginated.out &&
97 - test_might_fail git config --unset pager.grep &&
97 + test_unconfig pager.grep &&
98 test_terminal git grep initial &&
99 test -e paginated.out &&
100
101 rm -f paginated.out &&
102 - git config pager.grep false &&
103 - test_when_finished "git config --unset pager.grep" &&
102 + test_config pager.grep false &&
103 test_terminal git grep initial &&
104 ! test -e paginated.out
105 '
106
107 test_expect_success TTY 'git config uses a pager if configured to' '
108 rm -f paginated.out &&
110 - git config pager.config true &&
111 - test_when_finished "git config --unset pager.config" &&
109 + test_config pager.config true &&
110 test_terminal git config --list &&
111 test -e paginated.out
112 '
@@ -116,8 +114,7 @@ test_expect_success TTY 'git config uses a pager if configured to' '
114 test_expect_success TTY 'configuration can enable pager (from subdir)' '
115 rm -f paginated.out &&
116 mkdir -p subdir &&
119 - git config pager.bundle true &&
120 - test_when_finished "git config --unset pager.bundle" &&
117 + test_config pager.bundle true &&
118
119 git bundle create test.bundle --all &&
120 rm -f paginated.out subdir/paginated.out &&
@@ -150,7 +147,7 @@ test_expect_success 'tests can detect color' '
147
148 test_expect_success 'no color when stdout is a regular file' '
149 rm -f colorless.log &&
153 - git config color.ui auto ||
150 + test_config color.ui auto ||
151 cleanup_fail &&
152
153 git log >colorless.log &&
@@ -159,7 +156,7 @@ test_expect_success 'no color when stdout is a regular file' '
156
157 test_expect_success TTY 'color when writing to a pager' '
158 rm -f paginated.out &&
162 - git config color.ui auto ||
159 + test_config color.ui auto ||
160 cleanup_fail &&
161
162 (
@@ -172,7 +169,7 @@ test_expect_success TTY 'color when writing to a pager' '
169
170 test_expect_success 'color when writing to a file intended for a pager' '
171 rm -f colorful.log &&
175 - git config color.ui auto ||
172 + test_config color.ui auto ||
173 cleanup_fail &&
174
175 (
@@ -221,7 +218,7 @@ test_default_pager() {
218
219 $test_expectation SIMPLEPAGER,TTY "$cmd - default pager is used by default" "
220 sane_unset PAGER GIT_PAGER &&
224 - test_might_fail git config --unset core.pager &&
221 + test_unconfig core.pager &&
222 rm -f default_pager_used ||
223 cleanup_fail &&
224
@@ -244,7 +241,7 @@ test_PAGER_overrides() {
241
242 $test_expectation TTY "$cmd - PAGER overrides default pager" "
243 sane_unset GIT_PAGER &&
247 - test_might_fail git config --unset core.pager &&
244 + test_unconfig core.pager &&
245 rm -f PAGER_used ||
246 cleanup_fail &&
247
@@ -277,7 +274,7 @@ test_core_pager() {
274
275 PAGER=wc &&
276 export PAGER &&
280 - git config core.pager 'wc >core.pager_used' &&
277 + test_config core.pager 'wc >core.pager_used' &&
278 $full_command &&
279 ${if_local_config}test -e core.pager_used
280 "
@@ -307,7 +304,7 @@ test_pager_subdir_helper() {
304 PAGER=wc &&
305 stampname=\$(pwd)/core.pager_used &&
306 export PAGER stampname &&
310 - git config core.pager 'wc >\"\$stampname\"' &&
307 + test_config core.pager 'wc >\"\$stampname\"' &&
308 mkdir sub &&
309 (
310 cd sub &&
@@ -324,7 +321,7 @@ test_GIT_PAGER_overrides() {
321 rm -f GIT_PAGER_used ||
322 cleanup_fail &&
323
327 - git config core.pager wc &&
324 + test_config core.pager wc &&
325 GIT_PAGER='wc >GIT_PAGER_used' &&
326 export GIT_PAGER &&
327 $full_command &&
@@ -405,8 +402,8 @@ test_expect_success TTY 'command-specific pager' '
402 sane_unset PAGER GIT_PAGER &&
403 echo "foo:initial" >expect &&
404 >actual &&
408 - git config --unset core.pager &&
409 - git config pager.log "sed s/^/foo:/ >actual" &&
405 + test_unconfig core.pager &&
406 + test_config pager.log "sed s/^/foo:/ >actual" &&
407 test_terminal git log --format=%s -1 &&
408 test_cmp expect actual
409 '
@@ -415,8 +412,8 @@ test_expect_success TTY 'command-specific pager overrides core.pager' '
412 sane_unset PAGER GIT_PAGER &&
413 echo "foo:initial" >expect &&
414 >actual &&
418 - git config core.pager "exit 1"
419 - git config pager.log "sed s/^/foo:/ >actual" &&
415 + test_config core.pager "exit 1"
416 + test_config pager.log "sed s/^/foo:/ >actual" &&
417 test_terminal git log --format=%s -1 &&
418 test_cmp expect actual
419 '
@@ -425,7 +422,7 @@ test_expect_success TTY 'command-specific pager overridden by environment' '
422 GIT_PAGER="sed s/^/foo:/ >actual" && export GIT_PAGER &&
423 >actual &&
424 echo "foo:initial" >expect &&
428 - git config pager.log "exit 1" &&
425 + test_config pager.log "exit 1" &&
426 test_terminal git log --format=%s -1 &&
427 test_cmp expect actual
428 '