@@ -6,11 +6,6 @@ test_description='Test automatic use of a pager.'
6
6
. " $TEST_DIRECTORY " /lib-pager.sh
7
7
. " $TEST_DIRECTORY " /lib-terminal.sh
8
8
9
- cleanup_fail () {
10
- echo >&2 cleanup failed
11
- (exit 1)
12
- }
13
-
14
9
test_expect_success ' setup' '
15
10
sane_unset GIT_PAGER GIT_PAGER_IN_USE &&
16
11
test_unconfig core.pager &&
@@ -22,9 +17,7 @@ test_expect_success 'setup' '
22
17
'
23
18
24
19
test_expect_success TTY ' some commands use a pager' '
25
- rm -f paginated.out ||
26
- cleanup_fail &&
27
-
20
+ rm -f paginated.out &&
28
21
test_terminal git log &&
29
22
test -e paginated.out
30
23
'
@@ -45,49 +38,37 @@ test_expect_failure TTY 'pager runs from subdir' '
45
38
'
46
39
47
40
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 &&
51
42
test_terminal git rev-list HEAD &&
52
43
! test -e paginated.out
53
44
'
54
45
55
46
test_expect_success ' no pager when stdout is a pipe' '
56
- rm -f paginated.out ||
57
- cleanup_fail &&
58
-
47
+ rm -f paginated.out &&
59
48
git log | cat &&
60
49
! test -e paginated.out
61
50
'
62
51
63
52
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 &&
67
54
git log >file &&
68
55
! test -e paginated.out
69
56
'
70
57
71
58
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 &&
75
60
test_terminal git --paginate rev-list HEAD &&
76
61
test -e paginated.out
77
62
'
78
63
79
64
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 &&
83
66
git --paginate log | cat &&
84
67
! test -e paginated.out
85
68
'
86
69
87
70
test_expect_success TTY ' no pager with --no-pager' '
88
- rm -f paginated.out ||
89
- cleanup_fail &&
90
-
71
+ rm -f paginated.out &&
91
72
test_terminal git --no-pager log &&
92
73
! test -e paginated.out
93
74
'
@@ -136,9 +117,7 @@ colorful() {
136
117
}
137
118
138
119
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 &&
142
121
git log --no-color >colorless.log &&
143
122
git log --color >colorful.log &&
144
123
! colorful colorless.log &&
@@ -147,18 +126,14 @@ test_expect_success 'tests can detect color' '
147
126
148
127
test_expect_success ' no color when stdout is a regular file' '
149
128
rm -f colorless.log &&
150
- test_config color.ui auto ||
151
- cleanup_fail &&
152
-
129
+ test_config color.ui auto &&
153
130
git log >colorless.log &&
154
131
! colorful colorless.log
155
132
'
156
133
157
134
test_expect_success TTY ' color when writing to a pager' '
158
135
rm -f paginated.out &&
159
- test_config color.ui auto ||
160
- cleanup_fail &&
161
-
136
+ test_config color.ui auto &&
162
137
(
163
138
TERM=vt100 &&
164
139
export TERM &&
@@ -181,9 +156,7 @@ test_expect_success TTY 'colors are suppressed by color.pager' '
181
156
182
157
test_expect_success ' color when writing to a file intended for a pager' '
183
158
rm -f colorful.log &&
184
- test_config color.ui auto ||
185
- cleanup_fail &&
186
-
159
+ test_config color.ui auto &&
187
160
(
188
161
TERM=vt100 &&
189
162
GIT_PAGER_IN_USE=true &&
@@ -242,9 +215,7 @@ test_default_pager() {
242
215
$test_expectation SIMPLEPAGER,TTY " $cmd - default pager is used by default" "
243
216
sane_unset PAGER GIT_PAGER &&
244
217
test_unconfig core.pager &&
245
- rm -f default_pager_used ||
246
- cleanup_fail &&
247
-
218
+ rm -f default_pager_used &&
248
219
cat >\$ less <<-\EOF &&
249
220
#!/bin/sh
250
221
wc >default_pager_used
@@ -265,9 +236,7 @@ test_PAGER_overrides() {
265
236
$test_expectation TTY " $cmd - PAGER overrides default pager" "
266
237
sane_unset GIT_PAGER &&
267
238
test_unconfig core.pager &&
268
- rm -f PAGER_used ||
269
- cleanup_fail &&
270
-
239
+ rm -f PAGER_used &&
271
240
PAGER='wc >PAGER_used' &&
272
241
export PAGER &&
273
242
$full_command &&
@@ -292,9 +261,7 @@ test_core_pager() {
292
261
293
262
$test_expectation TTY " $cmd - repository-local core.pager setting $used_if_wanted " "
294
263
sane_unset GIT_PAGER &&
295
- rm -f core.pager_used ||
296
- cleanup_fail &&
297
-
264
+ rm -f core.pager_used &&
298
265
PAGER=wc &&
299
266
export PAGER &&
300
267
test_config core.pager 'wc >core.pager_used' &&
@@ -321,9 +288,7 @@ test_pager_subdir_helper() {
321
288
$test_expectation TTY " $cmd - core.pager $used_if_wanted from subdirectory" "
322
289
sane_unset GIT_PAGER &&
323
290
rm -f core.pager_used &&
324
- rm -fr sub ||
325
- cleanup_fail &&
326
-
291
+ rm -fr sub &&
327
292
PAGER=wc &&
328
293
stampname=\$ (pwd)/core.pager_used &&
329
294
export PAGER stampname &&
@@ -341,9 +306,7 @@ test_GIT_PAGER_overrides() {
341
306
parse_args " $@ "
342
307
343
308
$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 &&
347
310
test_config core.pager wc &&
348
311
GIT_PAGER='wc >GIT_PAGER_used' &&
349
312
export GIT_PAGER &&
@@ -356,9 +319,7 @@ test_doesnt_paginate() {
356
319
parse_args " $@ "
357
320
358
321
$test_expectation TTY " no pager for '$cmd '" "
359
- rm -f GIT_PAGER_used ||
360
- cleanup_fail &&
361
-
322
+ rm -f GIT_PAGER_used &&
362
323
GIT_PAGER='wc >GIT_PAGER_used' &&
363
324
export GIT_PAGER &&
364
325
$full_command &&
0 commit comments