mirror of
https://github.com/git/git.git
synced 2024-11-28 20:44:04 +08:00
181 lines
3.4 KiB
Bash
181 lines
3.4 KiB
Bash
|
#!/bin/sh
|
||
|
#
|
||
|
# Copyright (c) 2007 Michael Spang
|
||
|
#
|
||
|
|
||
|
test_description='git-clean basic tests'
|
||
|
|
||
|
. ./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' '
|
||
|
|
||
|
mkdir -p build docs &&
|
||
|
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
|
||
|
git-clean &&
|
||
|
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 docs/manual.txt &&
|
||
|
test -f obj.o &&
|
||
|
test -f build/lib.so
|
||
|
|
||
|
'
|
||
|
|
||
|
test_expect_success 'git-clean -n' '
|
||
|
|
||
|
mkdir -p build docs &&
|
||
|
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
|
||
|
git-clean -n &&
|
||
|
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 docs/manual.txt &&
|
||
|
test -f obj.o &&
|
||
|
test -f build/lib.so
|
||
|
|
||
|
'
|
||
|
|
||
|
test_expect_success 'git-clean -d' '
|
||
|
|
||
|
mkdir -p build docs &&
|
||
|
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
|
||
|
git-clean -d &&
|
||
|
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 ! -d docs &&
|
||
|
test -f obj.o &&
|
||
|
test -f build/lib.so
|
||
|
|
||
|
'
|
||
|
|
||
|
test_expect_success 'git-clean -x' '
|
||
|
|
||
|
mkdir -p build docs &&
|
||
|
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
|
||
|
git-clean -x &&
|
||
|
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 docs/manual.txt &&
|
||
|
test ! -f obj.o &&
|
||
|
test -f build/lib.so
|
||
|
|
||
|
'
|
||
|
|
||
|
test_expect_success 'git-clean -d -x' '
|
||
|
|
||
|
mkdir -p build docs &&
|
||
|
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
|
||
|
git-clean -d -x &&
|
||
|
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 ! -d docs &&
|
||
|
test ! -f obj.o &&
|
||
|
test ! -d build
|
||
|
|
||
|
'
|
||
|
|
||
|
test_expect_success 'git-clean -X' '
|
||
|
|
||
|
mkdir -p build docs &&
|
||
|
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
|
||
|
git-clean -X &&
|
||
|
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 docs/manual.txt &&
|
||
|
test ! -f obj.o &&
|
||
|
test -f build/lib.so
|
||
|
|
||
|
'
|
||
|
|
||
|
test_expect_success 'git-clean -d -X' '
|
||
|
|
||
|
mkdir -p build docs &&
|
||
|
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
|
||
|
git-clean -d -X &&
|
||
|
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 docs/manual.txt &&
|
||
|
test ! -f obj.o &&
|
||
|
test ! -d build
|
||
|
|
||
|
'
|
||
|
|
||
|
test_expect_success 'clean.requireForce' '
|
||
|
|
||
|
git-config clean.requireForce true &&
|
||
|
! git-clean
|
||
|
|
||
|
'
|
||
|
|
||
|
test_expect_success 'clean.requireForce and -n' '
|
||
|
|
||
|
mkdir -p build docs &&
|
||
|
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
|
||
|
git-clean -n &&
|
||
|
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 docs/manual.txt &&
|
||
|
test -f obj.o &&
|
||
|
test -f build/lib.so
|
||
|
|
||
|
'
|
||
|
|
||
|
test_expect_success 'clean.requireForce and -f' '
|
||
|
|
||
|
git-clean -f &&
|
||
|
test -f README &&
|
||
|
test -f src/part1.c &&
|
||
|
test -f src/part2.c &&
|
||
|
test ! -f a.out &&
|
||
|
test ! -f src/part3.c &&
|
||
|
test -f docs/manual.txt &&
|
||
|
test -f obj.o &&
|
||
|
test -f build/lib.so
|
||
|
|
||
|
'
|
||
|
|
||
|
test_done
|