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

[PATCH 02/12] contrib/credential: fix "netrc" tests with out-of-tree builds

From
Patrick Steinhardt <ps@pks.im>
Date
Feb 18, 2025, 07:45 UTC
Message-ID
<20250218-b4-pks-meson-contrib-v1-2-c3edd292beb8@pks.im>
In-Reply-To
<20250218-b4-pks-meson-contrib-v1-0-c3edd292beb8@pks.im>

Tests of the "netrc" credential helper aren't prepared to handle out-of-tree builds:

  - They expect the "test.pl" script to be located relative to the build
    directory, even though it is located in the source directory.
  - They expect the built "git-credential-netrc" helper to be located
    relative to the "test.pl" file, evne though it is loated in the
    build directory.

This works alright as long as source and build directories are the same, but starts to break apart with Meson.

Fix these first issue by using the new "GIT_SOURCE_DIR" variable to locate the test script itself. And fix the second issue by introducing a new environment variable "CREDENTIAL_NETRC_PATH" that can be set for out-of-tree builds to locate the built credential helper.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 contrib/credential/netrc/t-git-credential-netrc.sh | 2 +-
 contrib/credential/netrc/test.pl                   | 7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/contrib/credential/netrc/t-git-credential-netrc.sh b/contrib/credential/netrc/t-git-credential-netrc.sh
index bf2777308a5..1b7b8b3a9aa 100755
--- a/contrib/credential/netrc/t-git-credential-netrc.sh
+++ b/contrib/credential/netrc/t-git-credential-netrc.sh
@@ -15,7 +15,7 @@
 
 	export PERL5LIB="$GITPERLLIB"
 	test_expect_success 'git-credential-netrc' '
-		perl "$GIT_BUILD_DIR"/contrib/credential/netrc/test.pl
+		perl "$GIT_SOURCE_DIR"/contrib/credential/netrc/test.pl
 	'
 
 	test_done
diff --git a/contrib/credential/netrc/test.pl b/contrib/credential/netrc/test.pl
index c0fb3718b28..67a0ede5644 100755
--- a/contrib/credential/netrc/test.pl
+++ b/contrib/credential/netrc/test.pl
@@ -15,10 +15,11 @@ BEGIN
 
 my @global_credential_args = @ARGV;
 my $scriptDir = dirname rel2abs $0;
-my ($netrc, $netrcGpg, $gcNetrc) = map { catfile $scriptDir, $_; }
+my ($netrc, $netrcGpg) = map { catfile $scriptDir, $_; }
                                        qw(test.netrc
-                                          test.netrc.gpg
-                                          git-credential-netrc);
+                                          test.netrc.gpg);
+my $gcNetrc = $ENV{CREDENTIAL_NETRC_PATH} || catfile $scriptDir, qw(git-credential-netrc);
+
 local $ENV{PATH} = join ':'
                       , $scriptDir
                       , $ENV{PATH}
-- 
2.48.1.666.gff9fcf71b7.dirty
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 3 of 37 in “meson: wire up bits and pieces from "contrib/"”
  1. 00/12 meson: wire up bits and pieces from "contrib/"Patrick Steinhardt, Feb 18, 2025
  2. 01/12 GIT-BUILD-OPTIONS: propagate project's source directoryPatrick Steinhardt, Feb 18, 2025
  3. 02/12 contrib/credential: fix "netrc" tests with out-of-tree buildsPatrick Steinhardt, Feb 18, 2025
  4. 03/12 contrib/credential: fix compilation of wincred helper with MSVCPatrick Steinhardt, Feb 18, 2025
  5. 05/12 contrib/credential: fix compilation of "osxkeychain" helperPatrick Steinhardt, Feb 18, 2025
  6. 04/12 contrib/credential: fix compiling "libsecret" helperPatrick Steinhardt, Feb 18, 2025
  7. 06/12 meson: wire up credential helpersPatrick Steinhardt, Feb 18, 2025
  8. M HickfordFeb 18, 2025
  9. Patrick SteinhardtFeb 18, 2025
  10. M HickfordMar 29, 2025
  11. Patrick SteinhardtMar 31, 2025
  12. 07/12 meson: wire up git-contacts(1)Patrick Steinhardt, Feb 18, 2025
  13. 08/12 meson: wire up static analysis via CoccinellePatrick Steinhardt, Feb 18, 2025
  14. 09/12 gitk: extract script to build GitkPatrick Steinhardt, Feb 18, 2025
  15. Junio C HamanoFeb 18, 2025
  16. Patrick SteinhardtFeb 19, 2025
  17. Johannes SixtFeb 19, 2025
  18. Patrick SteinhardtFeb 19, 2025
  19. Johannes SixtFeb 19, 2025
  20. 10/12 meson: wire up GitkPatrick Steinhardt, Feb 18, 2025
  21. 11/12 ci: fix propagating UTF-8 test locale in musl-based Meson jobPatrick Steinhardt, Feb 18, 2025
  22. 12/12 ci: exercise credential helpersPatrick Steinhardt, Feb 18, 2025
  23. M HickfordFeb 18, 2025
  24. 00/10 meson: wire up bits and pieces from "contrib/"Patrick Steinhardt, Feb 19, 2025
  25. 01/10 GIT-BUILD-OPTIONS: propagate project's source directoryPatrick Steinhardt, Feb 19, 2025
  26. 02/10 contrib/credential: fix "netrc" tests with out-of-tree buildsPatrick Steinhardt, Feb 19, 2025
  27. 03/10 contrib/credential: fix compilation of wincred helper with MSVCPatrick Steinhardt, Feb 19, 2025
  28. 05/10 contrib/credential: fix compilation of "osxkeychain" helperPatrick Steinhardt, Feb 19, 2025
  29. 04/10 contrib/credential: fix compiling "libsecret" helperPatrick Steinhardt, Feb 19, 2025
  30. 06/10 meson: wire up credential helpersPatrick Steinhardt, Feb 19, 2025
  31. 07/10 meson: wire up git-contacts(1)Patrick Steinhardt, Feb 19, 2025
  32. 08/10 meson: wire up static analysis via CoccinellePatrick Steinhardt, Feb 19, 2025
  33. 09/10 ci: fix propagating UTF-8 test locale in musl-based Meson jobPatrick Steinhardt, Feb 19, 2025
  34. 10/10 ci: exercise credential helpersPatrick Steinhardt, Feb 19, 2025
  35. Ramsay JonesFeb 20, 2025
  36. Patrick SteinhardtFeb 20, 2025
  37. Ramsay JonesFeb 21, 2025

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.