summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <meyering@fb.com>2020-09-27 22:23:00 -0700
committerJim Meyering <meyering@fb.com>2020-09-28 11:24:52 -0700
commit2f3ec21c25021355bd19ea3965b61607a0bdf83e (patch)
tree9bbbbce769587a92809ea5618bc9c50e83e7a33c
parent111b8b59273d14afee2386611d5e10e22e507864 (diff)
downloadgrep-2f3ec21c25021355bd19ea3965b61607a0bdf83e.tar.gz
tests: restore deleted -P tests
v3.4-almost-45-g8577dda deleted these two -P-using tests because a grep built without PCRE support would fail those tests. This sets an envvar with the equivalent of the result from the require_pcre_ function and restores the now-guarded tests. Tested by running this: ./configure --disable-perl-regexp && make check * tests/Makefile.am (PCRE_WORKS): Set this envvar. * tests/filename-lineno.pl: Restore invalid-re-P-paren and invalid-re-P-star-paren, now each with a guard.
-rw-r--r--tests/Makefile.am5
-rwxr-xr-xtests/filename-lineno.pl13
2 files changed, 18 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 83e7087f..034bd0c3 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -224,6 +224,11 @@ TESTS_ENVIRONMENT = \
}; \
fi; \
\
+ : 'set this envvar to indicate whether -P works'; \
+ m=0; if err=`echo .|grep -Pq . 2>&1`; then \
+ test -z "$$err" && m=1; fi; \
+ export PCRE_WORKS=$$m; \
+ \
: 'Test egrep/fgrep help if they use our grep.'; \
grep=`echo grep | sed -e '$(transform)'` || exit; \
if test "$$grep" = grep; then \
diff --git a/tests/filename-lineno.pl b/tests/filename-lineno.pl
index be927ef4..82b48cd8 100755
--- a/tests/filename-lineno.pl
+++ b/tests/filename-lineno.pl
@@ -97,6 +97,19 @@ my @Tests =
['invalid-re-G-star-paren', '-G "a.*\\)"', {EXIT=>2},
{ERR => "$prog: Unmatched ) or \\)\n"},
],
+ ['invalid-re-P-paren', '-P ")"', {EXIT=>2},
+ {ERR => $ENV{PCRE_WORKS} == 1
+ ? "$prog: unmatched parentheses\n"
+ : "Perl matching not supported in a --disable-perl-regexp build\n"
+ },
+ ],
+ ['invalid-re-P-star-paren', '-P "a.*)"', {EXIT=>2},
+ {ERR => $ENV{PCRE_WORKS} == 1
+ ? "$prog: unmatched parentheses\n"
+ : "Perl matching not supported in a --disable-perl-regexp build\n"
+ },
+ ],
+
);
my $save_temps = $ENV{DEBUG};