Fix Savannah bug #35410: handle escape chars in filter/filter-out
[make.git] / tests / scripts / functions / filter-out
blob1fe4819d828190e1d6cd95b8b5da7cfbc82209e1
1 #                                                                    -*-perl-*-
3 $description = "Test the filter and filter-out functions.";
5 $details = "The makefile created in this test has two variables.  The
6 filter-out function is first used to discard names ending in
7 .o with a single simple pattern.  The second filter-out function
8 augments the simple pattern with three literal names, which are
9 also added to the text argument.  This tests an internal hash table
10 which is only used if there are multiple literals present in both
11 the pattern and text arguments.  The result of both filter-out
12 functions is the same single .elc name.\n";
14 # Basic test -- filter
15 run_make_test(q!
16 files1 := $(filter %.o, foo.elc bar.o lose.o)
17 files2 := $(filter %.o foo.i, foo.i bar.i lose.i foo.elc bar.o lose.o)
18 all: ; @echo '$(files1) $(files2)'
20               '', "bar.o lose.o foo.i bar.o lose.o\n");
22 # Basic test -- filter-out
23 run_make_test(q!
24 files1 := $(filter-out %.o, foo.elc bar.o lose.o)
25 files2 := $(filter-out foo.i bar.i lose.i %.o, foo.i bar.i lose.i foo.elc bar.o lose.o)
26 all: ; @echo '$(files1) $(files2)'
28               '', "foo.elc foo.elc\n");
30 # Escaped patterns
31 run_make_test(q!all:;@echo '$(filter foo\%bar,foo%bar fooXbar)'!,
32               '', "foo%bar\n");
34 run_make_test(q!all:;@echo '$(filter foo\%\%\\\\\%\%bar,foo%%\\%%bar fooX\\Ybar)'!,
35               '', "foo%%\\%%bar\n");
37 run_make_test(q!
38 X = $(filter foo\\\\\%bar,foo\%bar foo\Xbar)
39 all:;@echo '$(X)'!,
40               '', "foo\\%bar\n");