view tests/test-exclude7.sh @ 16806:babe19575e66

exclude: process exclude and include directives in order This restores the pre-2009 behavior, and is part of a fix of a grep bug reported by Quentin Arce in <http://lists.gnu.org/archive/html/bug-grep/2012-04/msg00056.html>. * lib/exclude.c (struct exclude): Remove 'tail' member. (new_exclude_segment): Prepend the new segment instead of appending. Return void, since that's now more convenient. (file_pattern_matches): Renamed from excluded_file_pattern_p. (file_name_matches): Renamed from excluded_file_name_p. (file_pattern_matches, file_name_matches): Return true if the pattern matches, not if it excludes. All callers changed. (excluded_file_name): Process the list in reverse order; since the list is now reversed this restores the pre-2009 behavior. (add_exclude): Adjust to new reversed-order list. Use local var rather than macro, for clarity. * tests/test-exclude7.sh: Adjust to corrected behavior.
author Paul Eggert <eggert@cs.ucla.edu>
date Sun, 29 Apr 2012 19:04:41 -0700
parents 8250f2777afc
children e542fd46ad6f
line wrap: on
line source

#! /bin/sh
# Test suite for exclude.
# Copyright (C) 2009-2012 Free Software Foundation, Inc.
# This file is part of the GNUlib Library.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

. "${srcdir=.}/init.sh"; path_prepend_ .
fail=0

# Test exclude precedence

cat > in <<EOT
foo*
bar
Baz
EOT

cat > expected <<EOT
bar: 0
bar: 1
EOT

test-exclude in -include in -- bar > out || exit $?
test-exclude -include in -no-include in -- bar >> out || exit $?

# Find out how to remove carriage returns from output. Solaris /usr/ucb/tr
# does not understand '\r'.
case $(echo r | tr -d '\r') in '') cr='\015';; *) cr='\r';; esac

# normalize output
LC_ALL=C tr -d "$cr" < out > k && mv k out

compare expected out || fail=1

Exit $fail