diff mbox series

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

Message ID 20250218-b4-pks-meson-contrib-v1-2-c3edd292beb8@pks.im (mailing list archive)
State Superseded
Headers show
Series meson: wire up bits and pieces from "contrib/" | expand

Commit Message

Patrick Steinhardt Feb. 18, 2025, 7:45 a.m. UTC
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 mbox series

Patch

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}