mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-18 08:43:03 +00:00
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:
@@ -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
|
||||
])])
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user