diff options
author | Jim Meyering <meyering@redhat.com> | 2010-03-04 18:24:03 +0100 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2010-03-04 18:28:47 +0100 |
commit | 29182990773f031a7b39f93a17a05b64fa28e38d (patch) | |
tree | 53b53bd1ddb880dc23dca4098940ac490c94d0e7 /tests | |
parent | 10ab6fb6f239eaef102e71140d425bbca91b12dc (diff) | |
download | grep-29182990773f031a7b39f93a17a05b64fa28e38d.tar.gz |
tests: add a test based on an example from Paolo Bonzini
* tests/word-multi-file: New test.
* tests/Makefile.am (TESTS): Add it.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/word-multi-file | 30 |
2 files changed, 31 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index a34c38d0..cee1fa48 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -30,6 +30,7 @@ TESTS = \ spencer1.sh \ status.sh \ warning.sh \ + word-multi-file \ yesno.sh EXTRA_DIST = \ diff --git a/tests/word-multi-file b/tests/word-multi-file new file mode 100644 index 00000000..0bafc097 --- /dev/null +++ b/tests/word-multi-file @@ -0,0 +1,30 @@ +#!/bin/sh +# exercise the -w option on multiple files +# Derived from http://bugzilla.redhat.com/570500 +: ${srcdir=.} +. "$srcdir/init.sh"; path_prepend_ ../src + +mkdir a || framework_failure +( cd a \ + && echo aa bb cc > 1 \ + && echo bb dd ff > 2 \ + && echo ff gg hh > 3 \ + && echo bb xx zz > 4 \ +) || framework_failure + +cat << \EOF > exp1 || framework_failure +a/1:aa bb cc +a/2:bb dd ff +a/4:bb xx zz +EOF +sed s/..// exp1 > exp2 || framework_failure + +fail=0 +grep -rw bb a > out || fail=1 +sort < out > k; mv k out +compare out exp1 || fail=1 + +(cd a && grep -w bb [1-4]) > out || fail=1 +compare out exp2 || fail=1 + +Exit $fail |