diff mbox series

[v2,1/2] t/lib-gpg: introduce new prereq GPG2

Message ID 20230602023105.17979-2-five231003@gmail.com (mailing list archive)
State Superseded
Headers show
Series Add new "signature" atom | expand

Commit Message

Kousik Sanagavarapu June 2, 2023, 2:11 a.m. UTC
GnuPG v2.0.0 released in 2006, which according to its release notes

	https://gnupg.org/download/release_notes.html

is the "First stable version of GnuPG integrating OpenPGP and S/MIME".

Use this version or it's successors for tests that will fail for
versions less than v2.0.0 because of the difference in the output on
stderr between the versions (v2.* vs v0.* or v2.* vs v1.*). Skip if
the GPG version detected is less than v2.0.0.

Do not, however, remove the existing prereq GPG yet since a lot of tests
still work with the prereq GPG (that is even with versions v0.* or v1.*)
and some systems still use these versions.

Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Hariom Verma <hariom18599@gmail.com>
Signed-off-by: Kousik Sanagavarapu <five231003@gmail.com>
---
 t/lib-gpg.sh             | 21 +++++++++++++++++++++
 t/t7510-signed-commit.sh |  7 +++++++
 2 files changed, 28 insertions(+)

Comments

Christian Couder June 2, 2023, 6:50 a.m. UTC | #1
On Fri, Jun 2, 2023 at 4:31 AM Kousik Sanagavarapu <five231003@gmail.com> wrote:

> +test_lazy_prereq GPG2 '
> +       gpg_version=$(gpg --version 2>&1)
> +       test $? != 127 || exit 1
> +
> +       case "$gpg_version" in
> +       "gpg (GnuPG) 0."* | "gpg (GnuPG) 1.*")

s/"gpg (GnuPG) 1.*"/"gpg (GnuPG) 1."*/

I am not sure if it changes anything, but for testing if we have v0
here and v1.0.6 in the "test_lazy_prereq PGP", we put the '*'
character outside the double quoted string.

> +               say "This test requires a GPG version >= v2.0.0"
> +               exit 1
> +               ;;
> +       *)
> +               (gpgconf --kill all || : ) &&
> +               gpg --homedir "${GNUPGHOME}" --import \
> +                       "$TEST_DIRECTORY"/lib-gpg/keyring.gpg &&
> +               gpg --homedir "${GNUPGHOME}" --import-ownertrust \
> +                       "$TEST_DIRECTORY"/lib-gpg/ownertrust &&
> +               gpg --homedir "${GNUPGHOME}" </dev/null >/dev/null \
> +                       --sign -u committer@example.com
> +               ;;
> +       esac
> +'
Kousik Sanagavarapu June 2, 2023, 12:58 p.m. UTC | #2
On Fri, Jun 02, 2023 at 08:50:18AM +0200, Christian Couder wrote:
> On Fri, Jun 2, 2023 at 4:31 AM Kousik Sanagavarapu <five231003@gmail.com> wrote:
> 
> > +test_lazy_prereq GPG2 '
> > +       gpg_version=$(gpg --version 2>&1)
> > +       test $? != 127 || exit 1
> > +
> > +       case "$gpg_version" in
> > +       "gpg (GnuPG) 0."* | "gpg (GnuPG) 1.*")
> 
> s/"gpg (GnuPG) 1.*"/"gpg (GnuPG) 1."*/
> 
> I am not sure if it changes anything, but for testing if we have v0
> here and v1.0.6 in the "test_lazy_prereq PGP", we put the '*'
> character outside the double quoted string.

It does seem that it changes things, thanks for catching. I'll reroll
with the necessary changes (there are also some style issues that
Oswald pointed out).

Thanks
diff mbox series

Patch

diff --git a/t/lib-gpg.sh b/t/lib-gpg.sh
index 114785586a..aba8f861ed 100644
--- a/t/lib-gpg.sh
+++ b/t/lib-gpg.sh
@@ -51,6 +51,27 @@  test_lazy_prereq GPG '
 	esac
 '
 
+test_lazy_prereq GPG2 '
+	gpg_version=$(gpg --version 2>&1)
+	test $? != 127 || exit 1
+
+	case "$gpg_version" in
+	"gpg (GnuPG) 0."* | "gpg (GnuPG) 1.*")
+		say "This test requires a GPG version >= v2.0.0"
+		exit 1
+		;;
+	*)
+		(gpgconf --kill all || : ) &&
+		gpg --homedir "${GNUPGHOME}" --import \
+			"$TEST_DIRECTORY"/lib-gpg/keyring.gpg &&
+		gpg --homedir "${GNUPGHOME}" --import-ownertrust \
+			"$TEST_DIRECTORY"/lib-gpg/ownertrust &&
+		gpg --homedir "${GNUPGHOME}" </dev/null >/dev/null \
+			--sign -u committer@example.com
+		;;
+	esac
+'
+
 test_lazy_prereq GPGSM '
 	test_have_prereq GPG &&
 	# Available key info:
diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh
index ccbc416402..0d2dd29fe6 100755
--- a/t/t7510-signed-commit.sh
+++ b/t/t7510-signed-commit.sh
@@ -218,6 +218,13 @@  test_expect_success GPG 'amending already signed commit' '
 	! grep "BAD signature from" actual
 '
 
+test_expect_success GPG2 'bare signature' '
+	git verify-commit fifth-signed 2>expect &&
+	echo >>expect &&
+	git log -1 --format="%GG" fifth-signed >actual &&
+	test_cmp expect actual
+'
+
 test_expect_success GPG 'show good signature with custom format' '
 	cat >expect <<-\EOF &&
 	G