Skip to content

Commit c53d1e4

Browse files
committed
Merge branch 'jn/test-cleanup-7006'
* jn/test-cleanup-7006: test: errors preparing for a test are not special
2 parents 340c54a + 0d16451 commit c53d1e4

File tree

1 file changed

+17
-56
lines changed

1 file changed

+17
-56
lines changed

t/t7006-pager.sh

Lines changed: 17 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ test_description='Test automatic use of a pager.'
66
. "$TEST_DIRECTORY"/lib-pager.sh
77
. "$TEST_DIRECTORY"/lib-terminal.sh
88

9-
cleanup_fail() {
10-
echo >&2 cleanup failed
11-
(exit 1)
12-
}
13-
149
test_expect_success 'setup' '
1510
sane_unset GIT_PAGER GIT_PAGER_IN_USE &&
1611
test_unconfig core.pager &&
@@ -22,9 +17,7 @@ test_expect_success 'setup' '
2217
'
2318

2419
test_expect_success TTY 'some commands use a pager' '
25-
rm -f paginated.out ||
26-
cleanup_fail &&
27-
20+
rm -f paginated.out &&
2821
test_terminal git log &&
2922
test -e paginated.out
3023
'
@@ -45,49 +38,37 @@ test_expect_failure TTY 'pager runs from subdir' '
4538
'
4639

4740
test_expect_success TTY 'some commands do not use a pager' '
48-
rm -f paginated.out ||
49-
cleanup_fail &&
50-
41+
rm -f paginated.out &&
5142
test_terminal git rev-list HEAD &&
5243
! test -e paginated.out
5344
'
5445

5546
test_expect_success 'no pager when stdout is a pipe' '
56-
rm -f paginated.out ||
57-
cleanup_fail &&
58-
47+
rm -f paginated.out &&
5948
git log | cat &&
6049
! test -e paginated.out
6150
'
6251

6352
test_expect_success 'no pager when stdout is a regular file' '
64-
rm -f paginated.out ||
65-
cleanup_fail &&
66-
53+
rm -f paginated.out &&
6754
git log >file &&
6855
! test -e paginated.out
6956
'
7057

7158
test_expect_success TTY 'git --paginate rev-list uses a pager' '
72-
rm -f paginated.out ||
73-
cleanup_fail &&
74-
59+
rm -f paginated.out &&
7560
test_terminal git --paginate rev-list HEAD &&
7661
test -e paginated.out
7762
'
7863

7964
test_expect_success 'no pager even with --paginate when stdout is a pipe' '
80-
rm -f file paginated.out ||
81-
cleanup_fail &&
82-
65+
rm -f file paginated.out &&
8366
git --paginate log | cat &&
8467
! test -e paginated.out
8568
'
8669

8770
test_expect_success TTY 'no pager with --no-pager' '
88-
rm -f paginated.out ||
89-
cleanup_fail &&
90-
71+
rm -f paginated.out &&
9172
test_terminal git --no-pager log &&
9273
! test -e paginated.out
9374
'
@@ -136,9 +117,7 @@ colorful() {
136117
}
137118

138119
test_expect_success 'tests can detect color' '
139-
rm -f colorful.log colorless.log ||
140-
cleanup_fail &&
141-
120+
rm -f colorful.log colorless.log &&
142121
git log --no-color >colorless.log &&
143122
git log --color >colorful.log &&
144123
! colorful colorless.log &&
@@ -147,18 +126,14 @@ test_expect_success 'tests can detect color' '
147126

148127
test_expect_success 'no color when stdout is a regular file' '
149128
rm -f colorless.log &&
150-
test_config color.ui auto ||
151-
cleanup_fail &&
152-
129+
test_config color.ui auto &&
153130
git log >colorless.log &&
154131
! colorful colorless.log
155132
'
156133

157134
test_expect_success TTY 'color when writing to a pager' '
158135
rm -f paginated.out &&
159-
test_config color.ui auto ||
160-
cleanup_fail &&
161-
136+
test_config color.ui auto &&
162137
(
163138
TERM=vt100 &&
164139
export TERM &&
@@ -181,9 +156,7 @@ test_expect_success TTY 'colors are suppressed by color.pager' '
181156

182157
test_expect_success 'color when writing to a file intended for a pager' '
183158
rm -f colorful.log &&
184-
test_config color.ui auto ||
185-
cleanup_fail &&
186-
159+
test_config color.ui auto &&
187160
(
188161
TERM=vt100 &&
189162
GIT_PAGER_IN_USE=true &&
@@ -242,9 +215,7 @@ test_default_pager() {
242215
$test_expectation SIMPLEPAGER,TTY "$cmd - default pager is used by default" "
243216
sane_unset PAGER GIT_PAGER &&
244217
test_unconfig core.pager &&
245-
rm -f default_pager_used ||
246-
cleanup_fail &&
247-
218+
rm -f default_pager_used &&
248219
cat >\$less <<-\EOF &&
249220
#!/bin/sh
250221
wc >default_pager_used
@@ -265,9 +236,7 @@ test_PAGER_overrides() {
265236
$test_expectation TTY "$cmd - PAGER overrides default pager" "
266237
sane_unset GIT_PAGER &&
267238
test_unconfig core.pager &&
268-
rm -f PAGER_used ||
269-
cleanup_fail &&
270-
239+
rm -f PAGER_used &&
271240
PAGER='wc >PAGER_used' &&
272241
export PAGER &&
273242
$full_command &&
@@ -292,9 +261,7 @@ test_core_pager() {
292261

293262
$test_expectation TTY "$cmd - repository-local core.pager setting $used_if_wanted" "
294263
sane_unset GIT_PAGER &&
295-
rm -f core.pager_used ||
296-
cleanup_fail &&
297-
264+
rm -f core.pager_used &&
298265
PAGER=wc &&
299266
export PAGER &&
300267
test_config core.pager 'wc >core.pager_used' &&
@@ -321,9 +288,7 @@ test_pager_subdir_helper() {
321288
$test_expectation TTY "$cmd - core.pager $used_if_wanted from subdirectory" "
322289
sane_unset GIT_PAGER &&
323290
rm -f core.pager_used &&
324-
rm -fr sub ||
325-
cleanup_fail &&
326-
291+
rm -fr sub &&
327292
PAGER=wc &&
328293
stampname=\$(pwd)/core.pager_used &&
329294
export PAGER stampname &&
@@ -341,9 +306,7 @@ test_GIT_PAGER_overrides() {
341306
parse_args "$@"
342307

343308
$test_expectation TTY "$cmd - GIT_PAGER overrides core.pager" "
344-
rm -f GIT_PAGER_used ||
345-
cleanup_fail &&
346-
309+
rm -f GIT_PAGER_used &&
347310
test_config core.pager wc &&
348311
GIT_PAGER='wc >GIT_PAGER_used' &&
349312
export GIT_PAGER &&
@@ -356,9 +319,7 @@ test_doesnt_paginate() {
356319
parse_args "$@"
357320

358321
$test_expectation TTY "no pager for '$cmd'" "
359-
rm -f GIT_PAGER_used ||
360-
cleanup_fail &&
361-
322+
rm -f GIT_PAGER_used &&
362323
GIT_PAGER='wc >GIT_PAGER_used' &&
363324
export GIT_PAGER &&
364325
$full_command &&

0 commit comments

Comments
 (0)