t3700: remove unwanted leftover files before running new tests
authorIngo Brückl <ib@wupperonline.de>
Sat, 30 Jul 2016 20:13:38 +0000 (22:13 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 1 Aug 2016 21:20:51 +0000 (14:20 -0700)
When an earlier test that has prerequisite is skipped, files
used by later tests may be left in the working tree in an
unexpected state. For example, a test runs this sequence:

echo foo >xfoo1 && chmod 755 xfoo1

to create an executable file xfoo1, expecting that xfoo1
does not exist before it runs in the test sequence.
However, the absence of this file depends on "git reset
--hard" done in an earlier test, that is skipped when SANITY
prerequisite is not met, and worse yet, xfoo1 originally is
created as a symbolic link, which means the chmod does not
affect the modes of xfoo1 as this test expects.

Fix this by starting the test with "rm -f xfoo1" to make
sure the file is created from scratch, and do the same to
other similar tests.

Signed-off-by: Ingo Brückl <ib@wupperonline.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t3700-add.sh
index 4865304ebb8560d40fd993dc13a47a2ed4bf9e1b..494f5b84f51aa56e57f0b1ae751015a93388447b 100755 (executable)
@@ -333,6 +333,7 @@ test_expect_success 'git add --dry-run --ignore-missing of non-existing file out
 '
 
 test_expect_success 'git add --chmod=+x stages a non-executable file with +x' '
+       rm -f foo1 &&
        echo foo >foo1 &&
        git add --chmod=+x foo1 &&
        case "$(git ls-files --stage foo1)" in
@@ -342,6 +343,7 @@ test_expect_success 'git add --chmod=+x stages a non-executable file with +x' '
 '
 
 test_expect_success 'git add --chmod=-x stages an executable file with -x' '
+       rm -f xfoo1 &&
        echo foo >xfoo1 &&
        chmod 755 xfoo1 &&
        git add --chmod=-x xfoo1 &&
@@ -354,6 +356,7 @@ test_expect_success 'git add --chmod=-x stages an executable file with -x' '
 test_expect_success POSIXPERM,SYMLINKS 'git add --chmod=+x with symlinks' '
        git config core.filemode 1 &&
        git config core.symlinks 1 &&
+       rm -f foo2 &&
        echo foo >foo2 &&
        git add --chmod=+x foo2 &&
        case "$(git ls-files --stage foo2)" in