@matheusbsbs / matheus-bagliano / commits / f04593199b
Fork 0

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>

Ævar Arnfjörð Bjarmason committed Aug 13, 2010 at 20:40 UTC f04593199b1e1b91687463e46ad4595280853677
1 file changed +70 -34
t/t3701-add-interactive.sh
+70 -34
@@ -4,21 +4,18 @@ test_description='add -i basic tests'
4 . ./test-lib.sh
5 . "$TEST_DIRECTORY"/lib-prereq-FILEMODE.sh
6
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)' '
8 echo content >file &&
9 git add file &&
10 echo more >>file &&
11 echo lines >>file
12 '
18 -test_expect_success 'status works (initial)' '
13 +test_expect_success PERL 'status works (initial)' '
14 git add -i </dev/null >output &&
15 grep "+1/-0 *+2/-0 file" output
16 '
17 +
18 +test_expect_success PERL 'setup expected' '
19 cat >expected <<EOF
20 new file mode 100644
21 index 0000000..d95f3ad
@@ -27,19 +24,21 @@ index 0000000..d95f3ad
24 @@ -0,0 +1 @@
25 +content
26 EOF
30 -test_expect_success 'diff works (initial)' '
27 +'
28 +
29 +test_expect_success PERL 'diff works (initial)' '
30 (echo d; echo 1) | git add -i >output &&
31 sed -ne "/new file/,/content/p" <output >diff &&
32 test_cmp expected diff
33 '
35 -test_expect_success 'revert works (initial)' '
34 +test_expect_success PERL 'revert works (initial)' '
35 git add file &&
36 (echo r; echo 1) | git add -i &&
37 git ls-files >output &&
38 ! grep . output
39 '
40
42 -test_expect_success 'setup (commit)' '
41 +test_expect_success PERL 'setup (commit)' '
42 echo baseline >file &&
43 git add file &&
44 git commit -m commit &&
@@ -48,10 +47,12 @@ test_expect_success 'setup (commit)' '
47 echo more >>file &&
48 echo lines >>file
49 '
51 -test_expect_success 'status works (commit)' '
50 +test_expect_success PERL 'status works (commit)' '
51 git add -i </dev/null >output &&
52 grep "+1/-0 *+2/-0 file" output
53 '
54 +
55 +test_expect_success PERL 'setup expected' '
56 cat >expected <<EOF
57 index 180b47c..b6f2c08 100644
58 --- a/file
@@ -60,60 +61,79 @@ index 180b47c..b6f2c08 100644
61 baseline
62 +content
63 EOF
63 -test_expect_success 'diff works (commit)' '
64 +'
65 +
66 +test_expect_success PERL 'diff works (commit)' '
67 (echo d; echo 1) | git add -i >output &&
68 sed -ne "/^index/,/content/p" <output >diff &&
69 test_cmp expected diff
70 '
68 -test_expect_success 'revert works (commit)' '
71 +test_expect_success PERL 'revert works (commit)' '
72 git add file &&
73 (echo r; echo 1) | git add -i &&
74 git add -i </dev/null >output &&
75 grep "unchanged *+3/-0 file" output
76 '
77
78 +
79 +test_expect_success PERL 'setup expected' '
80 cat >expected <<EOF
81 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' '
92 (echo e; echo a) | git add -p &&
93 git diff > diff &&
94 test_cmp expected diff
95 '
96
97 +test_expect_success PERL 'setup patch' '
98 cat >patch <<EOF
99 @@ -1,1 +1,4 @@
100 this
101 +patch
91 --doesn't
102 +-does not
103 apply
104 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 &&
110 mv -f "$1" oldpatch &&
111 mv -f patch "$1"
112 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' '
118 git reset &&
119 (echo e; echo n; echo d) | git add -p >output &&
120 grep "hunk does not apply" output
121 '
122
123 +test_expect_success PERL 'setup patch' '
124 cat >patch <<EOF
125 this patch
126 is garbage
127 EOF
111 -test_expect_success 'garbage edit rejected' '
128 +'
129 +
130 +test_expect_success PERL 'garbage edit rejected' '
131 git reset &&
132 (echo e; echo n; echo d) | git add -p >output &&
133 grep "hunk does not apply" output
134 '
135
136 +test_expect_success PERL 'setup patch' '
137 cat >patch <<EOF
138 @@ -1,0 +1,0 @@
139 baseline
@@ -121,6 +141,9 @@ cat >patch <<EOF
141 +newcontent
142 +lines
143 EOF
144 +'
145 +
146 +test_expect_success PERL 'setup expected' '
147 cat >expected <<EOF
148 diff --git a/file b/file
149 index b5dd6c9..f910ae9 100644
@@ -133,13 +156,15 @@ index b5dd6c9..f910ae9 100644
156 +more
157 lines
158 EOF
136 -test_expect_success 'real edit works' '
159 +'
160 +
161 +test_expect_success PERL 'real edit works' '
162 (echo e; echo n; echo d) | git add -p &&
163 git diff >output &&
164 test_cmp expected output
165 '
166
142 -test_expect_success 'skip files similarly as commit -a' '
167 +test_expect_success PERL 'skip files similarly as commit -a' '
168 git reset &&
169 echo file >.gitignore &&
170 echo changed >file &&
@@ -153,7 +178,7 @@ test_expect_success 'skip files similarly as commit -a' '
178 '
179 rm -f .gitignore
180
156 -test_expect_success FILEMODE 'patch does not affect mode' '
181 +test_expect_success PERL,FILEMODE 'patch does not affect mode' '
182 git reset --hard &&
183 echo content >>file &&
184 chmod +x file &&
@@ -162,7 +187,7 @@ test_expect_success FILEMODE 'patch does not affect mode' '
187 git diff file | grep "new mode"
188 '
189
165 -test_expect_success FILEMODE 'stage mode but not hunk' '
190 +test_expect_success PERL,FILEMODE 'stage mode but not hunk' '
191 git reset --hard &&
192 echo content >>file &&
193 chmod +x file &&
@@ -172,7 +197,7 @@ test_expect_success FILEMODE 'stage mode but not hunk' '
197 '
198
199
175 -test_expect_success FILEMODE 'stage mode and hunk' '
200 +test_expect_success PERL,FILEMODE 'stage mode and hunk' '
201 git reset --hard &&
202 echo content >>file &&
203 chmod +x file &&
@@ -184,13 +209,14 @@ test_expect_success FILEMODE 'stage mode and hunk' '
209
210 # end of tests disabled when filemode is not usable
211
187 -test_expect_success 'setup again' '
212 +test_expect_success PERL 'setup again' '
213 git reset --hard &&
214 test_chmod +x file &&
215 echo content >>file
216 '
217
218 # Write the patch file with a new line at the top and bottom
219 +test_expect_success PERL 'setup patch' '
220 cat >patch <<EOF
221 index 180b47c..b6f2c08 100644
222 --- a/file
@@ -201,7 +227,10 @@ index 180b47c..b6f2c08 100644
227 content
228 +lastline
229 EOF
230 +'
231 +
232 # Expected output, similar to the patch but w/ diff at the top
233 +test_expect_success PERL 'setup expected' '
234 cat >expected <<EOF
235 diff --git a/file b/file
236 index b6f2c08..61b9053 100755
@@ -213,8 +242,10 @@ index b6f2c08..61b9053 100755
242 content
243 +lastline
244 EOF
245 +'
246 +
247 # 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' '
249 git commit -am "clear local changes" &&
250 git apply patch &&
251 (echo s; echo y; echo y) | git add -p file &&
@@ -222,6 +253,7 @@ test_expect_success 'add first line works' '
253 test_cmp expected diff
254 '
255
256 +test_expect_success PERL 'setup expected' '
257 cat >expected <<EOF
258 diff --git a/non-empty b/non-empty
259 deleted file mode 100644
@@ -231,7 +263,9 @@ index d95f3ad..0000000
263 @@ -1 +0,0 @@
264 -content
265 EOF
234 -test_expect_success 'deleting a non-empty file' '
266 +'
267 +
268 +test_expect_success PERL 'deleting a non-empty file' '
269 git reset --hard &&
270 echo content >non-empty &&
271 git add non-empty &&
@@ -242,13 +276,15 @@ test_expect_success 'deleting a non-empty file' '
276 test_cmp expected diff
277 '
278
279 +test_expect_success PERL 'setup expected' '
280 cat >expected <<EOF
281 diff --git a/empty b/empty
282 deleted file mode 100644
283 index e69de29..0000000
284 EOF
285 +'
286
251 -test_expect_success 'deleting an empty file' '
287 +test_expect_success PERL 'deleting an empty file' '
288 git reset --hard &&
289 > empty &&
290 git add empty &&