git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] test: make SYMLINKS prerequisite more robust
@ 2023-02-08 19:40 Junio C Hamano
  2023-02-08 23:09 ` Ævar Arnfjörð Bjarmason
  0 siblings, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2023-02-08 19:40 UTC (permalink / raw)
  To: git

I see many failures around SYMLINKS prerequisite in Windows tests.
There are too many to point at, but the pattern seems to be the
same.  Here is one example:

  https://github.com/git/git/actions/runs/4127147009/jobs/7130175639#step:5:502

where "ln -s x y && test -h y" succeeds and declares SYMLINKS
lazy prerequisite is satisfied, but then it fails to run

	"ln -s unrelated DS && git update-index --add DS"

with:

	error: readlink("DS"): Function not implemented

I wonder if something like this is in order?

----- >8 -----

We should not just ensure "ln -s" and "test -h" works, but readlink
yields the expected value.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Makefile                 |  1 +
 t/helper/test-readlink.c | 19 +++++++++++++++++++
 t/helper/test-tool.c     |  1 +
 t/helper/test-tool.h     |  1 +
 t/test-lib.sh            |  3 ++-
 5 files changed, 24 insertions(+), 1 deletion(-)
 create mode 100644 t/helper/test-readlink.c

diff --git a/Makefile b/Makefile
index 45bd6ac9c3..2261e56d31 100644
--- a/Makefile
+++ b/Makefile
@@ -837,6 +837,7 @@ TEST_BUILTINS_OBJS += test-reach.o
 TEST_BUILTINS_OBJS += test-read-cache.o
 TEST_BUILTINS_OBJS += test-read-graph.o
 TEST_BUILTINS_OBJS += test-read-midx.o
+TEST_BUILTINS_OBJS += test-readlink.o
 TEST_BUILTINS_OBJS += test-ref-store.o
 TEST_BUILTINS_OBJS += test-reftable.o
 TEST_BUILTINS_OBJS += test-regex.o
diff --git a/t/helper/test-readlink.c b/t/helper/test-readlink.c
new file mode 100644
index 0000000000..c300dc8a1a
--- /dev/null
+++ b/t/helper/test-readlink.c
@@ -0,0 +1,19 @@
+#include "test-tool.h"
+#include "strbuf.h"
+
+static const char *usage_msg = "test-tool readlink file";
+
+int cmd__readlink(int ac, const char **av)
+{
+	struct strbuf buf;
+	int ret;
+
+	if (ac != 2 || !av[1])
+		usage(usage_msg);
+
+	ret = strbuf_readlink(&buf, av[1], 0);
+	if (!ret)
+		printf("%s\n", buf.buf);
+	strbuf_release(&buf);
+	return ret;
+}
diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c
index abe8a785eb..12054d13d4 100644
--- a/t/helper/test-tool.c
+++ b/t/helper/test-tool.c
@@ -64,6 +64,7 @@ static struct test_cmd cmds[] = {
 	{ "read-cache", cmd__read_cache },
 	{ "read-graph", cmd__read_graph },
 	{ "read-midx", cmd__read_midx },
+	{ "readlink", cmd__readlink },
 	{ "ref-store", cmd__ref_store },
 	{ "reftable", cmd__reftable },
 	{ "rot13-filter", cmd__rot13_filter },
diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h
index ea2672436c..efe382d48e 100644
--- a/t/helper/test-tool.h
+++ b/t/helper/test-tool.h
@@ -57,6 +57,7 @@ int cmd__reach(int argc, const char **argv);
 int cmd__read_cache(int argc, const char **argv);
 int cmd__read_graph(int argc, const char **argv);
 int cmd__read_midx(int argc, const char **argv);
+int cmd__readlink(int argc, const char **argv);
 int cmd__ref_store(int argc, const char **argv);
 int cmd__rot13_filter(int argc, const char **argv);
 int cmd__reftable(int argc, const char **argv);
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 01e88781dd..c8094f643b 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1773,7 +1773,8 @@ 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 >/dev/null &&
+	test "$(test-tool readlink y)" = x
 '
 
 test_lazy_prereq SYMLINKS_WINDOWS '
-- 
2.39.1-418-g7876265d61




^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-02-13 18:08 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-08 19:40 [PATCH] test: make SYMLINKS prerequisite more robust Junio C Hamano
2023-02-08 23:09 ` Ævar Arnfjörð Bjarmason
2023-02-09  1:56   ` Junio C Hamano
2023-02-09  2:15     ` Ævar Arnfjörð Bjarmason
2023-02-09 22:54       ` Junio C Hamano
2023-02-10 17:31     ` Junio C Hamano
2023-02-10 19:39       ` Ævar Arnfjörð Bjarmason
2023-02-13  9:12       ` Johannes Schindelin
2023-02-13 18:07         ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).