Skip to content

Commit c0fa44d

Browse files
ibgitster
authored andcommitted
t3700: remove unwanted leftover files before running new tests
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4e55ed3 commit c0fa44d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

t/t3700-add.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ test_expect_success 'git add --dry-run --ignore-missing of non-existing file out
333333
'
334334

335335
test_expect_success 'git add --chmod=+x stages a non-executable file with +x' '
336+
rm -f foo1 &&
336337
echo foo >foo1 &&
337338
git add --chmod=+x foo1 &&
338339
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' '
342343
'
343344

344345
test_expect_success 'git add --chmod=-x stages an executable file with -x' '
346+
rm -f xfoo1 &&
345347
echo foo >xfoo1 &&
346348
chmod 755 xfoo1 &&
347349
git add --chmod=-x xfoo1 &&
@@ -354,6 +356,7 @@ test_expect_success 'git add --chmod=-x stages an executable file with -x' '
354356
test_expect_success POSIXPERM,SYMLINKS 'git add --chmod=+x with symlinks' '
355357
git config core.filemode 1 &&
356358
git config core.symlinks 1 &&
359+
rm -f foo2 &&
357360
echo foo >foo2 &&
358361
git add --chmod=+x foo2 &&
359362
case "$(git ls-files --stage foo2)" in

0 commit comments

Comments
 (0)