mirror of
https://github.com/mirror/make.git
synced 2026-09-04 05:32:57 +08:00
Implementation of the second expansion in explicit
rules, static pattern rules and implicit rules.
This commit is contained in:
105
tests/scripts/features/se_explicit
Normal file
105
tests/scripts/features/se_explicit
Normal file
@@ -0,0 +1,105 @@
|
||||
# -*-perl-*-
|
||||
$description = "Test second expansion in ordinary rules.";
|
||||
|
||||
$details = "";
|
||||
|
||||
# Test #1: automatic variables.
|
||||
#
|
||||
run_make_test('
|
||||
.DEFAULT: ; @echo $@
|
||||
|
||||
foo: bar baz
|
||||
|
||||
foo: biz | buz
|
||||
|
||||
foo: $$@.1 \
|
||||
$$<.2 \
|
||||
$$(addsuffix .3,$$^) \
|
||||
$$(addsuffix .4,$$+) \
|
||||
$$|.5 \
|
||||
$$*.6
|
||||
|
||||
',
|
||||
'',
|
||||
'bar
|
||||
baz
|
||||
biz
|
||||
buz
|
||||
foo.1
|
||||
bar.2
|
||||
bar.3
|
||||
baz.3
|
||||
biz.3
|
||||
bar.4
|
||||
baz.4
|
||||
biz.4
|
||||
buz.5
|
||||
.6
|
||||
');
|
||||
|
||||
|
||||
# Test #2: target/pattern -specific variables.
|
||||
#
|
||||
run_make_test('
|
||||
.DEFAULT: ; @echo $@
|
||||
|
||||
foo.x: $$a $$b
|
||||
|
||||
foo.x: a := bar
|
||||
|
||||
%.x: b := baz
|
||||
|
||||
',
|
||||
'',
|
||||
'bar
|
||||
baz
|
||||
');
|
||||
|
||||
|
||||
# Test #3: order of prerequisites.
|
||||
#
|
||||
run_make_test('
|
||||
.DEFAULT: ; @echo $@
|
||||
|
||||
all: foo bar baz
|
||||
|
||||
# Subtest #1
|
||||
#
|
||||
foo: foo.1; @:
|
||||
|
||||
foo: foo.2
|
||||
|
||||
foo: foo.3
|
||||
|
||||
|
||||
# Subtest #2
|
||||
#
|
||||
bar: bar.2
|
||||
|
||||
bar: bar.1; @:
|
||||
|
||||
bar: bar.3
|
||||
|
||||
|
||||
# Subtest #3
|
||||
#
|
||||
baz: baz.1
|
||||
|
||||
baz: baz.2
|
||||
|
||||
baz: ; @:
|
||||
|
||||
',
|
||||
'',
|
||||
'foo.1
|
||||
foo.2
|
||||
foo.3
|
||||
bar.1
|
||||
bar.2
|
||||
bar.3
|
||||
baz.1
|
||||
baz.2
|
||||
');
|
||||
|
||||
# This tells the test driver that the perl test script executed properly.
|
||||
1;
|
||||
188
tests/scripts/features/se_implicit
Normal file
188
tests/scripts/features/se_implicit
Normal file
@@ -0,0 +1,188 @@
|
||||
# -*-perl-*-
|
||||
$description = "Test second expansion in ordinary rules.";
|
||||
|
||||
$details = "";
|
||||
|
||||
use Cwd;
|
||||
|
||||
$dir = cwd;
|
||||
$dir =~ s,.*/([^/]+)$,../$1,;
|
||||
|
||||
|
||||
# Test #1: automatic variables.
|
||||
#
|
||||
run_make_test('
|
||||
.DEFAULT: ; @echo $@
|
||||
|
||||
foo.a: bar baz
|
||||
|
||||
foo.a: biz | buz
|
||||
|
||||
foo.%: 1.$$@ \
|
||||
2.$$< \
|
||||
$$(addprefix 3.,$$^) \
|
||||
$$(addprefix 4.,$$+) \
|
||||
5.$$| \
|
||||
6.$$*
|
||||
@:
|
||||
|
||||
1.foo.a \
|
||||
2.bar \
|
||||
3.bar \
|
||||
3.baz \
|
||||
3.biz \
|
||||
4.bar \
|
||||
4.baz \
|
||||
4.biz \
|
||||
5.buz \
|
||||
6.a:
|
||||
@echo $@
|
||||
|
||||
',
|
||||
'',
|
||||
'1.foo.a
|
||||
2.bar
|
||||
3.bar
|
||||
3.baz
|
||||
3.biz
|
||||
4.bar
|
||||
4.baz
|
||||
4.biz
|
||||
5.buz
|
||||
6.a
|
||||
bar
|
||||
baz
|
||||
biz
|
||||
buz
|
||||
');
|
||||
|
||||
|
||||
# Test #2: target/pattern -specific variables.
|
||||
#
|
||||
run_make_test('
|
||||
foo.x:
|
||||
|
||||
foo.%: $$(%_a) $$(%_b) bar
|
||||
@:
|
||||
|
||||
foo.x: x_a := bar
|
||||
|
||||
%.x: x_b := baz
|
||||
|
||||
bar baz: ; @echo $@
|
||||
|
||||
',
|
||||
'',
|
||||
'bar
|
||||
baz
|
||||
');
|
||||
|
||||
|
||||
# Test #3: order of prerequisites.
|
||||
#
|
||||
run_make_test('
|
||||
.DEFAULT: ; @echo $@
|
||||
|
||||
all: foo bar baz
|
||||
|
||||
|
||||
# Subtest #1
|
||||
#
|
||||
%oo: %oo.1; @:
|
||||
|
||||
foo: foo.2
|
||||
|
||||
foo: foo.3
|
||||
|
||||
foo.1: ; @echo $@
|
||||
|
||||
|
||||
# Subtest #2
|
||||
#
|
||||
bar: bar.2
|
||||
|
||||
%ar: %ar.1; @:
|
||||
|
||||
bar: bar.3
|
||||
|
||||
bar.1: ; @echo $@
|
||||
|
||||
|
||||
# Subtest #3
|
||||
#
|
||||
baz: baz.1
|
||||
|
||||
baz: baz.2
|
||||
|
||||
%az: ; @:
|
||||
|
||||
',
|
||||
'',
|
||||
'foo.1
|
||||
foo.2
|
||||
foo.3
|
||||
bar.1
|
||||
bar.2
|
||||
bar.3
|
||||
baz.1
|
||||
baz.2
|
||||
');
|
||||
|
||||
|
||||
# Test #4: stem splitting logic.
|
||||
#
|
||||
run_make_test('
|
||||
$(dir)/tmp/bar.o:
|
||||
|
||||
$(dir)/tmp/foo/bar.c: ; @echo $@
|
||||
$(dir)/tmp/bar/bar.c: ; @echo $@
|
||||
foo.h: ; @echo $@
|
||||
|
||||
%.o: $$(addsuffix /%.c,foo bar) foo.h
|
||||
@echo $@: {$<} $^
|
||||
|
||||
',
|
||||
"dir=$dir",
|
||||
"$dir/tmp/foo/bar.c
|
||||
$dir/tmp/bar/bar.c
|
||||
foo.h
|
||||
$dir/tmp/bar.o: {$dir/tmp/foo/bar.c} $dir/tmp/foo/bar.c $dir/tmp/bar/bar.c foo.h
|
||||
");
|
||||
|
||||
|
||||
# Test #5: stem splitting logic and order-only prerequisites.
|
||||
#
|
||||
run_make_test('
|
||||
$(dir)/tmp/foo.o: $(dir)/tmp/foo.c
|
||||
$(dir)/tmp/foo.c: ; @echo $@
|
||||
bar.h: ; @echo $@
|
||||
|
||||
%.o: %.c|bar.h
|
||||
@echo $@: {$<} {$|} $^
|
||||
|
||||
',
|
||||
"dir=$dir",
|
||||
"$dir/tmp/foo.c
|
||||
bar.h
|
||||
$dir/tmp/foo.o: {$dir/tmp/foo.c} {bar.h} $dir/tmp/foo.c
|
||||
");
|
||||
|
||||
|
||||
# Test #6: lack of implicit prerequisites.
|
||||
#
|
||||
run_make_test('
|
||||
foo.o: foo.c
|
||||
foo.c: ; @echo $@
|
||||
|
||||
%.o:
|
||||
@echo $@: {$<} $^
|
||||
|
||||
',
|
||||
'',
|
||||
'foo.c
|
||||
foo.o: {foo.c} foo.c
|
||||
');
|
||||
|
||||
|
||||
# This tells the test driver that the perl test script executed properly.
|
||||
1;
|
||||
106
tests/scripts/features/se_statpat
Normal file
106
tests/scripts/features/se_statpat
Normal file
@@ -0,0 +1,106 @@
|
||||
# -*-perl-*-
|
||||
$description = "Test second expansion in static pattern rules.";
|
||||
|
||||
$details = "";
|
||||
|
||||
# Test #1: automatic variables.
|
||||
#
|
||||
run_make_test('
|
||||
.DEFAULT: ; @echo $@
|
||||
|
||||
foo.a foo.b: foo.%: bar.% baz.%
|
||||
|
||||
foo.a foo.b: foo.%: biz.% | buz.%
|
||||
|
||||
foo.a foo.b: foo.%: $$@.1 \
|
||||
$$<.2 \
|
||||
$$(addsuffix .3,$$^) \
|
||||
$$(addsuffix .4,$$+) \
|
||||
$$|.5 \
|
||||
$$*.6
|
||||
|
||||
',
|
||||
'',
|
||||
'bar.a
|
||||
baz.a
|
||||
biz.a
|
||||
buz.a
|
||||
foo.a.1
|
||||
bar.a.2
|
||||
bar.a.3
|
||||
baz.a.3
|
||||
biz.a.3
|
||||
bar.a.4
|
||||
baz.a.4
|
||||
biz.a.4
|
||||
buz.a.5
|
||||
a.6
|
||||
');
|
||||
|
||||
|
||||
# Test #2: target/pattern -specific variables.
|
||||
#
|
||||
run_make_test('
|
||||
.DEFAULT: ; @echo $@
|
||||
|
||||
foo.x foo.y: foo.%: $$(%_a) $$($$*_b)
|
||||
|
||||
foo.x: x_a := bar
|
||||
|
||||
%.x: x_b := baz
|
||||
|
||||
|
||||
',
|
||||
'',
|
||||
'bar
|
||||
baz
|
||||
');
|
||||
|
||||
|
||||
# Test #3: order of prerequisites.
|
||||
#
|
||||
run_make_test('
|
||||
.DEFAULT: ; @echo $@
|
||||
|
||||
all: foo.a bar.a baz.a
|
||||
|
||||
# Subtest #1
|
||||
#
|
||||
foo.a foo.b: foo.%: foo.%.1; @:
|
||||
|
||||
foo.a foo.b: foo.%: foo.%.2
|
||||
|
||||
foo.a foo.b: foo.%: foo.%.3
|
||||
|
||||
|
||||
# Subtest #2
|
||||
#
|
||||
bar.a bar.b: bar.%: bar.%.2
|
||||
|
||||
bar.a bar.b: bar.%: bar.%.1; @:
|
||||
|
||||
bar.a bar.b: bar.%: bar.%.3
|
||||
|
||||
|
||||
# Subtest #3
|
||||
#
|
||||
baz.a baz.b: baz.%: baz.%.1
|
||||
|
||||
baz.a baz.b: baz.%: baz.%.2
|
||||
|
||||
baz.a baz.b: ; @:
|
||||
|
||||
',
|
||||
'',
|
||||
'foo.a.1
|
||||
foo.a.2
|
||||
foo.a.3
|
||||
bar.a.1
|
||||
bar.a.2
|
||||
bar.a.3
|
||||
baz.a.1
|
||||
baz.a.2
|
||||
');
|
||||
|
||||
# This tells the test driver that the perl test script executed properly.
|
||||
1;
|
||||
@@ -6,9 +6,6 @@ which have either broken at some point in the past or seem likely to
|
||||
break.";
|
||||
|
||||
open(MAKEFILE,"> $makefile");
|
||||
|
||||
# The contents of the Makefile ...
|
||||
|
||||
print MAKEFILE <<'EOF';
|
||||
# Make sure that subdirectories built as prerequisites are actually handled
|
||||
# properly.
|
||||
@@ -21,11 +18,36 @@ dir/subdir/file.b: dir/subdir ; @echo touch dir/subdir/file.b
|
||||
|
||||
dir/subdir/%.a: dir/subdir/%.b ; @echo cp $< $@
|
||||
EOF
|
||||
|
||||
close(MAKEFILE);
|
||||
|
||||
&run_make_with_options($makefile,"",&get_logfile);
|
||||
$answer = "mkdir -p dir/subdir\ntouch dir/subdir/file.b\ncp dir/subdir/file.b dir/subdir/file.a\n";
|
||||
&compare_output($answer,&get_logfile(1));
|
||||
|
||||
|
||||
# Test implicit rules
|
||||
|
||||
&touch('foo.c');
|
||||
run_make_test('
|
||||
foo: foo.o
|
||||
',
|
||||
'CC="@echo cc" OUTPUT_OPTION=',
|
||||
'cc -c foo.c
|
||||
cc foo.o -o foo');
|
||||
unlink('foo.c');
|
||||
|
||||
|
||||
# Test other implicit rule searching
|
||||
|
||||
&touch('bar');
|
||||
run_make_test('
|
||||
test.foo:
|
||||
%.foo : baz ; @echo done $<
|
||||
%.foo : bar ; @echo done $<
|
||||
fox: baz
|
||||
',
|
||||
'',
|
||||
'done bar');
|
||||
unlink('bar');
|
||||
|
||||
1;
|
||||
|
||||
@@ -67,11 +67,11 @@ EOF
|
||||
close(MAKEFILE);
|
||||
|
||||
&run_make_with_options($makefile2, "$dir/foo $dir/bar", &get_logfile);
|
||||
$answer = ".x\n$dir/foo.x\n\$.x\n\$@.x\n$dir.x\nfoo.x\n$dir/bar.x\nbar.x\n";
|
||||
$answer = ".x\n$dir/foo.x\nx\n\$@.x\n$dir.x\nfoo.x\n$dir/bar.x\nbar.x\n";
|
||||
&compare_output($answer, &get_logfile(1));
|
||||
|
||||
&run_make_with_options($makefile2, "$dir/x.z $dir/y.z", &get_logfile);
|
||||
$answer = ".x\n$dir/x.z.x\n\$.x\n\$@.x\n$dir.x\nx.z.x\n.y\n$dir/y.z.y\n\$.y\n\$@.y\n$dir.y\ny.z.y\n";
|
||||
$answer = ".x\n$dir/x.z.x\nx\n\$@.x\n$dir.x\nx.z.x\n.y\n$dir/y.z.y\n\y\n\$@.y\n$dir.y\ny.z.y\n";
|
||||
&compare_output($answer, &get_logfile(1));
|
||||
|
||||
&run_make_with_options($makefile2, "$dir/biz", &get_logfile);
|
||||
|
||||
Reference in New Issue
Block a user