grep/tests/include-exclude
Jim Meyering 8a54f20312 tests: ensure that each test script is executable
This adds a rule run at "make check" time to ensure that
test scripts are consistently executable.
This change is not required for "make check", but makes it easier
for people to run scripts manually, but that is discouraged because
doing so makes it easy to omit important variable settings that
are normally provided via TESTS_ENVIRONMENT.
This change also makes each of the existing TESTS executable.
* tests/Makefile.am (check_executable_TESTS): New rule.
(check): Depend on it.
* tests/{all_scripts}: chmod 755.
Prompted by a report from Eric Blake.
2011-06-21 19:16:14 +02:00

47 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
# Use of any --include or --exclude* option would segfault in 2.6 and 2.6.1
. "${srcdir=.}/init.sh"; path_prepend_ ../src
mkdir -p x/dir || framework_failure_
echo aaa > x/a || framework_failure_
echo bbb > x/b || framework_failure_
echo ddd > x/dir/d || framework_failure_
printf '%s\n' x/b:bbb x/dir/d:ddd > exp-not-a || framework_failure_
printf '%s\n' x/dir/d:ddd > exp-not-ab || framework_failure_
printf '%s\n' x/a:aaa x/b:bbb > exp-not-d || framework_failure_
printf '%s\n' x/a:aaa x/b:bbb > exp-not-dir || framework_failure_
printf '%s\n' x/a:aaa > exp-a || framework_failure_
grep -r --exclude='a*' . x > out || fail=1
sort out > k && mv k out
compare out exp-not-a || fail=1
grep -r --exclude='[ab]' . x > out || fail=1
sort out > k && mv k out
compare out exp-not-ab || fail=1
grep -r --exclude='*d' . x > out || fail=1
sort out > k && mv k out
compare out exp-not-d || fail=1
grep -r --exclude-dir=dir . x > out || fail=1
sort out > k && mv k out
compare out exp-not-dir || fail=1
# Test with a non-glob.
grep -r --include=a . x > out || fail=1
# no need to sort
compare out exp-a || fail=1
# Also test --include with a "glob".
grep -r --include='a*' . x > out || fail=1
# no need to sort
compare out exp-a || fail=1
# --include (without --recursive) uses different code
grep --include=a '^aaa$' x/* > out || fail=1
compare out exp-a || fail=1
Exit $fail