Skip to content

Commit 3ca6f20

Browse files
pks-tgitster
authored andcommitted
t/lib-gpg: refactor sanitize_pgp() to not depend on Perl
The `sanitize_pgp()` test helper uses Perl to strip PGP signatures from stdin. Refactor it to instead use sed(1) so that we drop the PERL_TEST_HELPERS prerequisite in users of this library. Note that we have to add PERL_TEST_HELPERS to a subset of tests in t6300 now that the test suite doesn't bail out early anymore in case the prerequisite isn't set. Helped-by: Johannes Schindelin <[email protected]> Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4a7af4e commit 3ca6f20

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

t/lib-gpg.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,5 @@ test_lazy_prereq GPGSSH_VERIFYTIME '
192192
'
193193

194194
sanitize_pgp() {
195-
perl -ne '
196-
/^-----END PGP/ and $in_pgp = 0;
197-
print unless $in_pgp;
198-
/^-----BEGIN PGP/ and $in_pgp = 1;
199-
'
195+
sed "/^-----BEGIN PGP/,/^-----END PGP/{/^-/p;d;}"
200196
}

t/t6300-for-each-ref.sh

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ GNUPGHOME_NOT_USED=$GNUPGHOME
1010
. "$TEST_DIRECTORY"/lib-gpg.sh
1111
. "$TEST_DIRECTORY"/lib-terminal.sh
1212

13-
if ! test_have_prereq PERL_TEST_HELPERS
14-
then
15-
skip_all='skipping for-each-ref tests; Perl not available'
16-
test_done
17-
fi
18-
1913
# Mon Jul 3 23:18:43 2006 +0000
2014
datestamp=1151968723
2115
setdate_and_increment () {
@@ -1215,7 +1209,7 @@ test_expect_success '%(raw) with --tcl must fail' '
12151209
test_must_fail git for-each-ref --format="%(raw)" --tcl
12161210
'
12171211

1218-
test_expect_success '%(raw) with --perl' '
1212+
test_expect_success PERL_TEST_HELPERS '%(raw) with --perl' '
12191213
git for-each-ref --format="\$name= %(raw);
12201214
print \"\$name\"" refs/myblobs/blob1 --perl | perl >actual &&
12211215
cmp blob1 actual &&
@@ -1442,17 +1436,22 @@ test_expect_success 'set up trailers for next test' '
14421436
'
14431437

14441438
test_trailer_option () {
1439+
if test "$#" -eq 3
1440+
then
1441+
prereq="$1"
1442+
shift
1443+
fi &&
14451444
title=$1 option=$2
14461445
cat >expect
1447-
test_expect_success "$title" '
1446+
test_expect_success $prereq "$title" '
14481447
git for-each-ref --format="%($option)" refs/heads/main >actual &&
14491448
test_cmp expect actual &&
14501449
git for-each-ref --format="%(contents:$option)" refs/heads/main >actual &&
14511450
test_cmp expect actual
14521451
'
14531452
}
14541453

1455-
test_trailer_option '%(trailers:unfold) unfolds trailers' \
1454+
test_trailer_option PERL_TEST_HELPERS '%(trailers:unfold) unfolds trailers' \
14561455
'trailers:unfold' <<-EOF
14571456
$(unfold <trailers)
14581457
@@ -1482,13 +1481,13 @@ test_trailer_option '%(trailers:only=no) shows all trailers' \
14821481
14831482
EOF
14841483

1485-
test_trailer_option '%(trailers:only) and %(trailers:unfold) work together' \
1484+
test_trailer_option PERL_TEST_HELPERS '%(trailers:only) and %(trailers:unfold) work together' \
14861485
'trailers:only,unfold' <<-EOF
14871486
$(grep -v patch.description <trailers | unfold)
14881487
14891488
EOF
14901489

1491-
test_trailer_option '%(trailers:unfold) and %(trailers:only) work together' \
1490+
test_trailer_option PERL_TEST_HELPERS '%(trailers:unfold) and %(trailers:only) work together' \
14921491
'trailers:unfold,only' <<-EOF
14931492
$(grep -v patch.description <trailers | unfold)
14941493

0 commit comments

Comments
 (0)