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

Re: [RFC PATCH 0/2] contrib/credential/netrc Makefile & test improvements

From
Luis Marsano <luis.marsano@gmail.com>
Date
Jun 9, 2018, 21:18 UTC
Message-ID
<CAHqJXRHGq9ofPcCzffUbTmuL6fuoB=33aZnwqNdqYy+nAVA_gw@mail.gmail.com>
In-Reply-To
<20180607051958.759-1-tmz@pobox.com>
Thanks for looking into this and addressing these issues.
On Thu, Jun 7, 2018 at 1:20 AM Todd Zullinger <tmz@pobox.com> wrote:
Show 15 quoted lines
>
> Hi,
>
> I noticed failures from the contrib/credential/netrc tests
> while building 2.18.0 release candidates.  I was surprised
> to see the tests being run when called with a simple 'make'
> command.
>
> The first patch in the series adds an empty 'all::' make
> target to match most of our other Makefiles and avoid the
> surprise of running tests by default.  (When the netrc
> helper was added to the fedora builds, it copied the same
> 'make -C contrib/credential/...' pattern from other
> credential helpers -- despite the lack of anything to
> build.)
I think this is a good idea.
> The actual test failures were initially due to my build
> environment lacking the perl autodie module, which was added
> in 786ef50a23 ("git-credential-netrc: accept gpg option",
> 2018-05-12).

I added 'use autodie;' without realizing it had external dependencies. According to the documentation http://perldoc.perl.org/autodie.html it's a pragma since perl 5.10.1 Removing 'use autodie;' should be fine: it's not critical.

> After installing the autodie module, the failures were due
> to the build environment lacking a git install (specifically
> the perl Git module).  The tests needing a pre-installed
> perl Git seemed odd and worth fixing.

I mistakenly thought 'use lib (split(/:/, $ENV{GITPERLLIB}));' in test.pl handled this. Since it doesn't, and I was only following an example from t/t9700/test.pl that doesn't fit, this line should be removed and it might make more sense to set the environment from t-git-credential-netrc.sh near '. ./test-lib.sh', which also sets the environment. Something like

diff --git a/contrib/credential/netrc/t-git-credential-netrc.sh
b/contrib/credential/netrc/t-git-credential-netrc.sh
index 58191a6..9e18611 100755
--- a/contrib/credential/netrc/t-git-credential-netrc.sh
+++ b/contrib/credential/netrc/t-git-credential-netrc.sh
@@ -23,5 +23,6 @@
        # The external test will outputs its own plan
        test_external_has_tap=1

+       export PERL5LIB="$GITPERLLIB"
        test_external \
     'git-credential-netrc' \

Your solution, however, is reasonable, and I don't know which is preferred.

> The second patch in the series aims to fix this.  I'm not
> sure if there's a better or more preferable way to fix this,
> which is one of the reasons for the RFC tag. (It's also why
> I added you to the Cc Ævar, as you're one of the
> knowledgeable perl folks here.)
>
> The other reason for the RFC tag is that I'm unsure of how
> to fix the last issue I found.  The tests exit cleanly even
> when there are failures, which seems undesirable.  I'm not
> familiar with the perl test_external framework to suggest a
> fix in patch form.  It might be a matter of adding something
> like this, from t/t9700/test.pl:
>
>     my $is_passing = eval { Test::More->is_passing };
>     exit($is_passing ? 0 : 1) unless $@ =~ /Can't locate object method/;
>
> ?  But that's a wild guess which I haven't tested.

Good idea.
It looks like you found an issue with t/t9700/test.pl, too.
When altered to fail, it first reports ok (then reports failed and
returns non-0).

not ok 46 - unquote simple quoted path
not ok 47 - unquote escape sequences
1..47
# test_external test Perl API was ok
# test_external_without_stderr test no stderr: Perl API failed: perl
/home/luism/project/git/t/t9700/test.pl:
$ echo $?
1

To make git-credential-netrc tests behave correctly, I ended up making
the changes below.
They might be okay, unless someone knows better.

diff --git a/contrib/credential/netrc/t-git-credential-netrc.sh
b/contrib/credential/netrc/t-git-credential-netrc.sh
index 58191a6..9e18611 100755
--- a/contrib/credential/netrc/t-git-credential-netrc.sh
+++ b/contrib/credential/netrc/t-git-credential-netrc.sh
@@ -23,9 +23,10 @@
        # The external test will outputs its own plan
        test_external_has_tap=1

+       export PERL5LIB="$GITPERLLIB"
        test_external \
     'git-credential-netrc' \
-    perl "$TEST_DIRECTORY"/../contrib/credential/netrc/test.pl
+    perl "$GIT_BUILD_DIR"/contrib/credential/netrc/test.pl

        test_done
 )
diff --git a/contrib/credential/netrc/test.pl b/contrib/credential/netrc/test.pl
index 1e10010..abc9081 100755
--- a/contrib/credential/netrc/test.pl
+++ b/contrib/credential/netrc/test.pl
@@ -1,6 +1,4 @@
 #!/usr/bin/perl
-use lib (split(/:/, $ENV{GITPERLLIB}));
-
 use warnings;
 use strict;
 use Test::More qw(no_plan);
@@ -12,7 +10,6 @@ BEGIN
        # t-git-credential-netrc.sh kicks off our testing, so we have to go
        # from there.
        Test::More->builder->current_test(1);
-       Test::More->builder->no_ending(1);
 }

 my @global_credential_args = @ARGV;
@@ -104,6 +101,9 @@ BEGIN

 ok(scalar keys %$cred == 2, 'Got keys decrypted by command option');

+my $is_passing = eval { Test::More->is_passing };
+exit($is_passing ? 0 : 1) unless $@ =~ /Can't locate object method/;
+
 sub run_credential
 {
        my $args = shift @_;
Previous: Todd ZullingerNext: Todd Zullinger
Message 4 of 20 in “contrib/credential/netrc Makefile & test improvements”
  1. 0/2 contrib/credential/netrc Makefile & test improvementsTodd Zullinger, Jun 7, 2018
  2. 1/2 git-credential-netrc: make "all" default target of MakefileTodd Zullinger, Jun 7, 2018
  3. 2/2 git-credential-netrc: use in-tree Git.pm for testsTodd Zullinger, Jun 7, 2018
  4. Luis MarsanoJun 9, 2018
  5. Todd ZullingerJun 10, 2018
  6. Ævar Arnfjörð BjarmasonJun 10, 2018
  7. Todd ZullingerJun 13, 2018
  8. Luis MarsanoJun 13, 2018
  9. git-credential-netrc: remove use of "autodie"Ævar Arnfjörð Bjarmason, Jun 13, 2018
  10. Junio C HamanoJun 13, 2018
  11. Todd ZullingerJun 13, 2018
  12. 0/4 contrib/credential/netrc Makefile & test improvementsTodd Zullinger, Jun 13, 2018
  13. Luis MarsanoJun 13, 2018
  14. 1/4 git-credential-netrc: make "all" default target of MakefileTodd Zullinger, Jun 13, 2018
  15. 2/4 git-credential-netrc: minor whitespace cleanup in test scriptTodd Zullinger, Jun 13, 2018
  16. Eric SunshineJun 13, 2018
  17. Todd ZullingerJun 13, 2018
  18. Eric SunshineJun 13, 2018
  19. 3/4 git-credential-netrc: use in-tree Git.pm for testsTodd Zullinger, Jun 13, 2018
  20. 4/4 git-credential-netrc: fix exit status when tests failTodd Zullinger, Jun 13, 2018

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.