test: add t7301 for git-clean--interactive
[git/mingw.git] / t / t7301-clean-interactive.sh
blob4e6055d06af2042e6bc6c1467d58680668c12881
1 #!/bin/sh
3 test_description='git clean -i basic tests'
5 . ./test-lib.sh
7 test_expect_success 'setup' '
9 mkdir -p src &&
10 touch src/part1.c Makefile &&
11 echo build >.gitignore &&
12 echo \*.o >>.gitignore &&
13 git add . &&
14 git commit -m setup &&
15 touch src/part2.c README &&
16 git add .
20 test_expect_success 'git clean -i (clean)' '
22 mkdir -p build docs &&
23 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
24 docs/manual.txt obj.o build/lib.so &&
25 echo c | git clean -i &&
26 test -f Makefile &&
27 test -f README &&
28 test -f src/part1.c &&
29 test -f src/part2.c &&
30 test ! -f a.out &&
31 test -f docs/manual.txt &&
32 test ! -f src/part3.c &&
33 test ! -f src/part3.h &&
34 test ! -f src/part4.c &&
35 test ! -f src/part4.h &&
36 test -f obj.o &&
37 test -f build/lib.so
41 test_expect_success 'git clean -i (quit)' '
43 mkdir -p build docs &&
44 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
45 docs/manual.txt obj.o build/lib.so &&
46 echo q | git clean -i &&
47 test -f Makefile &&
48 test -f README &&
49 test -f src/part1.c &&
50 test -f src/part2.c &&
51 test -f a.out &&
52 test -f docs/manual.txt &&
53 test -f src/part3.c &&
54 test -f src/part3.h &&
55 test -f src/part4.c &&
56 test -f src/part4.h &&
57 test -f obj.o &&
58 test -f build/lib.so
62 test_expect_success 'git clean -i (Ctrl+D)' '
64 mkdir -p build docs &&
65 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
66 docs/manual.txt obj.o build/lib.so &&
67 echo "\04" | git clean -i &&
68 test -f Makefile &&
69 test -f README &&
70 test -f src/part1.c &&
71 test -f src/part2.c &&
72 test -f a.out &&
73 test -f docs/manual.txt &&
74 test -f src/part3.c &&
75 test -f src/part3.h &&
76 test -f src/part4.c &&
77 test -f src/part4.h &&
78 test -f obj.o &&
79 test -f build/lib.so
83 test_expect_success 'git clean -id (filter all)' '
85 mkdir -p build docs &&
86 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
87 docs/manual.txt obj.o build/lib.so &&
88 (echo f; echo "*"; echo; echo c) | \
89 git clean -id &&
90 test -f Makefile &&
91 test -f README &&
92 test -f src/part1.c &&
93 test -f src/part2.c &&
94 test -f a.out &&
95 test -f docs/manual.txt &&
96 test -f src/part3.c &&
97 test -f src/part3.h &&
98 test -f src/part4.c &&
99 test -f src/part4.h &&
100 test -f obj.o &&
101 test -f build/lib.so
105 test_expect_success 'git clean -id (filter patterns)' '
107 mkdir -p build docs &&
108 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
109 docs/manual.txt obj.o build/lib.so &&
110 (echo f; echo "part3.* *.out"; echo; echo c) | \
111 git clean -id &&
112 test -f Makefile &&
113 test -f README &&
114 test -f src/part1.c &&
115 test -f src/part2.c &&
116 test -f a.out &&
117 test ! -f docs/manual.txt &&
118 test -f src/part3.c &&
119 test -f src/part3.h &&
120 test ! -f src/part4.c &&
121 test ! -f src/part4.h &&
122 test -f obj.o &&
123 test -f build/lib.so
127 test_expect_success 'git clean -id (filter patterns 2)' '
129 mkdir -p build docs &&
130 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
131 docs/manual.txt obj.o build/lib.so &&
132 (echo f; echo "* !*.out"; echo; echo c) | \
133 git clean -id &&
134 test -f Makefile &&
135 test -f README &&
136 test -f src/part1.c &&
137 test -f src/part2.c &&
138 test ! -f a.out &&
139 test -f docs/manual.txt &&
140 test -f src/part3.c &&
141 test -f src/part3.h &&
142 test -f src/part4.c &&
143 test -f src/part4.h &&
144 test -f obj.o &&
145 test -f build/lib.so
149 test_expect_success 'git clean -id (select - all)' '
151 mkdir -p build docs &&
152 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
153 docs/manual.txt obj.o build/lib.so &&
154 (echo s; echo "*"; echo; echo c) | \
155 git clean -id &&
156 test -f Makefile &&
157 test -f README &&
158 test -f src/part1.c &&
159 test -f src/part2.c &&
160 test ! -f a.out &&
161 test ! -f docs/manual.txt &&
162 test ! -f src/part3.c &&
163 test ! -f src/part3.h &&
164 test ! -f src/part4.c &&
165 test ! -f src/part4.h &&
166 test -f obj.o &&
167 test -f build/lib.so
171 test_expect_success 'git clean -id (select - none)' '
173 mkdir -p build docs &&
174 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
175 docs/manual.txt obj.o build/lib.so &&
176 (echo s; echo; echo c) | \
177 git clean -id &&
178 test -f Makefile &&
179 test -f README &&
180 test -f src/part1.c &&
181 test -f src/part2.c &&
182 test -f a.out &&
183 test -f docs/manual.txt &&
184 test -f src/part3.c &&
185 test -f src/part3.h &&
186 test -f src/part4.c &&
187 test -f src/part4.h &&
188 test -f obj.o &&
189 test -f build/lib.so
193 test_expect_success 'git clean -id (select - number)' '
195 mkdir -p build docs &&
196 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
197 docs/manual.txt obj.o build/lib.so &&
198 (echo s; echo 3; echo; echo c) | \
199 git clean -id &&
200 test -f Makefile &&
201 test -f README &&
202 test -f src/part1.c &&
203 test -f src/part2.c &&
204 test -f a.out &&
205 test -f docs/manual.txt &&
206 test ! -f src/part3.c &&
207 test -f src/part3.h &&
208 test -f src/part4.c &&
209 test -f src/part4.h &&
210 test -f obj.o &&
211 test -f build/lib.so
215 test_expect_success 'git clean -id (select - number 2)' '
217 mkdir -p build docs &&
218 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
219 docs/manual.txt obj.o build/lib.so &&
220 (echo s; echo 2 3; echo 5; echo; echo c) | \
221 git clean -id &&
222 test -f Makefile &&
223 test -f README &&
224 test -f src/part1.c &&
225 test -f src/part2.c &&
226 test -f a.out &&
227 test ! -f docs/manual.txt &&
228 test ! -f src/part3.c &&
229 test -f src/part3.h &&
230 test ! -f src/part4.c &&
231 test -f src/part4.h &&
232 test -f obj.o &&
233 test -f build/lib.so
237 test_expect_success 'git clean -id (select - number 3)' '
239 mkdir -p build docs &&
240 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
241 docs/manual.txt obj.o build/lib.so &&
242 (echo s; echo 3,4 5; echo; echo c) | \
243 git clean -id &&
244 test -f Makefile &&
245 test -f README &&
246 test -f src/part1.c &&
247 test -f src/part2.c &&
248 test -f a.out &&
249 test -f docs/manual.txt &&
250 test ! -f src/part3.c &&
251 test ! -f src/part3.h &&
252 test ! -f src/part4.c &&
253 test -f src/part4.h &&
254 test -f obj.o &&
255 test -f build/lib.so
259 test_expect_success 'git clean -id (select - range)' '
261 mkdir -p build docs &&
262 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
263 docs/manual.txt obj.o build/lib.so &&
264 (echo s; echo 1,3-4; echo 2; echo; echo c) | \
265 git clean -id &&
266 test -f Makefile &&
267 test -f README &&
268 test -f src/part1.c &&
269 test -f src/part2.c &&
270 test ! -f a.out &&
271 test ! -f src/part3.c &&
272 test ! -f src/part3.h &&
273 test -f src/part4.c &&
274 test -f src/part4.h &&
275 test ! -f docs/manual.txt &&
276 test -f obj.o &&
277 test -f build/lib.so
281 test_expect_success 'git clean -id (select - range 2)' '
283 mkdir -p build docs &&
284 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
285 docs/manual.txt obj.o build/lib.so &&
286 (echo s; echo 4- 1; echo; echo c) | \
287 git clean -id &&
288 test -f Makefile &&
289 test -f README &&
290 test -f src/part1.c &&
291 test -f src/part2.c &&
292 test ! -f a.out &&
293 test -f docs/manual.txt &&
294 test -f src/part3.c &&
295 test ! -f src/part3.h &&
296 test ! -f src/part4.c &&
297 test ! -f src/part4.h &&
298 test -f obj.o &&
299 test -f build/lib.so
303 test_expect_success 'git clean -id (inverse select)' '
305 mkdir -p build docs &&
306 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
307 docs/manual.txt obj.o build/lib.so &&
308 (echo s; echo "*"; echo -5- 1 -2; echo; echo c) | \
309 git clean -id &&
310 test -f Makefile &&
311 test -f README &&
312 test -f src/part1.c &&
313 test -f src/part2.c &&
314 test ! -f a.out &&
315 test -f docs/manual.txt &&
316 test ! -f src/part3.c &&
317 test ! -f src/part3.h &&
318 test -f src/part4.c &&
319 test -f src/part4.h &&
320 test -f obj.o &&
321 test -f build/lib.so
325 test_expect_success 'git clean -id (ask)' '
327 mkdir -p build docs &&
328 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
329 docs/manual.txt obj.o build/lib.so &&
330 (echo a; echo Y; echo y; echo no; echo yes; echo bad; echo) | \
331 git clean -id &&
332 test -f Makefile &&
333 test -f README &&
334 test -f src/part1.c &&
335 test -f src/part2.c &&
336 test ! -f a.out &&
337 test ! -f docs/manual.txt &&
338 test -f src/part3.c &&
339 test ! -f src/part3.h &&
340 test -f src/part4.c &&
341 test -f src/part4.h &&
342 test -f obj.o &&
343 test -f build/lib.so
347 test_expect_success 'git clean -id (ask - Ctrl+D)' '
349 mkdir -p build docs &&
350 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
351 docs/manual.txt obj.o build/lib.so &&
352 (echo a; echo Y; echo no; echo yes; echo "\04") | \
353 git clean -id &&
354 test -f Makefile &&
355 test -f README &&
356 test -f src/part1.c &&
357 test -f src/part2.c &&
358 test ! -f a.out &&
359 test -f docs/manual.txt &&
360 test ! -f src/part3.c &&
361 test -f src/part3.h &&
362 test -f src/part4.c &&
363 test -f src/part4.h &&
364 test -f obj.o &&
365 test -f build/lib.so
369 test_expect_success 'git clean -id with prefix and path (filter)' '
371 mkdir -p build docs &&
372 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
373 docs/manual.txt obj.o build/lib.so &&
374 (cd build/ && \
375 (echo f; echo "docs"; echo "*.h"; echo ; echo c) | \
376 git clean -id ..) &&
377 test -f Makefile &&
378 test -f README &&
379 test -f src/part1.c &&
380 test -f src/part2.c &&
381 test ! -f a.out &&
382 test -f docs/manual.txt &&
383 test ! -f src/part3.c &&
384 test -f src/part3.h &&
385 test ! -f src/part4.c &&
386 test -f src/part4.h &&
387 test -f obj.o &&
388 test -f build/lib.so
392 test_expect_success 'git clean -id with prefix and path (select by name)' '
394 mkdir -p build docs &&
395 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
396 docs/manual.txt obj.o build/lib.so &&
397 (cd build/ && \
398 (echo s; echo "../docs/"; echo "../src/part3.c"; \
399 echo "../src/part4.c"; echo; echo c) | \
400 git clean -id ..) &&
401 test -f Makefile &&
402 test -f README &&
403 test -f src/part1.c &&
404 test -f src/part2.c &&
405 test -f a.out &&
406 test ! -f docs/manual.txt &&
407 test ! -f src/part3.c &&
408 test -f src/part3.h &&
409 test ! -f src/part4.c &&
410 test -f src/part4.h &&
411 test -f obj.o &&
412 test -f build/lib.so
416 test_expect_success 'git clean -id with prefix and path (ask)' '
418 mkdir -p build docs &&
419 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
420 docs/manual.txt obj.o build/lib.so &&
421 (cd build/ && \
422 (echo a; echo Y; echo y; echo no; echo yes; echo bad; echo) | \
423 git clean -id ..) &&
424 test -f Makefile &&
425 test -f README &&
426 test -f src/part1.c &&
427 test -f src/part2.c &&
428 test ! -f a.out &&
429 test ! -f docs/manual.txt &&
430 test -f src/part3.c &&
431 test ! -f src/part3.h &&
432 test -f src/part4.c &&
433 test -f src/part4.h &&
434 test -f obj.o &&
435 test -f build/lib.so
439 test_done