tests: refactor the handling of Perl

Let's make a difference between places where Perl is required for the
test (AT_PERL_REQUIRE), and the places where it's used to run the
test, but it's not not to run the test (AT_PERL_CHECK).

* tests/local.at (AT_REQUIRE): New.
(AT_PERL_CHECK, AT_PERL_REQUIRE): New.
Use them where appropriate.

* tests/local.mk ($(TESTSUITE)): Beware not to start the line with
'-pi' if Perl is empty, as Make understands this as "it's ok to fail".
Which it is not.
This commit is contained in:
Akim Demaille
2019-10-12 12:34:10 +02:00
parent 59cb1f421c
commit c483b6593f
13 changed files with 65 additions and 39 deletions

View File

@@ -29,6 +29,7 @@ m4_define([m4_null_if],
[], [$2],
[$3])])
# AT_SETUP_STRIP(TITLE)
# ---------------------
# Abbreviate the TITLE to be passed to AT_SETUP. Remove new-lines
@@ -50,15 +51,40 @@ m4_define([AT_SETUP_STRIP],
## Basic tests. ##
## ------------- ##
# AT_PERL_CHECK(PERL-ARGS, ...)
# -----------------------------
# If Perl is available, run this test.
m4_define([AT_PERL_CHECK],
[if test x"$PERL" != x; then
AT_CHECK(["$PERL" $1], [$2], [$3], [$4])
fi
])
# AT_REQUIRE(CMD, ...)
# --------------------
# Same as AT_CHECK(...) but skip this test if we failed.
m4_define([AT_REQUIRE],
[AT_CHECK([$1 || exit 77], [$2], [$3], [$4])])
# AT_PERL_REQUIRE(PERL-ARGS, ...)
# -------------------------------
# Run this Perl program, or skip the test if Perl is not available.
m4_define([AT_PERL_REQUIRE],
[AT_REQUIRE(["$PERL" $1], [$2], [$3], [$4])])
# AT_MATCHES_CHECK(FILE, PERL-REGEXP, COUNT)
# ------------------------------------------
# Expect COUNT matches of the PERL-REGEXP in FILE. The file is
# taken in "slurp" mode, i.e., one can match end-of-lines.
m4_define([AT_MATCHES_CHECK],
[AT_CHECK(["$PERL" -0777 -ne '
my $count = 0;
s{$2}{ ++$count; "" }gem;
printf "$count\n";' $1 || exit 77], [0], [$3
[AT_PERL_CHECK([-0777 -ne '
my $count = 0;
s{$2}{ ++$count; "" }gem;
printf "$count\n";' $1], [0], [$3
])])