{"thread":{"id":"55960","subject":"[PATCH] t: use portable wrapper for readlink(1)","startedAt":"2021-06-18T16:32:26Z","lastAt":"2021-06-19T06:20:59Z","messageCount":4,"participants":["Jeff King","brian m. carlson","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"427839","messageId":"YMzKlrmHFZdx2ti9@coredump.intra.peff.net","threadId":"55960","inReplyTo":null,"subject":"[PATCH] t: use portable wrapper for readlink(1)","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-06-18T16:32:22Z","receivedAt":"2021-06-18T16:32:26Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"Not all systems have a readlink program available for use by the shell.\nThis causes t3210 to fail on at least AIX. Let's provide a perl\none-liner to do the same thing, and use it there.\n\nI also updated calls in t9802. Nobody reported failure there, but it's\nthe same issue. Presumably nobody actually tests with p4 on AIX in the\nfirst place (if it is even available there).\n\nI left the use of readlink in the \"--valgrind\" setup in test-lib.sh, as\nvalgrind isn't available on exotic platforms anyway (and I didn't want\nto increase dependencies between test-lib.sh and test-lib-functions.sh).\n\nThere's one other curious case. Commit d2addc3b96 (t7800: readlink may\nnot be available, 2016-05-31) fixed a similar case. We can't use our\nwrapper function there, though, as it's inside a sub-script triggered by\nGit. It uses a slightly different technique (\"ls\" piped to \"sed\"). I\nchose not to use that here as it gives confusing \"ls -l\" output if the\nfile is unexpectedly not a symlink (which is OK for its limited use, but\npotentially confusing for general use within the test suite). The perl\nversion emits the empty string.\n\nReported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\nSigned-off-by: Jeff King <peff@peff.net>\n---\nThis is a re-post that doesn't seem to have made it into \"seen\"; the\noriginal[1] was buried in a thread, but Ævar reported there that it\nfixes t3210 on his AIX build.\n\n[1] https://lore.kernel.org/git/YLk0Zm2J6VOA%2Flks@coredump.intra.peff.net/\n\n t/t3210-pack-refs.sh       | 2 +-\n t/t9802-git-p4-filetype.sh | 4 ++--\n t/test-lib-functions.sh    | 6 ++++++\n 3 files changed, 9 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t3210-pack-refs.sh b/t/t3210-pack-refs.sh\nindex 3b7cdc56ec..577f32dc71 100755\n--- a/t/t3210-pack-refs.sh\n+++ b/t/t3210-pack-refs.sh\n@@ -253,7 +253,7 @@ test_expect_success SYMLINKS 'pack symlinked packed-refs' '\n \tgit for-each-ref >all-refs-packed &&\n \ttest_cmp all-refs-before all-refs-packed &&\n \ttest -h .git/packed-refs &&\n-\ttest \"$(readlink .git/packed-refs)\" = \"my-deviant-packed-refs\"\n+\ttest \"$(test_readlink .git/packed-refs)\" = \"my-deviant-packed-refs\"\n '\n \n test_done\ndiff --git a/t/t9802-git-p4-filetype.sh b/t/t9802-git-p4-filetype.sh\nindex 94edebe272..19073c6e9f 100755\n--- a/t/t9802-git-p4-filetype.sh\n+++ b/t/t9802-git-p4-filetype.sh\n@@ -263,7 +263,7 @@ test_expect_success SYMLINKS 'ensure p4 symlink parsed correctly' '\n \t(\n \t\tcd \"$git\" &&\n \t\ttest -L symlink &&\n-\t\ttest $(readlink symlink) = symlink-target\n+\t\ttest $(test_readlink symlink) = symlink-target\n \t)\n '\n \n@@ -329,7 +329,7 @@ test_expect_success SYMLINKS 'empty symlink target' '\n \tgit p4 clone --dest=\"$git\" //depot@all &&\n \t(\n \t\tcd \"$git\" &&\n-\t\ttest $(readlink empty-symlink) = target2\n+\t\ttest $(test_readlink empty-symlink) = target2\n \t)\n '\n \ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex f0448daa74..b2810478a2 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -1708,3 +1708,9 @@ test_region () {\n \n \treturn 0\n }\n+\n+# Print the destination of symlink(s) provided as arguments. Basically\n+# the same as the readlink command, but it's not available everywhere.\n+test_readlink () {\n+\tperl -le 'print readlink($_) for @ARGV' \"$@\"\n+}\n-- \n2.32.0.352.gff02c21e72\n"},{"id":"427896","messageId":"YMzwWxkQXjDT+mi+@camp.crustytoothpaste.net","threadId":"55960","inReplyTo":"YMzKlrmHFZdx2ti9@coredump.intra.peff.net","subject":"Re: [PATCH] t: use portable wrapper for readlink(1)","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2021-06-18T19:13:31Z","receivedAt":"2021-06-18T19:14:08Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2021-06-18 at 16:32:22, Jeff King wrote:\n> Not all systems have a readlink program available for use by the shell.\n> This causes t3210 to fail on at least AIX. Let's provide a perl\n> one-liner to do the same thing, and use it there.\n> \n> I also updated calls in t9802. Nobody reported failure there, but it's\n> the same issue. Presumably nobody actually tests with p4 on AIX in the\n> first place (if it is even available there).\n> \n> I left the use of readlink in the \"--valgrind\" setup in test-lib.sh, as\n> valgrind isn't available on exotic platforms anyway (and I didn't want\n> to increase dependencies between test-lib.sh and test-lib-functions.sh).\n> \n> There's one other curious case. Commit d2addc3b96 (t7800: readlink may\n> not be available, 2016-05-31) fixed a similar case. We can't use our\n> wrapper function there, though, as it's inside a sub-script triggered by\n> Git. It uses a slightly different technique (\"ls\" piped to \"sed\"). I\n> chose not to use that here as it gives confusing \"ls -l\" output if the\n> file is unexpectedly not a symlink (which is OK for its limited use, but\n> potentially confusing for general use within the test suite). The perl\n> version emits the empty string.\n> \n> Reported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> Signed-off-by: Jeff King <peff@peff.net>\n> ---\n> This is a re-post that doesn't seem to have made it into \"seen\"; the\n> original[1] was buried in a thread, but Ævar reported there that it\n> fixes t3210 on his AIX build.\n>\n> [1] https://lore.kernel.org/git/YLk0Zm2J6VOA%2Flks@coredump.intra.peff.net/\n\nIn case I didn't say it up in the previous post, this looks fine to me.\nUsing Perl here seems like a fine solution.  If we needed to in the\nfuture, we could add this to test-tool and use the real readlink(2), but\nwe can hold off until we decide we need to.\n-- \nbrian m. carlson (he/him or they/them)\nToronto, Ontario, CA\n"},{"id":"427897","messageId":"YMz4eFmwFuPv3Ke+@coredump.intra.peff.net","threadId":"55960","inReplyTo":"YMzwWxkQXjDT+mi+@camp.crustytoothpaste.net","subject":"Re: [PATCH] t: use portable wrapper for readlink(1)","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-06-18T19:48:08Z","receivedAt":"2021-06-18T19:48:11Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Jun 18, 2021 at 07:13:31PM +0000, brian m. carlson wrote:\n\n> > This is a re-post that doesn't seem to have made it into \"seen\"; the\n> > original[1] was buried in a thread, but Ævar reported there that it\n> > fixes t3210 on his AIX build.\n> >\n> > [1] https://lore.kernel.org/git/YLk0Zm2J6VOA%2Flks@coredump.intra.peff.net/\n> \n> In case I didn't say it up in the previous post, this looks fine to me.\n> Using Perl here seems like a fine solution.  If we needed to in the\n> future, we could add this to test-tool and use the real readlink(2), but\n> we can hold off until we decide we need to.\n\nAgreed on all counts (if we do want to drop perl from the test suite,\nthere are a lot of these little one-liners that would need converting).\n\nThanks.\n\n-Peff\n"},{"id":"427941","messageId":"xmqqbl82l6ij.fsf@gitster.g","threadId":"55960","inReplyTo":"YMzKlrmHFZdx2ti9@coredump.intra.peff.net","subject":"Re: [PATCH] t: use portable wrapper for readlink(1)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-06-19T06:20:52Z","receivedAt":"2021-06-19T06:20:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> Not all systems have a readlink program available for use by the shell.\n> This causes t3210 to fail on at least AIX. Let's provide a perl\n> one-liner to do the same thing, and use it there.\n>\n> I also updated calls in t9802. Nobody reported failure there, but it's\n> the same issue. Presumably nobody actually tests with p4 on AIX in the\n> first place (if it is even available there).\n>\n> I left the use of readlink in the \"--valgrind\" setup in test-lib.sh, as\n> valgrind isn't available on exotic platforms anyway (and I didn't want\n> to increase dependencies between test-lib.sh and test-lib-functions.sh).\n>\n> There's one other curious case. Commit d2addc3b96 (t7800: readlink may\n> not be available, 2016-05-31) fixed a similar case. We can't use our\n> wrapper function there, though, as it's inside a sub-script triggered by\n> Git. It uses a slightly different technique (\"ls\" piped to \"sed\"). I\n> chose not to use that here as it gives confusing \"ls -l\" output if the\n> file is unexpectedly not a symlink (which is OK for its limited use, but\n> potentially confusing for general use within the test suite). The perl\n> version emits the empty string.\n>\n> Reported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> Signed-off-by: Jeff King <peff@peff.net>\n> ---\n> This is a re-post that doesn't seem to have made it into \"seen\"; the\n> original[1] was buried in a thread, but Ævar reported there that it\n> fixes t3210 on his AIX build.\n\nYeah, I think I've seen this one and thought I have queued it.\nThanks for resurrecting.\n\nBy the way, I'll be mostly offline next week and won't be back to\nfull speed til the end of the month (it's time to migrate in the\nother direction).\n\n> [1] https://lore.kernel.org/git/YLk0Zm2J6VOA%2Flks@coredump.intra.peff.net/\n>\n>  t/t3210-pack-refs.sh       | 2 +-\n>  t/t9802-git-p4-filetype.sh | 4 ++--\n>  t/test-lib-functions.sh    | 6 ++++++\n>  3 files changed, 9 insertions(+), 3 deletions(-)\n>\n> diff --git a/t/t3210-pack-refs.sh b/t/t3210-pack-refs.sh\n> index 3b7cdc56ec..577f32dc71 100755\n> --- a/t/t3210-pack-refs.sh\n> +++ b/t/t3210-pack-refs.sh\n> @@ -253,7 +253,7 @@ test_expect_success SYMLINKS 'pack symlinked packed-refs' '\n>  \tgit for-each-ref >all-refs-packed &&\n>  \ttest_cmp all-refs-before all-refs-packed &&\n>  \ttest -h .git/packed-refs &&\n> -\ttest \"$(readlink .git/packed-refs)\" = \"my-deviant-packed-refs\"\n> +\ttest \"$(test_readlink .git/packed-refs)\" = \"my-deviant-packed-refs\"\n>  '\n>  \n>  test_done\n> diff --git a/t/t9802-git-p4-filetype.sh b/t/t9802-git-p4-filetype.sh\n> index 94edebe272..19073c6e9f 100755\n> --- a/t/t9802-git-p4-filetype.sh\n> +++ b/t/t9802-git-p4-filetype.sh\n> @@ -263,7 +263,7 @@ test_expect_success SYMLINKS 'ensure p4 symlink parsed correctly' '\n>  \t(\n>  \t\tcd \"$git\" &&\n>  \t\ttest -L symlink &&\n> -\t\ttest $(readlink symlink) = symlink-target\n> +\t\ttest $(test_readlink symlink) = symlink-target\n>  \t)\n>  '\n>  \n> @@ -329,7 +329,7 @@ test_expect_success SYMLINKS 'empty symlink target' '\n>  \tgit p4 clone --dest=\"$git\" //depot@all &&\n>  \t(\n>  \t\tcd \"$git\" &&\n> -\t\ttest $(readlink empty-symlink) = target2\n> +\t\ttest $(test_readlink empty-symlink) = target2\n>  \t)\n>  '\n>  \n> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\n> index f0448daa74..b2810478a2 100644\n> --- a/t/test-lib-functions.sh\n> +++ b/t/test-lib-functions.sh\n> @@ -1708,3 +1708,9 @@ test_region () {\n>  \n>  \treturn 0\n>  }\n> +\n> +# Print the destination of symlink(s) provided as arguments. Basically\n> +# the same as the readlink command, but it's not available everywhere.\n> +test_readlink () {\n> +\tperl -le 'print readlink($_) for @ARGV' \"$@\"\n> +}\n"}]}