From: Jim Meyering Date: Tue, 6 Apr 2010 07:22:54 +0000 (+0200) Subject: tests: skip tests that use grep's -f and -E options, if they don't work X-Git-Tag: v1.5~86 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=9e0494673c35e57ff98f4516a2ba5b9cf180e4e7;p=debian%2Fgzip tests: skip tests that use grep's -f and -E options, if they don't work * tests/init.cfg (require_grep_minus_f): New function. * tests/zgrep-f: Use require_grep_minus_f. Use path_prepend_. --- diff --git a/tests/init.cfg b/tests/init.cfg index 901209c..5adfc9b 100644 --- a/tests/init.cfg +++ b/tests/init.cfg @@ -3,3 +3,18 @@ # This goes hand in hand with the "exec 9>&2;" in Makefile.am's # TESTS_ENVIRONMENT definition. stderr_fileno_=9 + +require_POSIX_grep_() +{ + # Ensure that grep's -f and -E options works. + # On Solaris 5.11, "grep -f" prints this: + # grep: illegal option -- f + # Usage: grep -hblcnsviw pattern file . . . + # Similar for grep -E. + + : | grep -f /dev/null + test $? = 1 || skip_ 'your grep lacks support for -f -' + + grep -E foo /dev/null + test $? = 1 || skip_ 'your grep lacks support for -E' +} diff --git a/tests/zgrep-f b/tests/zgrep-f index 0801e8d..f64b03e 100644 --- a/tests/zgrep-f +++ b/tests/zgrep-f @@ -18,19 +18,15 @@ # along with this program. If not, see . # limit so don't run it by default. -if test "$VERBOSE" = yes; then - set -x - zgrep --version -fi - : ${srcdir=.} -. "$srcdir/tests/init.sh" +. "$srcdir/tests/init.sh"; path_prepend_ . + +require_POSIX_grep_ echo needle > n || framework_failure echo needle > haystack || framework_failure gzip haystack || framework_failure - fail=0 zgrep -f - haystack.gz < n > out 2>&1 || fail=1