Skip to content

Commit fd21e6e

Browse files
pks-tgitster
authored andcommitted
contrib/credential: fix "netrc" tests with out-of-tree builds
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c582364 commit fd21e6e

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

contrib/credential/netrc/t-git-credential-netrc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
export PERL5LIB="$GITPERLLIB"
1717
test_expect_success 'git-credential-netrc' '
18-
perl "$GIT_BUILD_DIR"/contrib/credential/netrc/test.pl
18+
perl "$GIT_SOURCE_DIR"/contrib/credential/netrc/test.pl
1919
'
2020

2121
test_done

contrib/credential/netrc/test.pl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ BEGIN
1515

1616
my @global_credential_args = @ARGV;
1717
my $scriptDir = dirname rel2abs $0;
18-
my ($netrc, $netrcGpg, $gcNetrc) = map { catfile $scriptDir, $_; }
18+
my ($netrc, $netrcGpg) = map { catfile $scriptDir, $_; }
1919
qw(test.netrc
20-
test.netrc.gpg
21-
git-credential-netrc);
20+
test.netrc.gpg);
21+
my $gcNetrc = $ENV{CREDENTIAL_NETRC_PATH} || catfile $scriptDir, qw(git-credential-netrc);
22+
2223
local $ENV{PATH} = join ':'
2324
, $scriptDir
2425
, $ENV{PATH}

0 commit comments

Comments
 (0)