Skip to content

Commit 8d68a6d

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d960c47 commit 8d68a6d

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

t/t7006-pager.sh

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ cleanup_fail() {
1313

1414
test_expect_success 'setup' '
1515
sane_unset GIT_PAGER GIT_PAGER_IN_USE &&
16-
test_might_fail git config --unset core.pager &&
16+
test_unconfig core.pager &&
1717
1818
PAGER="cat >paginated.out" &&
1919
export PAGER &&
@@ -94,30 +94,27 @@ test_expect_success TTY 'no pager with --no-pager' '
9494

9595
test_expect_success TTY 'configuration can disable pager' '
9696
rm -f paginated.out &&
97-
test_might_fail git config --unset pager.grep &&
97+
test_unconfig pager.grep &&
9898
test_terminal git grep initial &&
9999
test -e paginated.out &&
100100
101101
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 &&
104103
test_terminal git grep initial &&
105104
! test -e paginated.out
106105
'
107106

108107
test_expect_success TTY 'git config uses a pager if configured to' '
109108
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 &&
112110
test_terminal git config --list &&
113111
test -e paginated.out
114112
'
115113

116114
test_expect_success TTY 'configuration can enable pager (from subdir)' '
117115
rm -f paginated.out &&
118116
mkdir -p subdir &&
119-
git config pager.bundle true &&
120-
test_when_finished "git config --unset pager.bundle" &&
117+
test_config pager.bundle true &&
121118
122119
git bundle create test.bundle --all &&
123120
rm -f paginated.out subdir/paginated.out &&
@@ -150,7 +147,7 @@ test_expect_success 'tests can detect color' '
150147

151148
test_expect_success 'no color when stdout is a regular file' '
152149
rm -f colorless.log &&
153-
git config color.ui auto ||
150+
test_config color.ui auto ||
154151
cleanup_fail &&
155152
156153
git log >colorless.log &&
@@ -159,7 +156,7 @@ test_expect_success 'no color when stdout is a regular file' '
159156

160157
test_expect_success TTY 'color when writing to a pager' '
161158
rm -f paginated.out &&
162-
git config color.ui auto ||
159+
test_config color.ui auto ||
163160
cleanup_fail &&
164161
165162
(
@@ -172,7 +169,7 @@ test_expect_success TTY 'color when writing to a pager' '
172169

173170
test_expect_success 'color when writing to a file intended for a pager' '
174171
rm -f colorful.log &&
175-
git config color.ui auto ||
172+
test_config color.ui auto ||
176173
cleanup_fail &&
177174
178175
(
@@ -221,7 +218,7 @@ test_default_pager() {
221218

222219
$test_expectation SIMPLEPAGER,TTY "$cmd - default pager is used by default" "
223220
sane_unset PAGER GIT_PAGER &&
224-
test_might_fail git config --unset core.pager &&
221+
test_unconfig core.pager &&
225222
rm -f default_pager_used ||
226223
cleanup_fail &&
227224
@@ -244,7 +241,7 @@ test_PAGER_overrides() {
244241

245242
$test_expectation TTY "$cmd - PAGER overrides default pager" "
246243
sane_unset GIT_PAGER &&
247-
test_might_fail git config --unset core.pager &&
244+
test_unconfig core.pager &&
248245
rm -f PAGER_used ||
249246
cleanup_fail &&
250247
@@ -277,7 +274,7 @@ test_core_pager() {
277274
278275
PAGER=wc &&
279276
export PAGER &&
280-
git config core.pager 'wc >core.pager_used' &&
277+
test_config core.pager 'wc >core.pager_used' &&
281278
$full_command &&
282279
${if_local_config}test -e core.pager_used
283280
"
@@ -307,7 +304,7 @@ test_pager_subdir_helper() {
307304
PAGER=wc &&
308305
stampname=\$(pwd)/core.pager_used &&
309306
export PAGER stampname &&
310-
git config core.pager 'wc >\"\$stampname\"' &&
307+
test_config core.pager 'wc >\"\$stampname\"' &&
311308
mkdir sub &&
312309
(
313310
cd sub &&
@@ -324,7 +321,7 @@ test_GIT_PAGER_overrides() {
324321
rm -f GIT_PAGER_used ||
325322
cleanup_fail &&
326323
327-
git config core.pager wc &&
324+
test_config core.pager wc &&
328325
GIT_PAGER='wc >GIT_PAGER_used' &&
329326
export GIT_PAGER &&
330327
$full_command &&
@@ -405,8 +402,8 @@ test_expect_success TTY 'command-specific pager' '
405402
sane_unset PAGER GIT_PAGER &&
406403
echo "foo:initial" >expect &&
407404
>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" &&
410407
test_terminal git log --format=%s -1 &&
411408
test_cmp expect actual
412409
'
@@ -415,8 +412,8 @@ test_expect_success TTY 'command-specific pager overrides core.pager' '
415412
sane_unset PAGER GIT_PAGER &&
416413
echo "foo:initial" >expect &&
417414
>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" &&
420417
test_terminal git log --format=%s -1 &&
421418
test_cmp expect actual
422419
'
@@ -425,7 +422,7 @@ test_expect_success TTY 'command-specific pager overridden by environment' '
425422
GIT_PAGER="sed s/^/foo:/ >actual" && export GIT_PAGER &&
426423
>actual &&
427424
echo "foo:initial" >expect &&
428-
git config pager.log "exit 1" &&
425+
test_config pager.log "exit 1" &&
429426
test_terminal git log --format=%s -1 &&
430427
test_cmp expect actual
431428
'

0 commit comments

Comments
 (0)