Thread (1 message) 1 message, 1 author, 2023-02-09

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

From: Junio C Hamano <hidden>
Date: 2023-02-09 22:55:05

Ævar Arnfjörð Bjarmason [off-list ref] writes:
quoted
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 '
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help