Re: [PATCH 1/2] git-credential-netrc: adapt to test framework for git

2018-05-14 Thread Luis Marsano
Junio C Hamano  wrote:

> Luis Marsano  writes:
> 
> > until this change, git-credential-netrc did not test in a repository
> > this change reuses the main test framework, which provides such tests
> > specific changes
> 
> Sorry, but I cannot quite parse what the above is trying to say.
> 
[⋮]
> 
> Will queue, but may need to make the log message
> readable/understandable.
> 
> Thanks.

Thank you, the rewrite 
https://public-inbox.org/git/20180512091728.4931-2-luis.mars...@gmail.com/ 
should be more intelligible.
I welcome further criticisms if any.


Re: [PATCH 1/2] git-credential-netrc: adapt to test framework for git

2018-05-10 Thread Junio C Hamano
Luis Marsano  writes:

> until this change, git-credential-netrc did not test in a repository
> this change reuses the main test framework, which provides such tests
> specific changes

Sorry, but I cannot quite parse what the above is trying to say.

> - switch to Test::More module
> - use File::Basename & File::Spec::Functions
>
> Signed-off-by: Luis Marsano 
> Acked-by: Ted Zlatanov 
> ---
>  contrib/credential/netrc/Makefile |  4 +-
>  .../netrc/t-git-credential-netrc.sh   | 31 
>  contrib/credential/netrc/test.pl  | 73 ---
>  3 files changed, 78 insertions(+), 30 deletions(-)
>  create mode 100755 contrib/credential/netrc/t-git-credential-netrc.sh

Will queue, but may need to make the log message
readable/understandable.

Thanks.


[PATCH 1/2] git-credential-netrc: adapt to test framework for git

2018-05-09 Thread Luis Marsano
until this change, git-credential-netrc did not test in a repository
this change reuses the main test framework, which provides such tests
specific changes
- switch to Test::More module
- use File::Basename & File::Spec::Functions

Signed-off-by: Luis Marsano 
Acked-by: Ted Zlatanov 
---
 contrib/credential/netrc/Makefile |  4 +-
 .../netrc/t-git-credential-netrc.sh   | 31 
 contrib/credential/netrc/test.pl  | 73 ---
 3 files changed, 78 insertions(+), 30 deletions(-)
 create mode 100755 contrib/credential/netrc/t-git-credential-netrc.sh

diff --git a/contrib/credential/netrc/Makefile 
b/contrib/credential/netrc/Makefile
index 51b76138a..0ffa40719 100644
--- a/contrib/credential/netrc/Makefile
+++ b/contrib/credential/netrc/Makefile
@@ -1,5 +1,5 @@
 test:
-   ./test.pl
+   ./t-git-credential-netrc.sh
 
 testverbose:
-   ./test.pl -d -v
+   ./t-git-credential-netrc.sh -d -v
diff --git a/contrib/credential/netrc/t-git-credential-netrc.sh 
b/contrib/credential/netrc/t-git-credential-netrc.sh
new file mode 100755
index 0..fa21ca240
--- /dev/null
+++ b/contrib/credential/netrc/t-git-credential-netrc.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+(
+   cd ../../../t
+   test_description='git-credential-netrc'
+   . ./test-lib.sh
+
+   if ! test_have_prereq PERL; then
+   skip_all='skipping perl interface tests, perl not available'
+   test_done
+   fi
+
+   perl -MTest::More -e 0 2>/dev/null || {
+   skip_all="Perl Test::More unavailable, skipping test"
+   test_done
+   }
+
+   # set up test repository
+
+   test_expect_success \
+'set up test repository' \
+':'
+
+   # The external test will outputs its own plan
+   test_external_has_tap=1
+
+   test_external \
+'git-credential-netrc' \
+perl "$TEST_DIRECTORY"/../contrib/credential/netrc/test.pl
+
+   test_done
+)
diff --git a/contrib/credential/netrc/test.pl b/contrib/credential/netrc/test.pl
index 169b6463c..7211b4857 100755
--- a/contrib/credential/netrc/test.pl
+++ b/contrib/credential/netrc/test.pl
@@ -1,83 +1,100 @@
 #!/usr/bin/perl
+use lib (split(/:/, $ENV{GITPERLLIB}));
 
 use warnings;
 use strict;
-use Test;
+use Test::More qw(no_plan);
+use File::Basename;
+use File::Spec::Functions qw(:DEFAULT rel2abs);
 use IPC::Open2;
 
-BEGIN { plan tests => 15 }
+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;
-my $netrc = './test.netrc';
-print "# Testing insecure file, nothing should be found\n";
+my $scriptDir = dirname rel2abs $0;
+my $netrc = catfile $scriptDir, 'test.netrc';
+my $netrcGpg = catfile $scriptDir, 'test.netrc.gpg';
+my $gcNetrc = catfile $scriptDir, 'git-credential-netrc';
+local $ENV{PATH} = join ':'
+  , $scriptDir
+  , $ENV{PATH}
+  ? $ENV{PATH}
+  : ();
+
+diag "Testing insecure file, nothing should be found\n";
 chmod 0644, $netrc;
 my $cred = run_credential(['-f', $netrc, 'get'],
  { host => 'github.com' });
 
-ok(scalar keys %$cred, 0, "Got 0 keys from insecure file");
+ok(scalar keys %$cred == 0, "Got 0 keys from insecure file");
 
-print "# Testing missing file, nothing should be found\n";
+diag "Testing missing file, nothing should be found\n";
 chmod 0644, $netrc;
 $cred = run_credential(['-f', '///nosuchfile///', 'get'],
   { host => 'github.com' });
 
-ok(scalar keys %$cred, 0, "Got 0 keys from missing file");
+ok(scalar keys %$cred == 0, "Got 0 keys from missing file");
 
 chmod 0600, $netrc;
 
-print "# Testing with invalid data\n";
+diag "Testing with invalid data\n";
 $cred = run_credential(['-f', $netrc, 'get'],
   "bad data");
-ok(scalar keys %$cred, 4, "Got first found keys with bad data");
+ok(scalar keys %$cred == 4, "Got first found keys with bad data");
 
-print "# Testing netrc file for a missing corovamilkbar entry\n";
+diag "Testing netrc file for a missing corovamilkbar entry\n";
 $cred = run_credential(['-f', $netrc, 'get'],
   { host => 'corovamilkbar' });
 
-ok(scalar keys %$cred, 0, "Got no corovamilkbar keys");
+ok(scalar keys %$cred == 0, "Got no corovamilkbar keys");
 
-print "# Testing netrc file for a github.com entry\n";
+diag "Testing netrc file for a github.com entry\n";
 $cred = run_credential(['-f', $netrc, 'get'],
   { host => 'github.com' });
 
-ok(scalar keys %$cred, 2, "Got 2 Github keys");
+ok(scalar keys %$cred == 2, "Got 2 Github keys");
 
-ok($cred->{password}, 'carolknows', "Got correct Github password");
-ok($cred->{username}, 'carol', "Got correct Github username");
+is($cred->{password}, 'carolknows', "Got