summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2011-05-21 12:13:08 +0200
committerJim Meyering <meyering@redhat.com>2011-05-21 12:13:08 +0200
commit2be2b8c044f8bd0fc6723004840029bd85078196 (patch)
tree959b2ff53d265f8b2a41cbe0d1bc8d66f21e8ade
parent8e6d2371460706b0ad48ee476fb5cde7f4cd61ee (diff)
downloadgrep-2be2b8c044f8bd0fc6723004840029bd85078196.tar.gz
tests: factor out a new require_pcre_ function
* tests/init.cfg (require_pcre_): New function, factored out of... * tests/pcre-z: ...here. Use the function. * tests/pcre: Likewise.
-rw-r--r--tests/init.cfg6
-rw-r--r--tests/pcre4
-rwxr-xr-xtests/pcre-z4
3 files changed, 8 insertions, 6 deletions
diff --git a/tests/init.cfg b/tests/init.cfg
index baa2b40f..4c9d2d33 100644
--- a/tests/init.cfg
+++ b/tests/init.cfg
@@ -43,6 +43,12 @@ require_timeout_()
|| skip_ your system lacks the timeout program
}
+require_pcre_()
+{
+ echo . | grep -P . 2>err || skip_ no PCRE support
+ compare err /dev/null || fail_ PCRE available, but stderr not empty.
+}
+
# Some tests would fail without this particular locale.
# If the locale is not available, just skip the test.
require_en_utf8_locale_()
diff --git a/tests/pcre b/tests/pcre
index bec6e372..a712d19a 100644
--- a/tests/pcre
+++ b/tests/pcre
@@ -8,9 +8,7 @@
# notice and this notice are preserved.
. "${srcdir=.}/init.sh"; path_prepend_ ../src
-
-# Test that grep was compiled with HAVE_LIBPCRE. Otherwise, pass.
-echo . | grep -P . || skip_ no PCRE support
+require_pcre_
fail=0
diff --git a/tests/pcre-z b/tests/pcre-z
index d1d5dd7d..94e9a78e 100755
--- a/tests/pcre-z
+++ b/tests/pcre-z
@@ -1,9 +1,7 @@
#!/bin/sh
# Test Perl regex with NUL-separated input
. "${srcdir=.}/init.sh"; path_prepend_ ../src
-
-echo a | grep -P a >/dev/null 2>err || skip_ 'PCRE not available.'
-compare err /dev/null || fail_ 'PCRE available, but stderr not empty.'
+require_pcre_
REGEX=a