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 1b19ccd2 (2009-04-03) but switched to explicit PERL prereqs in f0459319 (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 <draenog@pld-linux.org> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Aug 24, 2013 at 13:13 UTC a070221eed679f626fc1cc0e7ea07a1a12ac4626
1 file changed +41 -35
t/t3701-add-interactive.sh
+41 -35
@@ -4,18 +4,24 @@ test_description='add -i basic tests'
4 . ./test-lib.sh
5 . "$TEST_DIRECTORY"/lib-prereq-FILEMODE.sh
6
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)' '
14 echo content >file &&
15 git add file &&
16 echo more >>file &&
17 echo lines >>file
18 '
13 -test_expect_success PERL 'status works (initial)' '
19 +test_expect_success 'status works (initial)' '
20 git add -i </dev/null >output &&
21 grep "+1/-0 *+2/-0 file" output
22 '
23
18 -test_expect_success PERL 'setup expected' '
24 +test_expect_success 'setup expected' '
25 cat >expected <<EOF
26 new file mode 100644
27 index 0000000..d95f3ad
@@ -26,19 +32,19 @@ index 0000000..d95f3ad
32 EOF
33 '
34
29 -test_expect_success PERL 'diff works (initial)' '
35 +test_expect_success 'diff works (initial)' '
36 (echo d; echo 1) | git add -i >output &&
37 sed -ne "/new file/,/content/p" <output >diff &&
38 test_cmp expected diff
39 '
34 -test_expect_success PERL 'revert works (initial)' '
40 +test_expect_success 'revert works (initial)' '
41 git add file &&
42 (echo r; echo 1) | git add -i &&
43 git ls-files >output &&
44 ! grep . output
45 '
46
41 -test_expect_success PERL 'setup (commit)' '
47 +test_expect_success 'setup (commit)' '
48 echo baseline >file &&
49 git add file &&
50 git commit -m commit &&
@@ -47,12 +53,12 @@ test_expect_success PERL 'setup (commit)' '
53 echo more >>file &&
54 echo lines >>file
55 '
50 -test_expect_success PERL 'status works (commit)' '
56 +test_expect_success 'status works (commit)' '
57 git add -i </dev/null >output &&
58 grep "+1/-0 *+2/-0 file" output
59 '
60
55 -test_expect_success PERL 'setup expected' '
61 +test_expect_success 'setup expected' '
62 cat >expected <<EOF
63 index 180b47c..b6f2c08 100644
64 --- a/file
@@ -63,12 +69,12 @@ index 180b47c..b6f2c08 100644
69 EOF
70 '
71
66 -test_expect_success PERL 'diff works (commit)' '
72 +test_expect_success 'diff works (commit)' '
73 (echo d; echo 1) | git add -i >output &&
74 sed -ne "/^index/,/content/p" <output >diff &&
75 test_cmp expected diff
76 '
71 -test_expect_success PERL 'revert works (commit)' '
77 +test_expect_success 'revert works (commit)' '
78 git add file &&
79 (echo r; echo 1) | git add -i &&
80 git add -i </dev/null >output &&
@@ -76,24 +82,24 @@ test_expect_success PERL 'revert works (commit)' '
82 '
83
84
79 -test_expect_success PERL 'setup expected' '
85 +test_expect_success 'setup expected' '
86 cat >expected <<EOF
87 EOF
88 '
89
84 -test_expect_success PERL 'setup fake editor' '
90 +test_expect_success 'setup fake editor' '
91 >fake_editor.sh &&
92 chmod a+x fake_editor.sh &&
93 test_set_editor "$(pwd)/fake_editor.sh"
94 '
95
90 -test_expect_success PERL 'dummy edit works' '
96 +test_expect_success 'dummy edit works' '
97 (echo e; echo a) | git add -p &&
98 git diff > diff &&
99 test_cmp expected diff
100 '
101
96 -test_expect_success PERL 'setup patch' '
102 +test_expect_success 'setup patch' '
103 cat >patch <<EOF
104 @@ -1,1 +1,4 @@
105 this
@@ -103,7 +109,7 @@ cat >patch <<EOF
109 EOF
110 '
111
106 -test_expect_success PERL 'setup fake editor' '
112 +test_expect_success 'setup fake editor' '
113 echo "#!$SHELL_PATH" >fake_editor.sh &&
114 cat >>fake_editor.sh <<\EOF &&
115 mv -f "$1" oldpatch &&
@@ -113,26 +119,26 @@ EOF
119 test_set_editor "$(pwd)/fake_editor.sh"
120 '
121
116 -test_expect_success PERL 'bad edit rejected' '
122 +test_expect_success 'bad edit rejected' '
123 git reset &&
124 (echo e; echo n; echo d) | git add -p >output &&
125 grep "hunk does not apply" output
126 '
127
122 -test_expect_success PERL 'setup patch' '
128 +test_expect_success 'setup patch' '
129 cat >patch <<EOF
130 this patch
131 is garbage
132 EOF
133 '
134
129 -test_expect_success PERL 'garbage edit rejected' '
135 +test_expect_success 'garbage edit rejected' '
136 git reset &&
137 (echo e; echo n; echo d) | git add -p >output &&
138 grep "hunk does not apply" output
139 '
140
135 -test_expect_success PERL 'setup patch' '
141 +test_expect_success 'setup patch' '
142 cat >patch <<EOF
143 @@ -1,0 +1,0 @@
144 baseline
@@ -142,7 +148,7 @@ cat >patch <<EOF
148 EOF
149 '
150
145 -test_expect_success PERL 'setup expected' '
151 +test_expect_success 'setup expected' '
152 cat >expected <<EOF
153 diff --git a/file b/file
154 index b5dd6c9..f910ae9 100644
@@ -157,13 +163,13 @@ index b5dd6c9..f910ae9 100644
163 EOF
164 '
165
160 -test_expect_success PERL 'real edit works' '
166 +test_expect_success 'real edit works' '
167 (echo e; echo n; echo d) | git add -p &&
168 git diff >output &&
169 test_cmp expected output
170 '
171
166 -test_expect_success PERL 'skip files similarly as commit -a' '
172 +test_expect_success 'skip files similarly as commit -a' '
173 git reset &&
174 echo file >.gitignore &&
175 echo changed >file &&
@@ -177,7 +183,7 @@ test_expect_success PERL 'skip files similarly as commit -a' '
183 '
184 rm -f .gitignore
185
180 -test_expect_success PERL,FILEMODE 'patch does not affect mode' '
186 +test_expect_success FILEMODE 'patch does not affect mode' '
187 git reset --hard &&
188 echo content >>file &&
189 chmod +x file &&
@@ -186,7 +192,7 @@ test_expect_success PERL,FILEMODE 'patch does not affect mode' '
192 git diff file | grep "new mode"
193 '
194
189 -test_expect_success PERL,FILEMODE 'stage mode but not hunk' '
195 +test_expect_success FILEMODE 'stage mode but not hunk' '
196 git reset --hard &&
197 echo content >>file &&
198 chmod +x file &&
@@ -196,7 +202,7 @@ test_expect_success PERL,FILEMODE 'stage mode but not hunk' '
202 '
203
204
199 -test_expect_success PERL,FILEMODE 'stage mode and hunk' '
205 +test_expect_success FILEMODE 'stage mode and hunk' '
206 git reset --hard &&
207 echo content >>file &&
208 chmod +x file &&
@@ -208,14 +214,14 @@ test_expect_success PERL,FILEMODE 'stage mode and hunk' '
214
215 # end of tests disabled when filemode is not usable
216
211 -test_expect_success PERL 'setup again' '
217 +test_expect_success 'setup again' '
218 git reset --hard &&
219 test_chmod +x file &&
220 echo content >>file
221 '
222
223 # 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' '
225 cat >patch <<EOF
226 index 180b47c..b6f2c08 100644
227 --- a/file
@@ -229,7 +235,7 @@ EOF
235 '
236
237 # 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' '
239 cat >expected <<EOF
240 diff --git a/file b/file
241 index b6f2c08..61b9053 100755
@@ -244,7 +250,7 @@ EOF
250 '
251
252 # 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' '
254 git commit -am "clear local changes" &&
255 git apply patch &&
256 (echo s; echo y; echo y) | git add -p file &&
@@ -252,7 +258,7 @@ test_expect_success PERL 'add first line works' '
258 test_cmp expected diff
259 '
260
255 -test_expect_success PERL 'setup expected' '
261 +test_expect_success 'setup expected' '
262 cat >expected <<EOF
263 diff --git a/non-empty b/non-empty
264 deleted file mode 100644
@@ -264,7 +270,7 @@ index d95f3ad..0000000
270 EOF
271 '
272
267 -test_expect_success PERL 'deleting a non-empty file' '
273 +test_expect_success 'deleting a non-empty file' '
274 git reset --hard &&
275 echo content >non-empty &&
276 git add non-empty &&
@@ -275,7 +281,7 @@ test_expect_success PERL 'deleting a non-empty file' '
281 test_cmp expected diff
282 '
283
278 -test_expect_success PERL 'setup expected' '
284 +test_expect_success 'setup expected' '
285 cat >expected <<EOF
286 diff --git a/empty b/empty
287 deleted file mode 100644
@@ -283,7 +289,7 @@ index e69de29..0000000
289 EOF
290 '
291
286 -test_expect_success PERL 'deleting an empty file' '
292 +test_expect_success 'deleting an empty file' '
293 git reset --hard &&
294 > empty &&
295 git add empty &&
@@ -294,7 +300,7 @@ test_expect_success PERL 'deleting an empty file' '
300 test_cmp expected diff
301 '
302
297 -test_expect_success PERL 'split hunk setup' '
303 +test_expect_success 'split hunk setup' '
304 git reset --hard &&
305 for i in 10 20 30 40 50 60
306 do
@@ -310,7 +316,7 @@ test_expect_success PERL 'split hunk setup' '
316 done >test
317 '
318
313 -test_expect_success PERL 'split hunk "add -p (edit)"' '
319 +test_expect_success 'split hunk "add -p (edit)"' '
320 # Split, say Edit and do nothing. Then:
321 #
322 # 1. Broken version results in a patch that does not apply and