git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git 2.10.1 test regression in t3700-add.sh

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 12, 2016, 05:59 UTC
Message-ID
<xmqq1szm6rbg.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<EF7F9B45-867A-433B-9623-EBBF33D34793@freedesktop.org>
Jeremy Huddleston Sequoia <jeremyhu@freedesktop.org> writes:
Show 17 quoted lines
>> diff --git a/t/t3700-add.sh b/t/t3700-add.sh
>> index 924a266126..53c0cb6dea 100755
>> --- a/t/t3700-add.sh
>> +++ b/t/t3700-add.sh
>> @@ -350,6 +350,7 @@ test_expect_success POSIXPERM,SYMLINKS 'git add --chmod=+x with symlinks' '
>> '
>> 
>> test_expect_success 'git add --chmod=[+-]x changes index with already added file' '
>> +	rm -f foo3 xfoo3 &&
>> 	echo foo >foo3 &&
>> 	git add foo3 &&
>> 	git add --chmod=+x foo3 &&
>
>
> I actually tried that, but the problem is that xfoo3 was
> previously added as a symlink, so test_mode_in_index still reports
> it as a symlink.

Ah, of course. That "rm -f" needs to remove from the index and also from the working tree, so has to be "git rm -f --ignore-unmatch" or something like that.

Show 5 quoted lines
> It's fundamentally a question of who is responsible for cleanup.
> Is the individual test responsible for cleaning up after itself
> (such that later tests can rely on a clean state), or should
> individual tests assume that the initial state might be undefined
> and try to cleanup after earlier tests?

In modern tests, we strive to do the former with liberal use of test_when_finished. I think the one that creates xfoo[123] and leaves them behind for a long time predates the modern practice.

A minimal fix with that approach may look like this:
 t/t3700-add.sh | 1 +
 1 file changed, 1 insertion(+)
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index 924a266126..80c7ee3e3b 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -64,6 +64,7 @@ test_expect_success 'git add: filemode=0 should not get confused by symlink' '
 test_expect_success \
 	'git update-index --add: Test that executable bit is not used...' \
 	'git config core.filemode 0 &&
+	 test_when_finished "git rm -f xfoo3" &&
 	 test_ln_s_add xfoo2 xfoo3 &&	# runs git update-index --add
 	 test_mode_in_index 120000 xfoo3'
 
Previous: Jeremy Huddleston Sequoia
Message 9 of 9 in “git 2.10.1 test regression in t3700-add.sh”
  1. Jeremy Huddleston SequoiaOct 10, 2016
  2. Jeremy Huddleston SequoiaOct 10, 2016
  3. Jeremy Huddleston SequoiaOct 10, 2016
  4. Jeremy Huddleston SequoiaOct 10, 2016
  5. Junio C HamanoOct 10, 2016
  6. Junio C HamanoOct 10, 2016
  7. Johannes SixtOct 10, 2016
  8. Jeremy Huddleston SequoiaOct 11, 2016
  9. Junio C HamanoOct 12, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.