Merge branch 'jl/zlib-restore-nul-termination'
[git/debian.git] / t / t7301-clean-interactive.sh
blob1bf9789c8a3cfbb1cc8a6ea33e4a0b1a0da0a7cd
1 #!/bin/sh
3 test_description='git clean -i basic tests'
5 . ./test-lib.sh
6 . "$TEST_DIRECTORY"/lib-terminal.sh
8 test_expect_success 'setup' '
10 mkdir -p src &&
11 touch src/part1.c Makefile &&
12 echo build >.gitignore &&
13 echo \*.o >>.gitignore &&
14 git add . &&
15 git commit -m setup &&
16 touch src/part2.c README &&
17 git add .
21 test_expect_success 'git clean -i (c: clean hotkey)' '
23 mkdir -p build docs &&
24 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
25 docs/manual.txt obj.o build/lib.so &&
26 echo c | git clean -i &&
27 test -f Makefile &&
28 test -f README &&
29 test -f src/part1.c &&
30 test -f src/part2.c &&
31 test ! -f a.out &&
32 test -f docs/manual.txt &&
33 test ! -f src/part3.c &&
34 test ! -f src/part3.h &&
35 test ! -f src/part4.c &&
36 test ! -f src/part4.h &&
37 test -f obj.o &&
38 test -f build/lib.so
42 test_expect_success 'git clean -i (cl: clean prefix)' '
44 mkdir -p build docs &&
45 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
46 docs/manual.txt obj.o build/lib.so &&
47 echo cl | git clean -i &&
48 test -f Makefile &&
49 test -f README &&
50 test -f src/part1.c &&
51 test -f src/part2.c &&
52 test ! -f a.out &&
53 test -f docs/manual.txt &&
54 test ! -f src/part3.c &&
55 test ! -f src/part3.h &&
56 test ! -f src/part4.c &&
57 test ! -f src/part4.h &&
58 test -f obj.o &&
59 test -f build/lib.so
63 test_expect_success 'git clean -i (quit)' '
65 mkdir -p build docs &&
66 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
67 docs/manual.txt obj.o build/lib.so &&
68 echo quit | git clean -i &&
69 test -f Makefile &&
70 test -f README &&
71 test -f src/part1.c &&
72 test -f src/part2.c &&
73 test -f a.out &&
74 test -f docs/manual.txt &&
75 test -f src/part3.c &&
76 test -f src/part3.h &&
77 test -f src/part4.c &&
78 test -f src/part4.h &&
79 test -f obj.o &&
80 test -f build/lib.so
84 test_expect_success 'git clean -i (Ctrl+D)' '
86 mkdir -p build docs &&
87 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
88 docs/manual.txt obj.o build/lib.so &&
89 echo "\04" | git clean -i &&
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 all)' '
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 "*"; 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)' '
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 "part3.* *.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 (filter patterns 2)' '
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 f; echo "* !*.out"; 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 - all)' '
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; 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 - none)' '
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; 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)' '
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 3; 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 2)' '
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 2 3; echo 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 - number 3)' '
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 3,4 5; 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 docs/manual.txt &&
272 test ! -f src/part3.c &&
273 test ! -f src/part3.h &&
274 test ! -f src/part4.c &&
275 test -f src/part4.h &&
276 test -f obj.o &&
277 test -f build/lib.so
281 test_expect_success 'git clean -id (select - filenames)' '
283 mkdir -p build docs &&
284 touch a.out foo.txt bar.txt baz.txt &&
285 (echo s; echo a.out fo ba bar; echo; echo c) | \
286 git clean -id &&
287 test -f Makefile &&
288 test ! -f a.out &&
289 test ! -f foo.txt &&
290 test ! -f bar.txt &&
291 test -f baz.txt &&
292 rm baz.txt
296 test_expect_success 'git clean -id (select - range)' '
298 mkdir -p build docs &&
299 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
300 docs/manual.txt obj.o build/lib.so &&
301 (echo s; echo 1,3-4; echo 2; echo; echo c) | \
302 git clean -id &&
303 test -f Makefile &&
304 test -f README &&
305 test -f src/part1.c &&
306 test -f src/part2.c &&
307 test ! -f a.out &&
308 test ! -f src/part3.c &&
309 test ! -f src/part3.h &&
310 test -f src/part4.c &&
311 test -f src/part4.h &&
312 test ! -f docs/manual.txt &&
313 test -f obj.o &&
314 test -f build/lib.so
318 test_expect_success 'git clean -id (select - range 2)' '
320 mkdir -p build docs &&
321 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
322 docs/manual.txt obj.o build/lib.so &&
323 (echo s; echo 4- 1; echo; echo c) | \
324 git clean -id &&
325 test -f Makefile &&
326 test -f README &&
327 test -f src/part1.c &&
328 test -f src/part2.c &&
329 test ! -f a.out &&
330 test -f docs/manual.txt &&
331 test -f src/part3.c &&
332 test ! -f src/part3.h &&
333 test ! -f src/part4.c &&
334 test ! -f src/part4.h &&
335 test -f obj.o &&
336 test -f build/lib.so
340 test_expect_success 'git clean -id (inverse select)' '
342 mkdir -p build docs &&
343 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
344 docs/manual.txt obj.o build/lib.so &&
345 (echo s; echo "*"; echo -5- 1 -2; echo; echo c) | \
346 git clean -id &&
347 test -f Makefile &&
348 test -f README &&
349 test -f src/part1.c &&
350 test -f src/part2.c &&
351 test ! -f a.out &&
352 test -f docs/manual.txt &&
353 test ! -f src/part3.c &&
354 test ! -f src/part3.h &&
355 test -f src/part4.c &&
356 test -f src/part4.h &&
357 test -f obj.o &&
358 test -f build/lib.so
362 test_expect_success 'git clean -id (ask)' '
364 mkdir -p build docs &&
365 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
366 docs/manual.txt obj.o build/lib.so &&
367 (echo a; echo Y; echo y; echo no; echo yes; echo bad; echo) | \
368 git clean -id &&
369 test -f Makefile &&
370 test -f README &&
371 test -f src/part1.c &&
372 test -f src/part2.c &&
373 test ! -f a.out &&
374 test ! -f docs/manual.txt &&
375 test -f src/part3.c &&
376 test ! -f src/part3.h &&
377 test -f src/part4.c &&
378 test -f src/part4.h &&
379 test -f obj.o &&
380 test -f build/lib.so
384 test_expect_success 'git clean -id (ask - Ctrl+D)' '
386 mkdir -p build docs &&
387 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
388 docs/manual.txt obj.o build/lib.so &&
389 (echo a; echo Y; echo no; echo yes; echo "\04") | \
390 git clean -id &&
391 test -f Makefile &&
392 test -f README &&
393 test -f src/part1.c &&
394 test -f src/part2.c &&
395 test ! -f a.out &&
396 test -f docs/manual.txt &&
397 test ! -f src/part3.c &&
398 test -f src/part3.h &&
399 test -f src/part4.c &&
400 test -f src/part4.h &&
401 test -f obj.o &&
402 test -f build/lib.so
406 test_expect_success 'git clean -id with prefix and path (filter)' '
408 mkdir -p build docs &&
409 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
410 docs/manual.txt obj.o build/lib.so &&
411 (cd build/ && \
412 (echo f; echo "docs"; echo "*.h"; echo ; echo c) | \
413 git clean -id ..) &&
414 test -f Makefile &&
415 test -f README &&
416 test -f src/part1.c &&
417 test -f src/part2.c &&
418 test ! -f a.out &&
419 test -f docs/manual.txt &&
420 test ! -f src/part3.c &&
421 test -f src/part3.h &&
422 test ! -f src/part4.c &&
423 test -f src/part4.h &&
424 test -f obj.o &&
425 test -f build/lib.so
429 test_expect_success 'git clean -id with prefix and path (select by name)' '
431 mkdir -p build docs &&
432 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
433 docs/manual.txt obj.o build/lib.so &&
434 (cd build/ && \
435 (echo s; echo "../docs/"; echo "../src/part3.c"; \
436 echo "../src/part4.c"; echo; echo c) | \
437 git clean -id ..) &&
438 test -f Makefile &&
439 test -f README &&
440 test -f src/part1.c &&
441 test -f src/part2.c &&
442 test -f a.out &&
443 test ! -f docs/manual.txt &&
444 test ! -f src/part3.c &&
445 test -f src/part3.h &&
446 test ! -f src/part4.c &&
447 test -f src/part4.h &&
448 test -f obj.o &&
449 test -f build/lib.so
453 test_expect_success 'git clean -id with prefix and path (ask)' '
455 mkdir -p build docs &&
456 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
457 docs/manual.txt obj.o build/lib.so &&
458 (cd build/ && \
459 (echo a; echo Y; echo y; echo no; echo yes; echo bad; echo) | \
460 git clean -id ..) &&
461 test -f Makefile &&
462 test -f README &&
463 test -f src/part1.c &&
464 test -f src/part2.c &&
465 test ! -f a.out &&
466 test ! -f docs/manual.txt &&
467 test -f src/part3.c &&
468 test ! -f src/part3.h &&
469 test -f src/part4.c &&
470 test -f src/part4.h &&
471 test -f obj.o &&
472 test -f build/lib.so
476 test_expect_success TTY 'git clean -i paints the header in HEADER color' '
477 >a.out &&
478 echo q |
479 test_terminal git clean -i |
480 test_decode_color |
481 head -n 1 >header &&
482 # not i18ngrep
483 grep "^<BOLD>" header
486 test_done