tests: skip tests that use grep's -f and -E options, if they don't work
authorJim Meyering <meyering@redhat.com>
Tue, 6 Apr 2010 07:22:54 +0000 (09:22 +0200)
committerJim Meyering <meyering@redhat.com>
Tue, 6 Apr 2010 16:28:57 +0000 (18:28 +0200)
* tests/init.cfg (require_grep_minus_f): New function.
* tests/zgrep-f: Use require_grep_minus_f.  Use path_prepend_.

tests/init.cfg
tests/zgrep-f

index 901209ceae96dd53ef2d110784fdba39c98254b4..5adfc9b357a134dcadd90de07838a535f84739fa 100644 (file)
@@ -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'
+}
index 0801e8dd55cdfac166507a53d6a14e579b99dbc5..f64b03ee97e537a6154d3d2466d9c26057776968 100644 (file)
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 # 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