Skip to content

Commit a070221

Browse files
jrngitster
authored andcommitted
add -i test: use skip_all instead of repeated PERL prerequisite
It is too easy to forget to add the PERL prerequisite for new "add -i" tests, especially given that many people do not test with NO_PERL so the missing prereq is not always noticed quickly. The test had used the skip_all mechanism since 1b19ccd (2009-04-03) but switched to explicit PERL prereqs in f045931 (2010-10-13) in hope of helping people see how many tests were skipped, perhaps to motivate them to tweak their platform or tests to improve test coverage. That didn't pan out much in practice, so let's move back to the simpler skip_all method. Reported-by: Kacper Kornet <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0bb0c15 commit a070221

File tree

1 file changed

+41
-35
lines changed

1 file changed

+41
-35
lines changed

t/t3701-add-interactive.sh

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,24 @@ test_description='add -i basic tests'
44
. ./test-lib.sh
55
. "$TEST_DIRECTORY"/lib-prereq-FILEMODE.sh
66

7-
test_expect_success PERL 'setup (initial)' '
7+
if ! test_have_prereq PERL
8+
then
9+
skip_all='skipping add -i tests, perl not available'
10+
test_done
11+
fi
12+
13+
test_expect_success 'setup (initial)' '
814
echo content >file &&
915
git add file &&
1016
echo more >>file &&
1117
echo lines >>file
1218
'
13-
test_expect_success PERL 'status works (initial)' '
19+
test_expect_success 'status works (initial)' '
1420
git add -i </dev/null >output &&
1521
grep "+1/-0 *+2/-0 file" output
1622
'
1723

18-
test_expect_success PERL 'setup expected' '
24+
test_expect_success 'setup expected' '
1925
cat >expected <<EOF
2026
new file mode 100644
2127
index 0000000..d95f3ad
@@ -26,19 +32,19 @@ index 0000000..d95f3ad
2632
EOF
2733
'
2834

29-
test_expect_success PERL 'diff works (initial)' '
35+
test_expect_success 'diff works (initial)' '
3036
(echo d; echo 1) | git add -i >output &&
3137
sed -ne "/new file/,/content/p" <output >diff &&
3238
test_cmp expected diff
3339
'
34-
test_expect_success PERL 'revert works (initial)' '
40+
test_expect_success 'revert works (initial)' '
3541
git add file &&
3642
(echo r; echo 1) | git add -i &&
3743
git ls-files >output &&
3844
! grep . output
3945
'
4046

41-
test_expect_success PERL 'setup (commit)' '
47+
test_expect_success 'setup (commit)' '
4248
echo baseline >file &&
4349
git add file &&
4450
git commit -m commit &&
@@ -47,12 +53,12 @@ test_expect_success PERL 'setup (commit)' '
4753
echo more >>file &&
4854
echo lines >>file
4955
'
50-
test_expect_success PERL 'status works (commit)' '
56+
test_expect_success 'status works (commit)' '
5157
git add -i </dev/null >output &&
5258
grep "+1/-0 *+2/-0 file" output
5359
'
5460

55-
test_expect_success PERL 'setup expected' '
61+
test_expect_success 'setup expected' '
5662
cat >expected <<EOF
5763
index 180b47c..b6f2c08 100644
5864
--- a/file
@@ -63,37 +69,37 @@ index 180b47c..b6f2c08 100644
6369
EOF
6470
'
6571

66-
test_expect_success PERL 'diff works (commit)' '
72+
test_expect_success 'diff works (commit)' '
6773
(echo d; echo 1) | git add -i >output &&
6874
sed -ne "/^index/,/content/p" <output >diff &&
6975
test_cmp expected diff
7076
'
71-
test_expect_success PERL 'revert works (commit)' '
77+
test_expect_success 'revert works (commit)' '
7278
git add file &&
7379
(echo r; echo 1) | git add -i &&
7480
git add -i </dev/null >output &&
7581
grep "unchanged *+3/-0 file" output
7682
'
7783

7884

79-
test_expect_success PERL 'setup expected' '
85+
test_expect_success 'setup expected' '
8086
cat >expected <<EOF
8187
EOF
8288
'
8389

84-
test_expect_success PERL 'setup fake editor' '
90+
test_expect_success 'setup fake editor' '
8591
>fake_editor.sh &&
8692
chmod a+x fake_editor.sh &&
8793
test_set_editor "$(pwd)/fake_editor.sh"
8894
'
8995

90-
test_expect_success PERL 'dummy edit works' '
96+
test_expect_success 'dummy edit works' '
9197
(echo e; echo a) | git add -p &&
9298
git diff > diff &&
9399
test_cmp expected diff
94100
'
95101

96-
test_expect_success PERL 'setup patch' '
102+
test_expect_success 'setup patch' '
97103
cat >patch <<EOF
98104
@@ -1,1 +1,4 @@
99105
this
@@ -103,7 +109,7 @@ cat >patch <<EOF
103109
EOF
104110
'
105111

106-
test_expect_success PERL 'setup fake editor' '
112+
test_expect_success 'setup fake editor' '
107113
echo "#!$SHELL_PATH" >fake_editor.sh &&
108114
cat >>fake_editor.sh <<\EOF &&
109115
mv -f "$1" oldpatch &&
@@ -113,26 +119,26 @@ EOF
113119
test_set_editor "$(pwd)/fake_editor.sh"
114120
'
115121

116-
test_expect_success PERL 'bad edit rejected' '
122+
test_expect_success 'bad edit rejected' '
117123
git reset &&
118124
(echo e; echo n; echo d) | git add -p >output &&
119125
grep "hunk does not apply" output
120126
'
121127

122-
test_expect_success PERL 'setup patch' '
128+
test_expect_success 'setup patch' '
123129
cat >patch <<EOF
124130
this patch
125131
is garbage
126132
EOF
127133
'
128134

129-
test_expect_success PERL 'garbage edit rejected' '
135+
test_expect_success 'garbage edit rejected' '
130136
git reset &&
131137
(echo e; echo n; echo d) | git add -p >output &&
132138
grep "hunk does not apply" output
133139
'
134140

135-
test_expect_success PERL 'setup patch' '
141+
test_expect_success 'setup patch' '
136142
cat >patch <<EOF
137143
@@ -1,0 +1,0 @@
138144
baseline
@@ -142,7 +148,7 @@ cat >patch <<EOF
142148
EOF
143149
'
144150

145-
test_expect_success PERL 'setup expected' '
151+
test_expect_success 'setup expected' '
146152
cat >expected <<EOF
147153
diff --git a/file b/file
148154
index b5dd6c9..f910ae9 100644
@@ -157,13 +163,13 @@ index b5dd6c9..f910ae9 100644
157163
EOF
158164
'
159165

160-
test_expect_success PERL 'real edit works' '
166+
test_expect_success 'real edit works' '
161167
(echo e; echo n; echo d) | git add -p &&
162168
git diff >output &&
163169
test_cmp expected output
164170
'
165171

166-
test_expect_success PERL 'skip files similarly as commit -a' '
172+
test_expect_success 'skip files similarly as commit -a' '
167173
git reset &&
168174
echo file >.gitignore &&
169175
echo changed >file &&
@@ -177,7 +183,7 @@ test_expect_success PERL 'skip files similarly as commit -a' '
177183
'
178184
rm -f .gitignore
179185

180-
test_expect_success PERL,FILEMODE 'patch does not affect mode' '
186+
test_expect_success FILEMODE 'patch does not affect mode' '
181187
git reset --hard &&
182188
echo content >>file &&
183189
chmod +x file &&
@@ -186,7 +192,7 @@ test_expect_success PERL,FILEMODE 'patch does not affect mode' '
186192
git diff file | grep "new mode"
187193
'
188194

189-
test_expect_success PERL,FILEMODE 'stage mode but not hunk' '
195+
test_expect_success FILEMODE 'stage mode but not hunk' '
190196
git reset --hard &&
191197
echo content >>file &&
192198
chmod +x file &&
@@ -196,7 +202,7 @@ test_expect_success PERL,FILEMODE 'stage mode but not hunk' '
196202
'
197203

198204

199-
test_expect_success PERL,FILEMODE 'stage mode and hunk' '
205+
test_expect_success FILEMODE 'stage mode and hunk' '
200206
git reset --hard &&
201207
echo content >>file &&
202208
chmod +x file &&
@@ -208,14 +214,14 @@ test_expect_success PERL,FILEMODE 'stage mode and hunk' '
208214

209215
# end of tests disabled when filemode is not usable
210216

211-
test_expect_success PERL 'setup again' '
217+
test_expect_success 'setup again' '
212218
git reset --hard &&
213219
test_chmod +x file &&
214220
echo content >>file
215221
'
216222

217223
# Write the patch file with a new line at the top and bottom
218-
test_expect_success PERL 'setup patch' '
224+
test_expect_success 'setup patch' '
219225
cat >patch <<EOF
220226
index 180b47c..b6f2c08 100644
221227
--- a/file
@@ -229,7 +235,7 @@ EOF
229235
'
230236

231237
# Expected output, similar to the patch but w/ diff at the top
232-
test_expect_success PERL 'setup expected' '
238+
test_expect_success 'setup expected' '
233239
cat >expected <<EOF
234240
diff --git a/file b/file
235241
index b6f2c08..61b9053 100755
@@ -244,15 +250,15 @@ EOF
244250
'
245251

246252
# Test splitting the first patch, then adding both
247-
test_expect_success PERL 'add first line works' '
253+
test_expect_success 'add first line works' '
248254
git commit -am "clear local changes" &&
249255
git apply patch &&
250256
(echo s; echo y; echo y) | git add -p file &&
251257
git diff --cached > diff &&
252258
test_cmp expected diff
253259
'
254260

255-
test_expect_success PERL 'setup expected' '
261+
test_expect_success 'setup expected' '
256262
cat >expected <<EOF
257263
diff --git a/non-empty b/non-empty
258264
deleted file mode 100644
@@ -264,7 +270,7 @@ index d95f3ad..0000000
264270
EOF
265271
'
266272

267-
test_expect_success PERL 'deleting a non-empty file' '
273+
test_expect_success 'deleting a non-empty file' '
268274
git reset --hard &&
269275
echo content >non-empty &&
270276
git add non-empty &&
@@ -275,15 +281,15 @@ test_expect_success PERL 'deleting a non-empty file' '
275281
test_cmp expected diff
276282
'
277283

278-
test_expect_success PERL 'setup expected' '
284+
test_expect_success 'setup expected' '
279285
cat >expected <<EOF
280286
diff --git a/empty b/empty
281287
deleted file mode 100644
282288
index e69de29..0000000
283289
EOF
284290
'
285291

286-
test_expect_success PERL 'deleting an empty file' '
292+
test_expect_success 'deleting an empty file' '
287293
git reset --hard &&
288294
> empty &&
289295
git add empty &&
@@ -294,7 +300,7 @@ test_expect_success PERL 'deleting an empty file' '
294300
test_cmp expected diff
295301
'
296302

297-
test_expect_success PERL 'split hunk setup' '
303+
test_expect_success 'split hunk setup' '
298304
git reset --hard &&
299305
for i in 10 20 30 40 50 60
300306
do
@@ -310,7 +316,7 @@ test_expect_success PERL 'split hunk setup' '
310316
done >test
311317
'
312318

313-
test_expect_success PERL 'split hunk "add -p (edit)"' '
319+
test_expect_success 'split hunk "add -p (edit)"' '
314320
# Split, say Edit and do nothing. Then:
315321
#
316322
# 1. Broken version results in a patch that does not apply and

0 commit comments

Comments
 (0)