#!/bin/sh global test_description := ''git clean -i basic tests'' source ./test-lib.sh test_expect_success 'setup' ' mkdir -p src && touch src/part1.c Makefile && echo build >.gitignore && echo \*.o >>.gitignore && git add . && git commit -m setup && touch src/part2.c README && git add . ' test_expect_success 'git clean -i (c: clean hotkey)' ' mkdir -p build docs && touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \ docs/manual.txt obj.o build/lib.so && echo c | git clean -i && test -f Makefile && test -f README && test -f src/part1.c && test -f src/part2.c && test ! -f a.out && test -f docs/manual.txt && test ! -f src/part3.c && test ! -f src/part3.h && test ! -f src/part4.c && test ! -f src/part4.h && test -f obj.o && test -f build/lib.so ' test_expect_success 'git clean -i (cl: clean prefix)' ' mkdir -p build docs && touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \ docs/manual.txt obj.o build/lib.so && echo cl | git clean -i && test -f Makefile && test -f README && test -f src/part1.c && test -f src/part2.c && test ! -f a.out && test -f docs/manual.txt && test ! -f src/part3.c && test ! -f src/part3.h && test ! -f src/part4.c && test ! -f src/part4.h && test -f obj.o && test -f build/lib.so ' test_expect_success 'git clean -i (quit)' ' mkdir -p build docs && touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \ docs/manual.txt obj.o build/lib.so && echo quit | git clean -i && test -f Makefile && test -f README && test -f src/part1.c && test -f src/part2.c && test -f a.out && test -f docs/manual.txt && test -f src/part3.c && test -f src/part3.h && test -f src/part4.c && test -f src/part4.h && test -f obj.o && test -f build/lib.so ' test_expect_success 'git clean -i (Ctrl+D)' ' mkdir -p build docs && touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \ docs/manual.txt obj.o build/lib.so && echo "\04" | git clean -i && test -f Makefile && test -f README && test -f src/part1.c && test -f src/part2.c && test -f a.out && test -f docs/manual.txt && test -f src/part3.c && test -f src/part3.h && test -f src/part4.c && test -f src/part4.h && test -f obj.o && test -f build/lib.so ' test_expect_success 'git clean -id (filter all)' ' mkdir -p build docs && touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \ docs/manual.txt obj.o build/lib.so && (echo f; echo "*"; echo; echo c) | \ git clean -id && test -f Makefile && test -f README && test -f src/part1.c && test -f src/part2.c && test -f a.out && test -f docs/manual.txt && test -f src/part3.c && test -f src/part3.h && test -f src/part4.c && test -f src/part4.h && test -f obj.o && test -f build/lib.so ' test_expect_success 'git clean -id (filter patterns)' ' mkdir -p build docs && touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \ docs/manual.txt obj.o build/lib.so && (echo f; echo "part3.* *.out"; echo; echo c) | \ git clean -id && test -f Makefile && test -f README && test -f src/part1.c && test -f src/part2.c && test -f a.out && test ! -f docs/manual.txt && test -f src/part3.c && test -f src/part3.h && test ! -f src/part4.c && test ! -f src/part4.h && test -f obj.o && test -f build/lib.so ' test_expect_success 'git clean -id (filter patterns 2)' ' mkdir -p build docs && touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \ docs/manual.txt obj.o build/lib.so && (echo f; echo "* !*.out"; echo; echo c) | \ git clean -id && test -f Makefile && test -f README && test -f src/part1.c && test -f src/part2.c && test ! -f a.out && test -f docs/manual.txt && test -f src/part3.c && test -f src/part3.h && test -f src/part4.c && test -f src/part4.h && test -f obj.o && test -f build/lib.so ' test_expect_success 'git clean -id (select - all)' ' mkdir -p build docs && touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \ docs/manual.txt obj.o build/lib.so && (echo s; echo "*"; echo; echo c) | \ git clean -id && test -f Makefile && test -f README && test -f src/part1.c && test -f src/part2.c && test ! -f a.out && test ! -f docs/manual.txt && test ! -f src/part3.c && test ! -f src/part3.h && test ! -f src/part4.c && test ! -f src/part4.h && test -f obj.o && test -f build/lib.so ' test_expect_success 'git clean -id (select - none)' ' mkdir -p build docs && touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \ docs/manual.txt obj.o build/lib.so && (echo s; echo; echo c) | \ git clean -id && test -f Makefile && test -f README && test -f src/part1.c && test -f src/part2.c && test -f a.out && test -f docs/manual.txt && test -f src/part3.c && test -f src/part3.h && test -f src/part4.c && test -f src/part4.h && test -f obj.o && test -f build/lib.so ' test_expect_success 'git clean -id (select - number)' ' mkdir -p build docs && touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \ docs/manual.txt obj.o build/lib.so && (echo s; echo 3; echo; echo c) | \ git clean -id && test -f Makefile && test -f README && test -f src/part1.c && test -f src/part2.c && test -f a.out && test -f docs/manual.txt && test ! -f src/part3.c && test -f src/part3.h && test -f src/part4.c && test -f src/part4.h && test -f obj.o && test -f build/lib.so ' test_expect_success 'git clean -id (select - number 2)' ' mkdir -p build docs && touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \ docs/manual.txt obj.o build/lib.so && (echo s; echo 2 3; echo 5; echo; echo c) | \ git clean -id && test -f Makefile && test -f README && test -f src/part1.c && test -f src/part2.c && test -f a.out && test ! -f docs/manual.txt && test ! -f src/part3.c && test -f src/part3.h && test ! -f src/part4.c && test -f src/part4.h && test -f obj.o && test -f build/lib.so ' test_expect_success 'git clean -id (select - number 3)' ' mkdir -p build docs && touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \ docs/manual.txt obj.o build/lib.so && (echo s; echo 3,4 5; echo; echo c) | \ git clean -id && test -f Makefile && test -f README && test -f src/part1.c && test -f src/part2.c && test -f a.out && test -f docs/manual.txt && test ! -f src/part3.c && test ! -f src/part3.h && test ! -f src/part4.c && test -f src/part4.h && test -f obj.o && test -f build/lib.so ' test_expect_success 'git clean -id (select - filenames)' ' mkdir -p build docs && touch a.out foo.txt bar.txt baz.txt && (echo s; echo a.out fo ba bar; echo; echo c) | \ git clean -id && test -f Makefile && test ! -f a.out && test ! -f foo.txt && test ! -f bar.txt && test -f baz.txt && rm baz.txt ' test_expect_success 'git clean -id (select - range)' ' mkdir -p build docs && touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \ docs/manual.txt obj.o build/lib.so && (echo s; echo 1,3-4; echo 2; echo; echo c) | \ git clean -id && test -f Makefile && test -f README && test -f src/part1.c && test -f src/part2.c && test ! -f a.out && test ! -f src/part3.c && test ! -f src/part3.h && test -f src/part4.c && test -f src/part4.h && test ! -f docs/manual.txt && test -f obj.o && test -f build/lib.so ' test_expect_success 'git clean -id (select - range 2)' ' mkdir -p build docs && touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \ docs/manual.txt obj.o build/lib.so && (echo s; echo 4- 1; echo; echo c) | \ git clean -id && test -f Makefile && test -f README && test -f src/part1.c && test -f src/part2.c && test ! -f a.out && test -f docs/manual.txt && test -f src/part3.c && test ! -f src/part3.h && test ! -f src/part4.c && test ! -f src/part4.h && test -f obj.o && test -f build/lib.so ' test_expect_success 'git clean -id (inverse select)' ' mkdir -p build docs && touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \ docs/manual.txt obj.o build/lib.so && (echo s; echo "*"; echo -5- 1 -2; echo; echo c) | \ git clean -id && test -f Makefile && test -f README && test -f src/part1.c && test -f src/part2.c && test ! -f a.out && test -f docs/manual.txt && test ! -f src/part3.c && test ! -f src/part3.h && test -f src/part4.c && test -f src/part4.h && test -f obj.o && test -f build/lib.so ' test_expect_success 'git clean -id (ask)' ' mkdir -p build docs && touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \ docs/manual.txt obj.o build/lib.so && (echo a; echo Y; echo y; echo no; echo yes; echo bad; echo) | \ git clean -id && test -f Makefile && test -f README && test -f src/part1.c && test -f src/part2.c && test ! -f a.out && test ! -f docs/manual.txt && test -f src/part3.c && test ! -f src/part3.h && test -f src/part4.c && test -f src/part4.h && test -f obj.o && test -f build/lib.so ' test_expect_success 'git clean -id (ask - Ctrl+D)' ' mkdir -p build docs && touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \ docs/manual.txt obj.o build/lib.so && (echo a; echo Y; echo no; echo yes; echo "\04") | \ git clean -id && test -f Makefile && test -f README && test -f src/part1.c && test -f src/part2.c && test ! -f a.out && test -f docs/manual.txt && test ! -f src/part3.c && test -f src/part3.h && test -f src/part4.c && test -f src/part4.h && test -f obj.o && test -f build/lib.so ' test_expect_success 'git clean -id with prefix and path (filter)' ' mkdir -p build docs && touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \ docs/manual.txt obj.o build/lib.so && (cd build/ && \ (echo f; echo "docs"; echo "*.h"; echo ; echo c) | \ git clean -id ..) && test -f Makefile && test -f README && test -f src/part1.c && test -f src/part2.c && test ! -f a.out && test -f docs/manual.txt && test ! -f src/part3.c && test -f src/part3.h && test ! -f src/part4.c && test -f src/part4.h && test -f obj.o && test -f build/lib.so ' test_expect_success 'git clean -id with prefix and path (select by name)' ' mkdir -p build docs && touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \ docs/manual.txt obj.o build/lib.so && (cd build/ && \ (echo s; echo "../docs/"; echo "../src/part3.c"; \ echo "../src/part4.c"; echo; echo c) | \ git clean -id ..) && test -f Makefile && test -f README && test -f src/part1.c && test -f src/part2.c && test -f a.out && test ! -f docs/manual.txt && test ! -f src/part3.c && test -f src/part3.h && test ! -f src/part4.c && test -f src/part4.h && test -f obj.o && test -f build/lib.so ' test_expect_success 'git clean -id with prefix and path (ask)' ' mkdir -p build docs && touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \ docs/manual.txt obj.o build/lib.so && (cd build/ && \ (echo a; echo Y; echo y; echo no; echo yes; echo bad; echo) | \ git clean -id ..) && test -f Makefile && test -f README && test -f src/part1.c && test -f src/part2.c && test ! -f a.out && test ! -f docs/manual.txt && test -f src/part3.c && test ! -f src/part3.h && test -f src/part4.c && test -f src/part4.h && test -f obj.o && test -f build/lib.so ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"git clean -i basic tests">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ )} { (SQ <"\n"> <"\n"> <"\tmkdir -p src &&\n"> <"\ttouch src/part1.c Makefile &&\n"> <"\techo build >.gitignore &&\n"> <"\techo \\*.o >>.gitignore &&\n"> <"\tgit add . &&\n"> <"\tgit commit -m setup &&\n"> <"\ttouch src/part2.c README &&\n"> <"\tgit add .\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"git clean -i (c: clean hotkey)">)} { (SQ <"\n"> <"\n"> <"\tmkdir -p build docs &&\n"> <"\ttouch a.out src/part3.c src/part3.h src/part4.c src/part4.h \\\n"> <"\tdocs/manual.txt obj.o build/lib.so &&\n"> <"\techo c | git clean -i &&\n"> <"\ttest -f Makefile &&\n"> <"\ttest -f README &&\n"> <"\ttest -f src/part1.c &&\n"> <"\ttest -f src/part2.c &&\n"> <"\ttest ! -f a.out &&\n"> <"\ttest -f docs/manual.txt &&\n"> <"\ttest ! -f src/part3.c &&\n"> <"\ttest ! -f src/part3.h &&\n"> <"\ttest ! -f src/part4.c &&\n"> <"\ttest ! -f src/part4.h &&\n"> <"\ttest -f obj.o &&\n"> <"\ttest -f build/lib.so\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"git clean -i (cl: clean prefix)">)} { (SQ <"\n"> <"\n"> <"\tmkdir -p build docs &&\n"> <"\ttouch a.out src/part3.c src/part3.h src/part4.c src/part4.h \\\n"> <"\tdocs/manual.txt obj.o build/lib.so &&\n"> <"\techo cl | git clean -i &&\n"> <"\ttest -f Makefile &&\n"> <"\ttest -f README &&\n"> <"\ttest -f src/part1.c &&\n"> <"\ttest -f src/part2.c &&\n"> <"\ttest ! -f a.out &&\n"> <"\ttest -f docs/manual.txt &&\n"> <"\ttest ! -f src/part3.c &&\n"> <"\ttest ! -f src/part3.h &&\n"> <"\ttest ! -f src/part4.c &&\n"> <"\ttest ! -f src/part4.h &&\n"> <"\ttest -f obj.o &&\n"> <"\ttest -f build/lib.so\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"git clean -i (quit)">)} { (SQ <"\n"> <"\n"> <"\tmkdir -p build docs &&\n"> <"\ttouch a.out src/part3.c src/part3.h src/part4.c src/part4.h \\\n"> <"\tdocs/manual.txt obj.o build/lib.so &&\n"> <"\techo quit | git clean -i &&\n"> <"\ttest -f Makefile &&\n"> <"\ttest -f README &&\n"> <"\ttest -f src/part1.c &&\n"> <"\ttest -f src/part2.c &&\n"> <"\ttest -f a.out &&\n"> <"\ttest -f docs/manual.txt &&\n"> <"\ttest -f src/part3.c &&\n"> <"\ttest -f src/part3.h &&\n"> <"\ttest -f src/part4.c &&\n"> <"\ttest -f src/part4.h &&\n"> <"\ttest -f obj.o &&\n"> <"\ttest -f build/lib.so\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"git clean -i (Ctrl+D)">)} { (SQ <"\n"> <"\n"> <"\tmkdir -p build docs &&\n"> <"\ttouch a.out src/part3.c src/part3.h src/part4.c src/part4.h \\\n"> <"\tdocs/manual.txt obj.o build/lib.so &&\n"> <"\techo \"\\04\" | git clean -i &&\n"> <"\ttest -f Makefile &&\n"> <"\ttest -f README &&\n"> <"\ttest -f src/part1.c &&\n"> <"\ttest -f src/part2.c &&\n"> <"\ttest -f a.out &&\n"> <"\ttest -f docs/manual.txt &&\n"> <"\ttest -f src/part3.c &&\n"> <"\ttest -f src/part3.h &&\n"> <"\ttest -f src/part4.c &&\n"> <"\ttest -f src/part4.h &&\n"> <"\ttest -f obj.o &&\n"> <"\ttest -f build/lib.so\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"git clean -id (filter all)">)} { (SQ <"\n"> <"\n"> <"\tmkdir -p build docs &&\n"> <"\ttouch a.out src/part3.c src/part3.h src/part4.c src/part4.h \\\n"> <"\tdocs/manual.txt obj.o build/lib.so &&\n"> <"\t(echo f; echo \"*\"; echo; echo c) | \\\n"> <"\tgit clean -id &&\n"> <"\ttest -f Makefile &&\n"> <"\ttest -f README &&\n"> <"\ttest -f src/part1.c &&\n"> <"\ttest -f src/part2.c &&\n"> <"\ttest -f a.out &&\n"> <"\ttest -f docs/manual.txt &&\n"> <"\ttest -f src/part3.c &&\n"> <"\ttest -f src/part3.h &&\n"> <"\ttest -f src/part4.c &&\n"> <"\ttest -f src/part4.h &&\n"> <"\ttest -f obj.o &&\n"> <"\ttest -f build/lib.so\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"git clean -id (filter patterns)">)} { (SQ <"\n"> <"\n"> <"\tmkdir -p build docs &&\n"> <"\ttouch a.out src/part3.c src/part3.h src/part4.c src/part4.h \\\n"> <"\tdocs/manual.txt obj.o build/lib.so &&\n"> <"\t(echo f; echo \"part3.* *.out\"; echo; echo c) | \\\n"> <"\tgit clean -id &&\n"> <"\ttest -f Makefile &&\n"> <"\ttest -f README &&\n"> <"\ttest -f src/part1.c &&\n"> <"\ttest -f src/part2.c &&\n"> <"\ttest -f a.out &&\n"> <"\ttest ! -f docs/manual.txt &&\n"> <"\ttest -f src/part3.c &&\n"> <"\ttest -f src/part3.h &&\n"> <"\ttest ! -f src/part4.c &&\n"> <"\ttest ! -f src/part4.h &&\n"> <"\ttest -f obj.o &&\n"> <"\ttest -f build/lib.so\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"git clean -id (filter patterns 2)">)} { (SQ <"\n"> <"\n"> <"\tmkdir -p build docs &&\n"> <"\ttouch a.out src/part3.c src/part3.h src/part4.c src/part4.h \\\n"> <"\tdocs/manual.txt obj.o build/lib.so &&\n"> <"\t(echo f; echo \"* !*.out\"; echo; echo c) | \\\n"> <"\tgit clean -id &&\n"> <"\ttest -f Makefile &&\n"> <"\ttest -f README &&\n"> <"\ttest -f src/part1.c &&\n"> <"\ttest -f src/part2.c &&\n"> <"\ttest ! -f a.out &&\n"> <"\ttest -f docs/manual.txt &&\n"> <"\ttest -f src/part3.c &&\n"> <"\ttest -f src/part3.h &&\n"> <"\ttest -f src/part4.c &&\n"> <"\ttest -f src/part4.h &&\n"> <"\ttest -f obj.o &&\n"> <"\ttest -f build/lib.so\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"git clean -id (select - all)">)} { (SQ <"\n"> <"\n"> <"\tmkdir -p build docs &&\n"> <"\ttouch a.out src/part3.c src/part3.h src/part4.c src/part4.h \\\n"> <"\tdocs/manual.txt obj.o build/lib.so &&\n"> <"\t(echo s; echo \"*\"; echo; echo c) | \\\n"> <"\tgit clean -id &&\n"> <"\ttest -f Makefile &&\n"> <"\ttest -f README &&\n"> <"\ttest -f src/part1.c &&\n"> <"\ttest -f src/part2.c &&\n"> <"\ttest ! -f a.out &&\n"> <"\ttest ! -f docs/manual.txt &&\n"> <"\ttest ! -f src/part3.c &&\n"> <"\ttest ! -f src/part3.h &&\n"> <"\ttest ! -f src/part4.c &&\n"> <"\ttest ! -f src/part4.h &&\n"> <"\ttest -f obj.o &&\n"> <"\ttest -f build/lib.so\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"git clean -id (select - none)">)} { (SQ <"\n"> <"\n"> <"\tmkdir -p build docs &&\n"> <"\ttouch a.out src/part3.c src/part3.h src/part4.c src/part4.h \\\n"> <"\tdocs/manual.txt obj.o build/lib.so &&\n"> <"\t(echo s; echo; echo c) | \\\n"> <"\tgit clean -id &&\n"> <"\ttest -f Makefile &&\n"> <"\ttest -f README &&\n"> <"\ttest -f src/part1.c &&\n"> <"\ttest -f src/part2.c &&\n"> <"\ttest -f a.out &&\n"> <"\ttest -f docs/manual.txt &&\n"> <"\ttest -f src/part3.c &&\n"> <"\ttest -f src/part3.h &&\n"> <"\ttest -f src/part4.c &&\n"> <"\ttest -f src/part4.h &&\n"> <"\ttest -f obj.o &&\n"> <"\ttest -f build/lib.so\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"git clean -id (select - number)">)} { (SQ <"\n"> <"\n"> <"\tmkdir -p build docs &&\n"> <"\ttouch a.out src/part3.c src/part3.h src/part4.c src/part4.h \\\n"> <"\tdocs/manual.txt obj.o build/lib.so &&\n"> <"\t(echo s; echo 3; echo; echo c) | \\\n"> <"\tgit clean -id &&\n"> <"\ttest -f Makefile &&\n"> <"\ttest -f README &&\n"> <"\ttest -f src/part1.c &&\n"> <"\ttest -f src/part2.c &&\n"> <"\ttest -f a.out &&\n"> <"\ttest -f docs/manual.txt &&\n"> <"\ttest ! -f src/part3.c &&\n"> <"\ttest -f src/part3.h &&\n"> <"\ttest -f src/part4.c &&\n"> <"\ttest -f src/part4.h &&\n"> <"\ttest -f obj.o &&\n"> <"\ttest -f build/lib.so\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"git clean -id (select - number 2)">)} { (SQ <"\n"> <"\n"> <"\tmkdir -p build docs &&\n"> <"\ttouch a.out src/part3.c src/part3.h src/part4.c src/part4.h \\\n"> <"\tdocs/manual.txt obj.o build/lib.so &&\n"> <"\t(echo s; echo 2 3; echo 5; echo; echo c) | \\\n"> <"\tgit clean -id &&\n"> <"\ttest -f Makefile &&\n"> <"\ttest -f README &&\n"> <"\ttest -f src/part1.c &&\n"> <"\ttest -f src/part2.c &&\n"> <"\ttest -f a.out &&\n"> <"\ttest ! -f docs/manual.txt &&\n"> <"\ttest ! -f src/part3.c &&\n"> <"\ttest -f src/part3.h &&\n"> <"\ttest ! -f src/part4.c &&\n"> <"\ttest -f src/part4.h &&\n"> <"\ttest -f obj.o &&\n"> <"\ttest -f build/lib.so\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"git clean -id (select - number 3)">)} { (SQ <"\n"> <"\n"> <"\tmkdir -p build docs &&\n"> <"\ttouch a.out src/part3.c src/part3.h src/part4.c src/part4.h \\\n"> <"\tdocs/manual.txt obj.o build/lib.so &&\n"> <"\t(echo s; echo 3,4 5; echo; echo c) | \\\n"> <"\tgit clean -id &&\n"> <"\ttest -f Makefile &&\n"> <"\ttest -f README &&\n"> <"\ttest -f src/part1.c &&\n"> <"\ttest -f src/part2.c &&\n"> <"\ttest -f a.out &&\n"> <"\ttest -f docs/manual.txt &&\n"> <"\ttest ! -f src/part3.c &&\n"> <"\ttest ! -f src/part3.h &&\n"> <"\ttest ! -f src/part4.c &&\n"> <"\ttest -f src/part4.h &&\n"> <"\ttest -f obj.o &&\n"> <"\ttest -f build/lib.so\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"git clean -id (select - filenames)">)} { (SQ <"\n"> <"\n"> <"\tmkdir -p build docs &&\n"> <"\ttouch a.out foo.txt bar.txt baz.txt &&\n"> <"\t(echo s; echo a.out fo ba bar; echo; echo c) | \\\n"> <"\tgit clean -id &&\n"> <"\ttest -f Makefile &&\n"> <"\ttest ! -f a.out &&\n"> <"\ttest ! -f foo.txt &&\n"> <"\ttest ! -f bar.txt &&\n"> <"\ttest -f baz.txt &&\n"> <"\trm baz.txt\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"git clean -id (select - range)">)} { (SQ <"\n"> <"\n"> <"\tmkdir -p build docs &&\n"> <"\ttouch a.out src/part3.c src/part3.h src/part4.c src/part4.h \\\n"> <"\tdocs/manual.txt obj.o build/lib.so &&\n"> <"\t(echo s; echo 1,3-4; echo 2; echo; echo c) | \\\n"> <"\tgit clean -id &&\n"> <"\ttest -f Makefile &&\n"> <"\ttest -f README &&\n"> <"\ttest -f src/part1.c &&\n"> <"\ttest -f src/part2.c &&\n"> <"\ttest ! -f a.out &&\n"> <"\ttest ! -f src/part3.c &&\n"> <"\ttest ! -f src/part3.h &&\n"> <"\ttest -f src/part4.c &&\n"> <"\ttest -f src/part4.h &&\n"> <"\ttest ! -f docs/manual.txt &&\n"> <"\ttest -f obj.o &&\n"> <"\ttest -f build/lib.so\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"git clean -id (select - range 2)">)} { (SQ <"\n"> <"\n"> <"\tmkdir -p build docs &&\n"> <"\ttouch a.out src/part3.c src/part3.h src/part4.c src/part4.h \\\n"> <"\tdocs/manual.txt obj.o build/lib.so &&\n"> <"\t(echo s; echo 4- 1; echo; echo c) | \\\n"> <"\tgit clean -id &&\n"> <"\ttest -f Makefile &&\n"> <"\ttest -f README &&\n"> <"\ttest -f src/part1.c &&\n"> <"\ttest -f src/part2.c &&\n"> <"\ttest ! -f a.out &&\n"> <"\ttest -f docs/manual.txt &&\n"> <"\ttest -f src/part3.c &&\n"> <"\ttest ! -f src/part3.h &&\n"> <"\ttest ! -f src/part4.c &&\n"> <"\ttest ! -f src/part4.h &&\n"> <"\ttest -f obj.o &&\n"> <"\ttest -f build/lib.so\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"git clean -id (inverse select)">)} { (SQ <"\n"> <"\n"> <"\tmkdir -p build docs &&\n"> <"\ttouch a.out src/part3.c src/part3.h src/part4.c src/part4.h \\\n"> <"\tdocs/manual.txt obj.o build/lib.so &&\n"> <"\t(echo s; echo \"*\"; echo -5- 1 -2; echo; echo c) | \\\n"> <"\tgit clean -id &&\n"> <"\ttest -f Makefile &&\n"> <"\ttest -f README &&\n"> <"\ttest -f src/part1.c &&\n"> <"\ttest -f src/part2.c &&\n"> <"\ttest ! -f a.out &&\n"> <"\ttest -f docs/manual.txt &&\n"> <"\ttest ! -f src/part3.c &&\n"> <"\ttest ! -f src/part3.h &&\n"> <"\ttest -f src/part4.c &&\n"> <"\ttest -f src/part4.h &&\n"> <"\ttest -f obj.o &&\n"> <"\ttest -f build/lib.so\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"git clean -id (ask)">)} { (SQ <"\n"> <"\n"> <"\tmkdir -p build docs &&\n"> <"\ttouch a.out src/part3.c src/part3.h src/part4.c src/part4.h \\\n"> <"\tdocs/manual.txt obj.o build/lib.so &&\n"> <"\t(echo a; echo Y; echo y; echo no; echo yes; echo bad; echo) | \\\n"> <"\tgit clean -id &&\n"> <"\ttest -f Makefile &&\n"> <"\ttest -f README &&\n"> <"\ttest -f src/part1.c &&\n"> <"\ttest -f src/part2.c &&\n"> <"\ttest ! -f a.out &&\n"> <"\ttest ! -f docs/manual.txt &&\n"> <"\ttest -f src/part3.c &&\n"> <"\ttest ! -f src/part3.h &&\n"> <"\ttest -f src/part4.c &&\n"> <"\ttest -f src/part4.h &&\n"> <"\ttest -f obj.o &&\n"> <"\ttest -f build/lib.so\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"git clean -id (ask - Ctrl+D)">)} { (SQ <"\n"> <"\n"> <"\tmkdir -p build docs &&\n"> <"\ttouch a.out src/part3.c src/part3.h src/part4.c src/part4.h \\\n"> <"\tdocs/manual.txt obj.o build/lib.so &&\n"> <"\t(echo a; echo Y; echo no; echo yes; echo \"\\04\") | \\\n"> <"\tgit clean -id &&\n"> <"\ttest -f Makefile &&\n"> <"\ttest -f README &&\n"> <"\ttest -f src/part1.c &&\n"> <"\ttest -f src/part2.c &&\n"> <"\ttest ! -f a.out &&\n"> <"\ttest -f docs/manual.txt &&\n"> <"\ttest ! -f src/part3.c &&\n"> <"\ttest -f src/part3.h &&\n"> <"\ttest -f src/part4.c &&\n"> <"\ttest -f src/part4.h &&\n"> <"\ttest -f obj.o &&\n"> <"\ttest -f build/lib.so\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"git clean -id with prefix and path (filter)">)} { (SQ <"\n"> <"\n"> <"\tmkdir -p build docs &&\n"> <"\ttouch a.out src/part3.c src/part3.h src/part4.c src/part4.h \\\n"> <"\tdocs/manual.txt obj.o build/lib.so &&\n"> <"\t(cd build/ && \\\n"> <"\t (echo f; echo \"docs\"; echo \"*.h\"; echo ; echo c) | \\\n"> <"\t git clean -id ..) &&\n"> <"\ttest -f Makefile &&\n"> <"\ttest -f README &&\n"> <"\ttest -f src/part1.c &&\n"> <"\ttest -f src/part2.c &&\n"> <"\ttest ! -f a.out &&\n"> <"\ttest -f docs/manual.txt &&\n"> <"\ttest ! -f src/part3.c &&\n"> <"\ttest -f src/part3.h &&\n"> <"\ttest ! -f src/part4.c &&\n"> <"\ttest -f src/part4.h &&\n"> <"\ttest -f obj.o &&\n"> <"\ttest -f build/lib.so\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"git clean -id with prefix and path (select by name)">)} { (SQ <"\n"> <"\n"> <"\tmkdir -p build docs &&\n"> <"\ttouch a.out src/part3.c src/part3.h src/part4.c src/part4.h \\\n"> <"\tdocs/manual.txt obj.o build/lib.so &&\n"> <"\t(cd build/ && \\\n"> <"\t (echo s; echo \"../docs/\"; echo \"../src/part3.c\"; \\\n"> <"\t echo \"../src/part4.c\"; echo; echo c) | \\\n"> <"\t git clean -id ..) &&\n"> <"\ttest -f Makefile &&\n"> <"\ttest -f README &&\n"> <"\ttest -f src/part1.c &&\n"> <"\ttest -f src/part2.c &&\n"> <"\ttest -f a.out &&\n"> <"\ttest ! -f docs/manual.txt &&\n"> <"\ttest ! -f src/part3.c &&\n"> <"\ttest -f src/part3.h &&\n"> <"\ttest ! -f src/part4.c &&\n"> <"\ttest -f src/part4.h &&\n"> <"\ttest -f obj.o &&\n"> <"\ttest -f build/lib.so\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"git clean -id with prefix and path (ask)">)} { (SQ <"\n"> <"\n"> <"\tmkdir -p build docs &&\n"> <"\ttouch a.out src/part3.c src/part3.h src/part4.c src/part4.h \\\n"> <"\tdocs/manual.txt obj.o build/lib.so &&\n"> <"\t(cd build/ && \\\n"> <"\t (echo a; echo Y; echo y; echo no; echo yes; echo bad; echo) | \\\n"> <"\t git clean -id ..) &&\n"> <"\ttest -f Makefile &&\n"> <"\ttest -f README &&\n"> <"\ttest -f src/part1.c &&\n"> <"\ttest -f src/part2.c &&\n"> <"\ttest ! -f a.out &&\n"> <"\ttest ! -f docs/manual.txt &&\n"> <"\ttest -f src/part3.c &&\n"> <"\ttest ! -f src/part3.h &&\n"> <"\ttest -f src/part4.c &&\n"> <"\ttest -f src/part4.h &&\n"> <"\ttest -f obj.o &&\n"> <"\ttest -f build/lib.so\n"> <"\n"> ) } ) (C {(test_done)}) ] )