| 1 |
# -*-perl-*- |
| 2 |
|
| 3 |
$description = "Test the filter and filter-out functions."; |
| 4 |
|
| 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"; |
| 13 |
|
| 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)' |
| 19 |
!, |
| 20 |
'', "bar.o lose.o foo.i bar.o lose.o\n"); |
| 21 |
|
| 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)' |
| 27 |
!, |
| 28 |
'', "foo.elc foo.elc\n"); |
| 29 |
|
| 30 |
# Force use of hash (see function.c:func_filter_filterout for params) |
| 31 |
|
| 32 |
my $base = 'foo.1 foo.2 foo.3 foo.4 foo.5 foo.6 foo.7 foo.8 foo.9 foo.10'; |
| 33 |
|
| 34 |
my $base10 = join(' ', ($base) x 10); |
| 35 |
my $out3 = join(' ', ('foo.3') x 10); |
| 36 |
my $out456 = join(' ', ('foo.4 foo.5 foo.6') x 10); |
| 37 |
|
| 38 |
run_make_test("words := $base10" . q! |
| 39 |
files1 := $(filter %.3, $(words)) |
| 40 |
files2 := $(filter %.4 foo.5 foo.6, $(words)) |
| 41 |
all: ; @echo '$(files1) $(files2)' |
| 42 |
!, |
| 43 |
'', "$out3 $out456\n"); |
| 44 |
|
| 45 |
|
| 46 |
# Escaped patterns |
| 47 |
run_make_test(q!all:;@echo '$(filter foo\%bar,foo%bar fooXbar)'!, |
| 48 |
'', "foo%bar\n"); |
| 49 |
|
| 50 |
run_make_test(q!all:;@echo '$(filter foo\%\%\\\\\%\%bar,foo%%\\%%bar fooX\\Ybar)'!, |
| 51 |
'', "foo%%\\%%bar\n"); |
| 52 |
|
| 53 |
run_make_test(q! |
| 54 |
X = $(filter foo\\\\\%bar,foo\%bar foo\Xbar) |
| 55 |
all:;@echo '$(X)'!, |
| 56 |
'', "foo\\%bar\n"); |
| 57 |
|
| 58 |
1; |