grep-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] tests: restore deleted -P tests


From: Jim Meyering
Subject: [PATCH] tests: restore deleted -P tests
Date: Mon, 28 Sep 2020 22:12:53 -0700

FYI, I've just pushed this:

    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.

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 83e7087..034bd0c 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 be927ef..82b48cd 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};



reply via email to

[Prev in Thread] Current Thread [Next in Thread]