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

Re: [PATCH 05/11] tests: use test_ln_s_add to remove SYMLINKS prerequisite (trivial cases)

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 4, 2013, 21:55 UTC
Message-ID
<7vd2s15yoa.fsf@alter.siamese.dyndns.org>
In-Reply-To
<3c8aaaa4ad606d2afb7c110a28c119792caa8aba.1370076477.git.j6t@kdbg.org>
Johannes Sixt <j6t@kdbg.org> writes:
> There are many instances where the treatment of symbolic links in the
> object model and the algorithms are tested, but where it is not
> necessary to actually have a symbolic link in the worktree.
Show 18 quoted lines
> diff --git a/t/t3000-ls-files-others.sh b/t/t3000-ls-files-others.sh
> index 88be904..563ac7f 100755
> --- a/t/t3000-ls-files-others.sh
> +++ b/t/t3000-ls-files-others.sh
> @@ -19,12 +19,7 @@ filesystem.
>  
>  test_expect_success 'setup ' '
>  	date >path0 &&
> -	if test_have_prereq SYMLINKS
> -	then
> -		ln -s xyzzy path1
> -	else
> -		date >path1
> -	fi &&
> +	test_ln_s xyzzy path1 &&
>  	mkdir path2 path3 path4 &&
>  	date >path2/file2 &&
>  	date >path2-junk &&

This also is not appropriate, but it is not as bad as the one in t2003 I earlier commented on.

This test wants an untracked symbolic link in the working tree as path1 and wants to see "ls-files -o" report it as "other". On a filesystem that lack symbolic link, we obviously cannot have one, so as a substitute we just create another regular file to make the expected output and comparison simpler.

Show 10 quoted lines
> diff --git a/t/t3010-ls-files-killed-modified.sh b/t/t3010-ls-files-killed-modified.sh
> index 2d0ff2d..310e0a2 100755
> --- a/t/t3010-ls-files-killed-modified.sh
> +++ b/t/t3010-ls-files-killed-modified.sh
> @@ -39,12 +39,7 @@ modified without reporting path9 and path10.
> ...
> +	test_ln_s_add xyzzy path1 &&
> ...
>  	date >path2/file2 &&
>  	date >path3/file3 &&

This one is correct; the test wants to make sure that path1 would be checked out as a non-directory, killing any files in path1/ that is a directory on the filesystem.

Show 6 quoted lines
> @@ -52,20 +47,14 @@ test_expect_success 'git update-index --add to add various paths.' '
>  	date >path8 &&
>  	: >path9 &&
>  	date >path10 &&
> -	git update-index --add -- path0 path1 path?/file? path7 path8 path9 path10 &&
> +	git update-index --add -- path0 path?/file? path7 path8 path9 path10 &&

And exclusion of path1 here is a logical consequence of the previous change, so it is good, too.

Show 12 quoted lines
>  test_expect_success 'git ls-files -k to show killed files.' '
>  	date >path2 &&
> -	if test_have_prereq SYMLINKS
> -	then
> -		ln -s frotz path3 &&
> -		ln -s nitfol path5
> -	else
> -		date >path3 &&
> -		date >path5
> -	fi &&
> +	test_ln_s frotz path3 &&
> +	test_ln_s nitfol path5 &&

This falls into the same category as the one in t3000 above. The only thing that matters in this test is path3 and path5 are non directories so that the former is killed when path3/file3 needs to be checked out, while path5 will not appear in "ls-files -k" output. Ideally we would want to test regular files and symlinks as two different kinds of "non directory" filesystem entities, but on platforms that lack symbolic links we cannot do so, hence we punt and create a regular file.

Show 18 quoted lines
> diff --git a/t/t4011-diff-symlink.sh b/t/t4011-diff-symlink.sh
> index f0d5041..3888519 100755
> --- a/t/t4011-diff-symlink.sh
> +++ b/t/t4011-diff-symlink.sh
> @@ -66,12 +69,12 @@ test_expect_success SYMLINKS 'diff removed symlink and file' '
>  	compare_diff_patch expected current
>  '
>  
> -test_expect_success SYMLINKS 'diff identical, but newly created symlink and file' '
> +test_expect_success 'diff identical, but newly created symlink and file' '
>  	>expected &&
>  	rm -f frotz nitfol &&
>  	echo xyzzy >nitfol &&
>  	test-chmtime +10 nitfol &&
> -	ln -s xyzzy frotz &&
> +	test_ln_s xyzzy frotz &&
>  	git diff-index -M -p $tree >current &&
>  	compare_diff_patch expected current &&

As the point of test is to compare $tree that has symlink with another symlink that is identical but newly created one, I think this _does_ want the filesystem entity to be a symbolic link, but the index has frotz as a symlink and the mode propagates to what we read from the filesystem on !has_symlinks systems, so this conversion may be a correct one, though it is a bit tricky.

Show 18 quoted lines
> @@ -80,7 +83,7 @@ test_expect_success SYMLINKS 'diff identical, but newly created symlink and file
>  	compare_diff_patch expected current
>  '
>  
> -test_expect_success SYMLINKS 'diff different symlink and file' '
> +test_expect_success 'diff different symlink and file' '
>  	cat >expected <<-\EOF &&
>  	diff --git a/frotz b/frotz
>  	index 7c465af..df1db54 120000
> @@ -100,7 +103,7 @@ test_expect_success SYMLINKS 'diff different symlink and file' '
>  	+yxyyz
>  	EOF
>  	rm -f frotz &&
> -	ln -s yxyyz frotz &&
> +	test_ln_s yxyyz frotz &&
>  	echo yxyyz >nitfol &&
>  	git diff-index -M -p $tree >current &&
>  	compare_diff_patch expected current
Likewise.
Previous: Johannes SixtNext: Johannes Sixt
Message 12 of 35 in “Increase test coverage on Windows by removing SYMLINKS from many tests”
  1. 00/11 Increase test coverage on Windows by removing SYMLINKS from many testsJohannes Sixt, Jun 1, 2013
  2. 01/11 test-chmtime: Fix exit code on WindowsJohannes Sixt, Jun 1, 2013
  3. 02/11 t2100: modernize style and unroll a loop of test casesJohannes Sixt, Jun 1, 2013
  4. 03/11 t3010: modernize styleJohannes Sixt, Jun 1, 2013
  5. 04/11 tests: introduce test_ln_s and test_ln_s_addJohannes Sixt, Jun 1, 2013
  6. Ramkumar RamachandraJun 1, 2013
  7. Johannes SixtJun 1, 2013
  8. Ramkumar RamachandraJun 1, 2013
  9. 05/11 tests: use test_ln_s_add to remove SYMLINKS prerequisite (trivial cases)Johannes Sixt, Jun 1, 2013
  10. Junio C HamanoJun 4, 2013
  11. Johannes SixtJun 5, 2013
  12. Junio C HamanoJun 4, 2013
  13. Johannes SixtJun 5, 2013
  14. 06/11 t0000: use test_ln_s_add to remove SYMLINKS prerequisiteJohannes Sixt, Jun 1, 2013
  15. 07/11 t2100: use test_ln_s_add to remove SYMLINKS prerequisiteJohannes Sixt, Jun 1, 2013
  16. Junio C HamanoJun 4, 2013
  17. Johannes SixtJun 5, 2013
  18. 08/11 t3030: use test_ln_s_add to remove SYMLINKS prerequisiteJohannes Sixt, Jun 1, 2013
  19. 09/11 t3100: use test_ln_s_add to remove SYMLINKS prerequisiteJohannes Sixt, Jun 1, 2013
  20. 10/11 t3509, t4023, t4114: use test_ln_s_add to remove SYMLINKS prerequisiteJohannes Sixt, Jun 1, 2013
  21. Junio C HamanoJun 2, 2013
  22. 11/11 t6035: use test_ln_s_add to remove SYMLINKS prerequisiteJohannes Sixt, Jun 1, 2013
  23. 00/10 Increase test coverage on Windows by removing SYMLINKS from many testsJohannes Sixt, Jun 7, 2013
  24. Junio C HamanoJun 7, 2013
  25. 01/10 test-chmtime: Fix exit code on WindowsJohannes Sixt, Jun 7, 2013
  26. Erik Faye-LundNov 20, 2013
  27. 02/10 t3010: modernize styleJohannes Sixt, Jun 7, 2013
  28. 03/10 tests: introduce test_ln_s_addJohannes Sixt, Jun 7, 2013
  29. 04/10 tests: use test_ln_s_add to remove SYMLINKS prerequisite (trivial cases)Johannes Sixt, Jun 7, 2013
  30. 05/10 t0000: use test_ln_s_add to remove SYMLINKS prerequisiteJohannes Sixt, Jun 7, 2013
  31. 06/10 t3030: use test_ln_s_add to remove SYMLINKS prerequisiteJohannes Sixt, Jun 7, 2013
  32. 07/10 t3100: use test_ln_s_add to remove SYMLINKS prerequisiteJohannes Sixt, Jun 7, 2013
  33. 08/10 t3509, t4023, t4114: use test_ln_s_add to remove SYMLINKS prerequisiteJohannes Sixt, Jun 7, 2013
  34. 09/10 t6035: use test_ln_s_add to remove SYMLINKS prerequisiteJohannes Sixt, Jun 7, 2013
  35. 10/10 t4011: remove SYMLINKS prerequisiteJohannes Sixt, Jun 7, 2013

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.