Skip to content

Commit f045931

Browse files
avargitster
authored andcommitted
t/t3701-add-interactive.sh: change from skip_all=* to prereq skip
Change this test to skip test with test prerequisites, and to do setup work in tests. This improves the skipped statistics on platforms where the test isn't run. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 535d974 commit f045931

File tree

1 file changed

+70
-34
lines changed

1 file changed

+70
-34
lines changed

t/t3701-add-interactive.sh

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

7-
if ! test_have_prereq PERL; then
8-
skip_all='skipping git add -i tests, perl not available'
9-
test_done
10-
fi
11-
12-
test_expect_success 'setup (initial)' '
7+
test_expect_success PERL 'setup (initial)' '
138
echo content >file &&
149
git add file &&
1510
echo more >>file &&
1611
echo lines >>file
1712
'
18-
test_expect_success 'status works (initial)' '
13+
test_expect_success PERL 'status works (initial)' '
1914
git add -i </dev/null >output &&
2015
grep "+1/-0 *+2/-0 file" output
2116
'
17+
18+
test_expect_success PERL 'setup expected' '
2219
cat >expected <<EOF
2320
new file mode 100644
2421
index 0000000..d95f3ad
@@ -27,19 +24,21 @@ index 0000000..d95f3ad
2724
@@ -0,0 +1 @@
2825
+content
2926
EOF
30-
test_expect_success 'diff works (initial)' '
27+
'
28+
29+
test_expect_success PERL 'diff works (initial)' '
3130
(echo d; echo 1) | git add -i >output &&
3231
sed -ne "/new file/,/content/p" <output >diff &&
3332
test_cmp expected diff
3433
'
35-
test_expect_success 'revert works (initial)' '
34+
test_expect_success PERL 'revert works (initial)' '
3635
git add file &&
3736
(echo r; echo 1) | git add -i &&
3837
git ls-files >output &&
3938
! grep . output
4039
'
4140

42-
test_expect_success 'setup (commit)' '
41+
test_expect_success PERL 'setup (commit)' '
4342
echo baseline >file &&
4443
git add file &&
4544
git commit -m commit &&
@@ -48,10 +47,12 @@ test_expect_success 'setup (commit)' '
4847
echo more >>file &&
4948
echo lines >>file
5049
'
51-
test_expect_success 'status works (commit)' '
50+
test_expect_success PERL 'status works (commit)' '
5251
git add -i </dev/null >output &&
5352
grep "+1/-0 *+2/-0 file" output
5453
'
54+
55+
test_expect_success PERL 'setup expected' '
5556
cat >expected <<EOF
5657
index 180b47c..b6f2c08 100644
5758
--- a/file
@@ -60,67 +61,89 @@ index 180b47c..b6f2c08 100644
6061
baseline
6162
+content
6263
EOF
63-
test_expect_success 'diff works (commit)' '
64+
'
65+
66+
test_expect_success PERL 'diff works (commit)' '
6467
(echo d; echo 1) | git add -i >output &&
6568
sed -ne "/^index/,/content/p" <output >diff &&
6669
test_cmp expected diff
6770
'
68-
test_expect_success 'revert works (commit)' '
71+
test_expect_success PERL 'revert works (commit)' '
6972
git add file &&
7073
(echo r; echo 1) | git add -i &&
7174
git add -i </dev/null >output &&
7275
grep "unchanged *+3/-0 file" output
7376
'
7477

78+
79+
test_expect_success PERL 'setup expected' '
7580
cat >expected <<EOF
7681
EOF
77-
cat >fake_editor.sh <<EOF
78-
EOF
79-
chmod a+x fake_editor.sh
80-
test_set_editor "$(pwd)/fake_editor.sh"
81-
test_expect_success 'dummy edit works' '
82+
'
83+
84+
test_expect_success PERL 'setup fake editor' '
85+
cat >fake_editor.sh <<EOF
86+
EOF
87+
chmod a+x fake_editor.sh &&
88+
test_set_editor "$(pwd)/fake_editor.sh" &&
89+
'
90+
91+
test_expect_success PERL 'dummy edit works' '
8292
(echo e; echo a) | git add -p &&
8393
git diff > diff &&
8494
test_cmp expected diff
8595
'
8696

97+
test_expect_success PERL 'setup patch' '
8798
cat >patch <<EOF
8899
@@ -1,1 +1,4 @@
89100
this
90101
+patch
91-
-doesn't
102+
-does not
92103
apply
93104
EOF
94-
echo "#!$SHELL_PATH" >fake_editor.sh
95-
cat >>fake_editor.sh <<\EOF
105+
'
106+
107+
test_expect_success PERL 'setup fake editor' '
108+
echo "#!$SHELL_PATH" >fake_editor.sh &&
109+
cat >>fake_editor.sh <<\EOF &&
96110
mv -f "$1" oldpatch &&
97111
mv -f patch "$1"
98112
EOF
99-
chmod a+x fake_editor.sh
100-
test_set_editor "$(pwd)/fake_editor.sh"
101-
test_expect_success 'bad edit rejected' '
113+
chmod a+x fake_editor.sh &&
114+
test_set_editor "$(pwd)/fake_editor.sh"
115+
'
116+
117+
test_expect_success PERL 'bad edit rejected' '
102118
git reset &&
103119
(echo e; echo n; echo d) | git add -p >output &&
104120
grep "hunk does not apply" output
105121
'
106122

123+
test_expect_success PERL 'setup patch' '
107124
cat >patch <<EOF
108125
this patch
109126
is garbage
110127
EOF
111-
test_expect_success 'garbage edit rejected' '
128+
'
129+
130+
test_expect_success PERL 'garbage edit rejected' '
112131
git reset &&
113132
(echo e; echo n; echo d) | git add -p >output &&
114133
grep "hunk does not apply" output
115134
'
116135

136+
test_expect_success PERL 'setup patch' '
117137
cat >patch <<EOF
118138
@@ -1,0 +1,0 @@
119139
baseline
120140
+content
121141
+newcontent
122142
+lines
123143
EOF
144+
'
145+
146+
test_expect_success PERL 'setup expected' '
124147
cat >expected <<EOF
125148
diff --git a/file b/file
126149
index b5dd6c9..f910ae9 100644
@@ -133,13 +156,15 @@ index b5dd6c9..f910ae9 100644
133156
+more
134157
lines
135158
EOF
136-
test_expect_success 'real edit works' '
159+
'
160+
161+
test_expect_success PERL 'real edit works' '
137162
(echo e; echo n; echo d) | git add -p &&
138163
git diff >output &&
139164
test_cmp expected output
140165
'
141166

142-
test_expect_success 'skip files similarly as commit -a' '
167+
test_expect_success PERL 'skip files similarly as commit -a' '
143168
git reset &&
144169
echo file >.gitignore &&
145170
echo changed >file &&
@@ -153,7 +178,7 @@ test_expect_success 'skip files similarly as commit -a' '
153178
'
154179
rm -f .gitignore
155180

156-
test_expect_success FILEMODE 'patch does not affect mode' '
181+
test_expect_success PERL,FILEMODE 'patch does not affect mode' '
157182
git reset --hard &&
158183
echo content >>file &&
159184
chmod +x file &&
@@ -162,7 +187,7 @@ test_expect_success FILEMODE 'patch does not affect mode' '
162187
git diff file | grep "new mode"
163188
'
164189

165-
test_expect_success FILEMODE 'stage mode but not hunk' '
190+
test_expect_success PERL,FILEMODE 'stage mode but not hunk' '
166191
git reset --hard &&
167192
echo content >>file &&
168193
chmod +x file &&
@@ -172,7 +197,7 @@ test_expect_success FILEMODE 'stage mode but not hunk' '
172197
'
173198

174199

175-
test_expect_success FILEMODE 'stage mode and hunk' '
200+
test_expect_success PERL,FILEMODE 'stage mode and hunk' '
176201
git reset --hard &&
177202
echo content >>file &&
178203
chmod +x file &&
@@ -184,13 +209,14 @@ test_expect_success FILEMODE 'stage mode and hunk' '
184209

185210
# end of tests disabled when filemode is not usable
186211

187-
test_expect_success 'setup again' '
212+
test_expect_success PERL 'setup again' '
188213
git reset --hard &&
189214
test_chmod +x file &&
190215
echo content >>file
191216
'
192217

193218
# Write the patch file with a new line at the top and bottom
219+
test_expect_success PERL 'setup patch' '
194220
cat >patch <<EOF
195221
index 180b47c..b6f2c08 100644
196222
--- a/file
@@ -201,7 +227,10 @@ index 180b47c..b6f2c08 100644
201227
content
202228
+lastline
203229
EOF
230+
'
231+
204232
# Expected output, similar to the patch but w/ diff at the top
233+
test_expect_success PERL 'setup expected' '
205234
cat >expected <<EOF
206235
diff --git a/file b/file
207236
index b6f2c08..61b9053 100755
@@ -213,15 +242,18 @@ index b6f2c08..61b9053 100755
213242
content
214243
+lastline
215244
EOF
245+
'
246+
216247
# Test splitting the first patch, then adding both
217-
test_expect_success 'add first line works' '
248+
test_expect_success PERL 'add first line works' '
218249
git commit -am "clear local changes" &&
219250
git apply patch &&
220251
(echo s; echo y; echo y) | git add -p file &&
221252
git diff --cached > diff &&
222253
test_cmp expected diff
223254
'
224255

256+
test_expect_success PERL 'setup expected' '
225257
cat >expected <<EOF
226258
diff --git a/non-empty b/non-empty
227259
deleted file mode 100644
@@ -231,7 +263,9 @@ index d95f3ad..0000000
231263
@@ -1 +0,0 @@
232264
-content
233265
EOF
234-
test_expect_success 'deleting a non-empty file' '
266+
'
267+
268+
test_expect_success PERL 'deleting a non-empty file' '
235269
git reset --hard &&
236270
echo content >non-empty &&
237271
git add non-empty &&
@@ -242,13 +276,15 @@ test_expect_success 'deleting a non-empty file' '
242276
test_cmp expected diff
243277
'
244278

279+
test_expect_success PERL 'setup expected' '
245280
cat >expected <<EOF
246281
diff --git a/empty b/empty
247282
deleted file mode 100644
248283
index e69de29..0000000
249284
EOF
285+
'
250286

251-
test_expect_success 'deleting an empty file' '
287+
test_expect_success PERL 'deleting an empty file' '
252288
git reset --hard &&
253289
> empty &&
254290
git add empty &&

0 commit comments

Comments
 (0)