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

Re: [PATCH] test: make SYMLINKS prerequisite more robust

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 9, 2023, 22:54 UTC
Message-ID
<xmqqlel6laa1.fsf@gitster.g>
In-Reply-To
<230209.86ttzvy405.gmgdl@evledraar.gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 9 quoted lines
>> We
>> are testing "git" with the test suite, so even if with some magic
>> that is still unknown to compat/mingw.h it knows how to read what
>> "ln -s x y" left in "y", until compat/mingw.h::readlink() learns the
>> same trick, asking Perl to decide SYMLINKS prerequisite would not
>> help our test scripts at all.
>
> We could always see if they return the same answer :) But not worth
> pursuing in this case.

Actually we probably should test if "git" can create a symbolic link, because that is what matters more than what "ln -s" can or cannot do. We also are interested in the "symbolic link" does behave as a symbolic link, i.e. writing into it should modify the contents of the target of the link.

In any case, here is what I have in mind. There is only a symbolic link 'y' without 'x' (because this happens in a new and empty directory for evaluating the lazy prerequisite), redirecting output from the command, which should be 'x', into 'y' will vivify file 'x' with contents also 'x', and reading 'y' should yield 'x' because it points at 'x'.

diff --git c/t/test-lib.sh w/t/test-lib.sh
index 6db377f68b..3fb5957bd2 100644
--- c/t/test-lib.sh
+++ w/t/test-lib.sh
@@ -1773,7 +1773,9 @@ test_lazy_prereq PIPE '
 
 test_lazy_prereq SYMLINKS '
 	# test whether the filesystem supports symbolic links
-	ln -s x y && test -h y
+	ln -s x y && test -h y && test-tool readlink y >y &&
+	test "$(cat y)" = x &&
+	test "$(cat x)" = x
 '
 
 test_lazy_prereq SYMLINKS_WINDOWS '
Previous: Ævar Arnfjörð BjarmasonNext: Junio C Hamano
Message 5 of 9 in “test: make SYMLINKS prerequisite more robust”
  1. test: make SYMLINKS prerequisite more robustJunio C Hamano, Feb 8, 2023
  2. Ævar Arnfjörð BjarmasonFeb 8, 2023
  3. Junio C HamanoFeb 9, 2023
  4. Ævar Arnfjörð BjarmasonFeb 9, 2023
  5. Junio C HamanoFeb 9, 2023
  6. Junio C HamanoFeb 10, 2023
  7. Ævar Arnfjörð BjarmasonFeb 10, 2023
  8. Johannes SchindelinFeb 13, 2023
  9. Junio C HamanoFeb 13, 2023

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.