public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
* [PATCH] t7510: Skip all if GPG isn't installed
@ 2014-06-24  4:52 Brian Gernhardt
  2014-06-25 21:16 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Brian Gernhardt @ 2014-06-24  4:52 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano

Since the setup requires the GPG prerequisite, it doesn't make much
sense to try and run any tests without it.  So rather than using a
prereq on each individual test and possibly forgetting it on new ones
(as just happened), skip the entire file if GPG isn't found.

Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware•com>
---
 t/t7510-signed-commit.sh | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh
index 9810242..414f9d1 100755
--- a/t/t7510-signed-commit.sh
+++ b/t/t7510-signed-commit.sh
@@ -4,7 +4,13 @@ test_description='signed commit tests'
 . ./test-lib.sh
 . "$TEST_DIRECTORY/lib-gpg.sh"
 
-test_expect_success GPG 'create signed commits' '
+if ! test_have_prereq GPG
+then
+	skip_all='skipping signed commit tests; gpg not available'
+	test_done
+fi
+
+test_expect_success 'create signed commits' '
 	test_when_finished "test_unconfig commit.gpgsign" &&
 
 	echo 1 >file && git add file &&
@@ -48,7 +54,7 @@ test_expect_success GPG 'create signed commits' '
 	git tag eighth-signed-alt
 '
 
-test_expect_success GPG 'show signatures' '
+test_expect_success 'show signatures' '
 	(
 		for commit in initial second merge fourth-signed fifth-signed sixth-signed seventh-signed
 		do
@@ -79,7 +85,7 @@ test_expect_success GPG 'show signatures' '
 	)
 '
 
-test_expect_success GPG 'detect fudged signature' '
+test_expect_success 'detect fudged signature' '
 	git cat-file commit seventh-signed >raw &&
 
 	sed -e "s/seventh/7th forged/" raw >forged1 &&
@@ -89,7 +95,7 @@ test_expect_success GPG 'detect fudged signature' '
 	! grep "Good signature from" actual1
 '
 
-test_expect_success GPG 'detect fudged signature with NUL' '
+test_expect_success 'detect fudged signature with NUL' '
 	git cat-file commit seventh-signed >raw &&
 	cat raw >forged2 &&
 	echo Qwik | tr "Q" "\000" >>forged2 &&
@@ -99,7 +105,7 @@ test_expect_success GPG 'detect fudged signature with NUL' '
 	! grep "Good signature from" actual2
 '
 
-test_expect_success GPG 'amending already signed commit' '
+test_expect_success 'amending already signed commit' '
 	git checkout fourth-signed^0 &&
 	git commit --amend -S --no-edit &&
 	git show -s --show-signature HEAD >actual &&
@@ -107,7 +113,7 @@ test_expect_success GPG 'amending already signed commit' '
 	! grep "BAD signature from" actual
 '
 
-test_expect_success GPG 'show good signature with custom format' '
+test_expect_success 'show good signature with custom format' '
 	cat >expect <<-\EOF &&
 	G
 	13B6F51ECDDE430D
@@ -117,7 +123,7 @@ test_expect_success GPG 'show good signature with custom format' '
 	test_cmp expect actual
 '
 
-test_expect_success GPG 'show bad signature with custom format' '
+test_expect_success 'show bad signature with custom format' '
 	cat >expect <<-\EOF &&
 	B
 	13B6F51ECDDE430D
@@ -127,7 +133,7 @@ test_expect_success GPG 'show bad signature with custom format' '
 	test_cmp expect actual
 '
 
-test_expect_success GPG 'show unknown signature with custom format' '
+test_expect_success 'show unknown signature with custom format' '
 	cat >expect <<-\EOF &&
 	U
 	61092E85B7227189
@@ -137,7 +143,7 @@ test_expect_success GPG 'show unknown signature with custom format' '
 	test_cmp expect actual
 '
 
-test_expect_success GPG 'show lack of signature with custom format' '
+test_expect_success 'show lack of signature with custom format' '
 	cat >expect <<-\EOF &&
 	N
 
-- 
2.0.0.495.gf681aa8

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] t7510: Skip all if GPG isn't installed
  2014-06-24  4:52 [PATCH] t7510: Skip all if GPG isn't installed Brian Gernhardt
@ 2014-06-25 21:16 ` Junio C Hamano
  2014-06-25 21:42   ` Jeff King
  0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2014-06-25 21:16 UTC (permalink / raw)
  To: Brian Gernhardt; +Cc: Git List, Jeff King

Brian Gernhardt <brian@gernhardtsoftware•com> writes:

> Since the setup requires the GPG prerequisite, it doesn't make much
> sense to try and run any tests without it.  So rather than using a
> prereq on each individual test and possibly forgetting it on new ones
> (as just happened), skip the entire file if GPG isn't found.
>
> Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware•com>
> ---

I think by "just happend" you mean aa4b78d4 (pretty: avoid reading
past end-of-string with "%G", 2014-06-16), which adds one that is
not protected (Cc'ed peff).

As there are a few additional test pieces to this file in flight
that come from another topic (which by the way protects them with
the prerequiste), I'd rather fix it up with the necessary GPG
prerequisite, at least for now, instead of doing it this way.

After the dust settles, we should definitely consider taking the
approach of this patch to simplify everything, but not now.

Another thing we may want to take into account is that we would also
want to make sure that builds of Git without GPG installed still
behave sensibly (with some definition of sensible) when faced with
GPG signatures in existing commit objects and tag objects.  I do not
think we currently test that combination at all, but we may want to
introduce a new directory t/t7510/ to hold store pre-existing commit
objects in the loose form (or in the textual form, suitable for
fast-import) and use them to populate the test repository in the
set-up step.  And new test pieces that do not require GPG (or those
that do require that GPG is *not* installed) would make sure that
various commands like "show --show-signature", "verify-commit" would
say "I cannot verify them" but still do what they are asked to do in
a sensible way (e.g. "show --show-signature" may not be able to show
the signature obviously but still will give you the header, the log
message and the patch; "verify-commit" should fail because it cannot
verify).  If that will happen in this same script, then skipping all
by requiring GPG upfront may not be a good change, but it is likely
that we would want a NOGPG prerequisite for "No GPG installed" case
and have a separate test script, in which case, this will just skip
all without GPG, and the other new one will just skip all without
NOGPG.  We'll see.


>  t/t7510-signed-commit.sh | 24 +++++++++++++++---------
>  1 file changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh
> index 9810242..414f9d1 100755
> --- a/t/t7510-signed-commit.sh
> +++ b/t/t7510-signed-commit.sh
> @@ -4,7 +4,13 @@ test_description='signed commit tests'
>  . ./test-lib.sh
>  . "$TEST_DIRECTORY/lib-gpg.sh"
>  
> -test_expect_success GPG 'create signed commits' '
> +if ! test_have_prereq GPG
> +then
> +	skip_all='skipping signed commit tests; gpg not available'
> +	test_done
> +fi
> +
> +test_expect_success 'create signed commits' '
>  	test_when_finished "test_unconfig commit.gpgsign" &&
>  
>  	echo 1 >file && git add file &&
> @@ -48,7 +54,7 @@ test_expect_success GPG 'create signed commits' '
>  	git tag eighth-signed-alt
>  '
>  
> -test_expect_success GPG 'show signatures' '
> +test_expect_success 'show signatures' '
>  	(
>  		for commit in initial second merge fourth-signed fifth-signed sixth-signed seventh-signed
>  		do
> @@ -79,7 +85,7 @@ test_expect_success GPG 'show signatures' '
>  	)
>  '
>  
> -test_expect_success GPG 'detect fudged signature' '
> +test_expect_success 'detect fudged signature' '
>  	git cat-file commit seventh-signed >raw &&
>  
>  	sed -e "s/seventh/7th forged/" raw >forged1 &&
> @@ -89,7 +95,7 @@ test_expect_success GPG 'detect fudged signature' '
>  	! grep "Good signature from" actual1
>  '
>  
> -test_expect_success GPG 'detect fudged signature with NUL' '
> +test_expect_success 'detect fudged signature with NUL' '
>  	git cat-file commit seventh-signed >raw &&
>  	cat raw >forged2 &&
>  	echo Qwik | tr "Q" "\000" >>forged2 &&
> @@ -99,7 +105,7 @@ test_expect_success GPG 'detect fudged signature with NUL' '
>  	! grep "Good signature from" actual2
>  '
>  
> -test_expect_success GPG 'amending already signed commit' '
> +test_expect_success 'amending already signed commit' '
>  	git checkout fourth-signed^0 &&
>  	git commit --amend -S --no-edit &&
>  	git show -s --show-signature HEAD >actual &&
> @@ -107,7 +113,7 @@ test_expect_success GPG 'amending already signed commit' '
>  	! grep "BAD signature from" actual
>  '
>  
> -test_expect_success GPG 'show good signature with custom format' '
> +test_expect_success 'show good signature with custom format' '
>  	cat >expect <<-\EOF &&
>  	G
>  	13B6F51ECDDE430D
> @@ -117,7 +123,7 @@ test_expect_success GPG 'show good signature with custom format' '
>  	test_cmp expect actual
>  '
>  
> -test_expect_success GPG 'show bad signature with custom format' '
> +test_expect_success 'show bad signature with custom format' '
>  	cat >expect <<-\EOF &&
>  	B
>  	13B6F51ECDDE430D
> @@ -127,7 +133,7 @@ test_expect_success GPG 'show bad signature with custom format' '
>  	test_cmp expect actual
>  '
>  
> -test_expect_success GPG 'show unknown signature with custom format' '
> +test_expect_success 'show unknown signature with custom format' '
>  	cat >expect <<-\EOF &&
>  	U
>  	61092E85B7227189
> @@ -137,7 +143,7 @@ test_expect_success GPG 'show unknown signature with custom format' '
>  	test_cmp expect actual
>  '
>  
> -test_expect_success GPG 'show lack of signature with custom format' '
> +test_expect_success 'show lack of signature with custom format' '
>  	cat >expect <<-\EOF &&
>  	N

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] t7510: Skip all if GPG isn't installed
  2014-06-25 21:16 ` Junio C Hamano
@ 2014-06-25 21:42   ` Jeff King
  2014-06-25 22:24     ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff King @ 2014-06-25 21:42 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Brian Gernhardt, Git List

On Wed, Jun 25, 2014 at 02:16:55PM -0700, Junio C Hamano wrote:

> Brian Gernhardt <brian@gernhardtsoftware•com> writes:
> 
> > Since the setup requires the GPG prerequisite, it doesn't make much
> > sense to try and run any tests without it.  So rather than using a
> > prereq on each individual test and possibly forgetting it on new ones
> > (as just happened), skip the entire file if GPG isn't found.
> >
> > Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware•com>
> > ---
> 
> I think by "just happend" you mean aa4b78d4 (pretty: avoid reading
> past end-of-string with "%G", 2014-06-16), which adds one that is
> not protected (Cc'ed peff).

If that is the one Brian means (and that is the only one I see in pu),
leaving it off was intentional. You do not need to have the GPG
prerequisite to verify the handling of %G and %GX, as the point is that
they are not actually gpg format placeholders.

That being said, I did botch the commit, because not having GPG means
we would not create any commits, and therefore "git log -1" fails for
the wrong reason.

The "right" fix is actually to make sure there is at least one commit in
that final test (e.g., by adding one base commit before the others).
Then it can run regardless of whether the GPG tests ran. And in that
sense, Brian's patch is working in the opposite direction.

Thinking on the explanation I gave above, though, I think it means the
test would probably be better placed in t6006 along with the other
format-specifier tests. That fixes the problem, and means that Brian's
simplification (to just skip all tests) becomes the right thing to do.

> As there are a few additional test pieces to this file in flight
> that come from another topic (which by the way protects them with
> the prerequiste), I'd rather fix it up with the necessary GPG
> prerequisite, at least for now, instead of doing it this way.

The patch below should fix it with minimal fuss. I think Brian's patch
makes sense on top, but I agree it would be nice to wait until the
existing topics settle.

> Another thing we may want to take into account is that we would also
> want to make sure that builds of Git without GPG installed still
> behave sensibly (with some definition of sensible) when faced with
> GPG signatures in existing commit objects and tag objects.

Yeah, I agree that is a good thing to test.

> If that will happen in this same script, then skipping all by
> requiring GPG upfront may not be a good change, but it is likely that
> we would want a NOGPG prerequisite for "No GPG installed" case and
> have a separate test script, in which case, this will just skip all
> without GPG, and the other new one will just skip all without NOGPG.
> We'll see.

I think it may make more sense to just configure gpg.program to "false"
for the NOGPG case. Then you get coverage both on systems with it
installed, and without (you could also just test it on GPG systems, and
drop the "ship commits in fast-import form" part of the plan).

Anyway, that is all outside the scope of the immediate problem. Here's
the patch to fix jk/pretty-G-format-fixes.

-- >8 --
Subject: move "%G" format test from t7510 to t6006

The final test in t7510 checks that "--format" placeholders
that look similar to GPG placeholders (but that we don't
actually understand) are passed through. That test was
placed in t7510, since the other GPG placeholder tests are
there. However, it does not have a GPG prerequisite, because
it is not actually checking any signed commits.

This causes the test to erroneously fail when gpg is not
installed on a system, however. Not because we need signed
commits, but because we need _any_ commit to run "git log".
If we don't have gpg installed, t7510 doesn't create any
commits at all.

We can fix this by moving the test into t6006. This is
arguably a better place anyway, because it is where we test
most of the other placeholders (we do not test GPG
placeholders there because of the infrastructure needed to
make signed commits).

Signed-off-by: Jeff King <peff@peff•net>
---
 t/t6006-rev-list-format.sh | 6 ++++++
 t/t7510-signed-commit.sh   | 6 ------
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index c277db6..88ed319 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -468,4 +468,10 @@ test_expect_success 'single-character name is parsed correctly' '
 	test_cmp expect actual
 '
 
+test_expect_success 'unused %G placeholders are passed through' '
+	echo "%GX %G" >expect &&
+	git log -1 --format="%GX %G" >actual &&
+	test_cmp expect actual
+'
+
 test_done
diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh
index 9810242..e97477a 100755
--- a/t/t7510-signed-commit.sh
+++ b/t/t7510-signed-commit.sh
@@ -147,10 +147,4 @@ test_expect_success GPG 'show lack of signature with custom format' '
 	test_cmp expect actual
 '
 
-test_expect_success 'unused %G placeholders are passed through' '
-	echo "%GX %G" >expect &&
-	git log -1 --format="%GX %G" >actual &&
-	test_cmp expect actual
-'
-
 test_done
-- 
2.0.0.566.gfe3e6b2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] t7510: Skip all if GPG isn't installed
  2014-06-25 21:42   ` Jeff King
@ 2014-06-25 22:24     ` Junio C Hamano
  0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2014-06-25 22:24 UTC (permalink / raw)
  To: Jeff King; +Cc: Brian Gernhardt, Git List

Jeff King <peff@peff•net> writes:

> ...
> I think it may make more sense to just configure gpg.program to "false"
> for the NOGPG case. Then you get coverage both on systems with it
> installed, and without (you could also just test it on GPG systems, and
> drop the "ship commits in fast-import form" part of the plan).
>
> Anyway, that is all outside the scope of the immediate problem. Here's
> the patch to fix jk/pretty-G-format-fixes.

All sounds sensible.  Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-06-25 22:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-24  4:52 [PATCH] t7510: Skip all if GPG isn't installed Brian Gernhardt
2014-06-25 21:16 ` Junio C Hamano
2014-06-25 21:42   ` Jeff King
2014-06-25 22:24     ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox