From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH] test: make SYMLINKS prerequisite more robust
Date: Wed, 08 Feb 2023 11:40:04 -0800 [thread overview]
Message-ID: <xmqqwn4sq73f.fsf@gitster.g> (raw)
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
next reply other threads:[~2023-02-08 19:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-08 19:40 Junio C Hamano [this message]
2023-02-08 23:09 ` [PATCH] test: make SYMLINKS prerequisite more robust Æ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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqwn4sq73f.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).