5 |
Create makefiles with various combinations of normal and order-only |
Create makefiles with various combinations of normal and order-only |
6 |
prerequisites and ensure they behave properly. Test the \$| variable."; |
prerequisites and ensure they behave properly. Test the \$| variable."; |
7 |
|
|
8 |
open(MAKEFILE,"> $makefile"); |
# TEST #0 -- Basics |
9 |
|
|
10 |
print MAKEFILE <<'EOF'; |
run_make_test(' |
11 |
|
%r: | baz ; @echo $< $^ $| |
12 |
|
bar: foo |
13 |
|
foo:;@: |
14 |
|
baz:;@:', |
15 |
|
'', "foo foo baz\n"); |
16 |
|
|
17 |
|
# TEST #1 -- First try: the order-only prereqs need to be built. |
18 |
|
|
19 |
|
run_make_test(q! |
20 |
foo: bar | baz |
foo: bar | baz |
21 |
@echo '$$^ = $^' |
@echo '$$^ = $^' |
22 |
@echo '$$| = $|' |
@echo '$$| = $|' |
25 |
.PHONY: baz |
.PHONY: baz |
26 |
|
|
27 |
bar baz: |
bar baz: |
28 |
touch $@ |
touch $@!, |
29 |
EOF |
'', "touch bar\ntouch baz\n\$^ = bar\n\$| = baz\ntouch foo\n"); |
|
|
|
|
close(MAKEFILE); |
|
|
|
|
|
|
|
|
# TEST #1 -- just the syntax |
|
|
|
|
|
&run_make_with_options($makefile, "", &get_logfile); |
|
|
$answer = "touch bar\ntouch baz\n\$^ = bar\n\$| = baz\ntouch foo\n"; |
|
|
&compare_output($answer,&get_logfile(1)); |
|
30 |
|
|
31 |
|
|
32 |
# TEST #2 -- now we do it again: baz is PHONY but foo should _NOT_ be updated |
# TEST #2 -- now we do it again: baz is PHONY but foo should _NOT_ be updated |
33 |
|
|
34 |
&run_make_with_options($makefile, "", &get_logfile); |
run_make_test(undef, '', "touch baz\n"); |
|
$answer = "touch baz\n"; |
|
|
&compare_output($answer,&get_logfile(1)); |
|
35 |
|
|
36 |
unlink(qw(foo bar baz)); |
unlink(qw(foo bar baz)); |
37 |
|
|
38 |
# Test prereqs that are both order and non-order |
# TEST #3 -- Make sure the order-only prereq was promoted to normal. |
|
|
|
|
$makefile2 = &get_tmpfile; |
|
|
|
|
|
open(MAKEFILE,"> $makefile2"); |
|
39 |
|
|
40 |
print MAKEFILE <<'EOF'; |
run_make_test(q! |
41 |
foo: bar | baz |
foo: bar | baz |
42 |
@echo '$$^ = $^' |
@echo '$$^ = $^' |
43 |
@echo '$$| = $|' |
@echo '$$| = $|' |
48 |
.PHONY: baz |
.PHONY: baz |
49 |
|
|
50 |
bar baz: |
bar baz: |
51 |
touch $@ |
touch $@!, |
52 |
EOF |
'', "touch bar\ntouch baz\n\$^ = bar baz\n\$| = \ntouch foo\n"); |
|
|
|
|
close(MAKEFILE); |
|
|
|
|
|
# TEST #3 -- Make sure the order-only prereq was promoted to normal. |
|
|
|
|
|
&run_make_with_options($makefile2, "", &get_logfile); |
|
|
$answer = "touch bar\ntouch baz\n\$^ = bar baz\n\$| = \ntouch foo\n"; |
|
|
&compare_output($answer,&get_logfile(1)); |
|
53 |
|
|
54 |
|
|
55 |
# TEST #4 -- now we do it again |
# TEST #4 -- now we do it again |
56 |
|
|
57 |
&run_make_with_options($makefile2, "", &get_logfile); |
run_make_test(undef, '', "touch baz\n\$^ = bar baz\n\$| = \ntouch foo\n"); |
|
$answer = "touch baz\n\$^ = bar baz\n\$| = \ntouch foo\n"; |
|
|
&compare_output($answer,&get_logfile(1)); |
|
58 |
|
|
59 |
unlink(qw(foo bar baz)); |
unlink(qw(foo bar baz)); |
60 |
|
|
61 |
# Test empty normal prereqs |
# Test empty normal prereqs |
62 |
|
|
63 |
$makefile3 = &get_tmpfile; |
# TEST #5 -- make sure the parser was correct. |
|
|
|
|
open(MAKEFILE,"> $makefile3"); |
|
64 |
|
|
65 |
print MAKEFILE <<'EOF'; |
run_make_test(q! |
66 |
foo:| baz |
foo:| baz |
67 |
@echo '$$^ = $^' |
@echo '$$^ = $^' |
68 |
@echo '$$| = $|' |
@echo '$$| = $|' |
71 |
.PHONY: baz |
.PHONY: baz |
72 |
|
|
73 |
baz: |
baz: |
74 |
touch $@ |
touch $@!, |
75 |
EOF |
'', "touch baz\n\$^ = \n\$| = baz\ntouch foo\n"); |
|
|
|
|
close(MAKEFILE); |
|
|
|
|
|
# TEST #5 -- make sure the parser was correct. |
|
|
|
|
|
&run_make_with_options($makefile3, "", &get_logfile); |
|
|
$answer = "touch baz\n\$^ = \n\$| = baz\ntouch foo\n"; |
|
|
&compare_output($answer,&get_logfile(1)); |
|
|
|
|
76 |
|
|
77 |
# TEST #6 -- now we do it again: this time foo won't be built |
# TEST #6 -- now we do it again: this time foo won't be built |
78 |
|
|
79 |
&run_make_with_options($makefile3, "", &get_logfile); |
run_make_test(undef, '', "touch baz\n"); |
|
$answer = "touch baz\n"; |
|
|
&compare_output($answer,&get_logfile(1)); |
|
80 |
|
|
81 |
unlink(qw(foo baz)); |
unlink(qw(foo baz)); |
82 |
|
|
83 |
# Test order-only in pattern rules |
# Test order-only in pattern rules |
84 |
|
|
85 |
$makefile4 = &get_tmpfile; |
# TEST #7 -- make sure the parser was correct. |
|
|
|
|
open(MAKEFILE,"> $makefile4"); |
|
86 |
|
|
87 |
print MAKEFILE <<'EOF'; |
run_make_test(q! |
88 |
%.w : %.x | baz |
%.w : %.x | baz |
89 |
@echo '$$^ = $^' |
@echo '$$^ = $^' |
90 |
@echo '$$| = $|' |
@echo '$$| = $|' |
94 |
|
|
95 |
.PHONY: baz |
.PHONY: baz |
96 |
foo.x baz: |
foo.x baz: |
97 |
touch $@ |
touch $@!, |
98 |
EOF |
'', |
99 |
|
"touch foo.x\ntouch baz\n\$^ = foo.x\n\$| = baz\ntouch foo.w\n"); |
|
close(MAKEFILE); |
|
|
|
|
|
# TEST #7 -- make sure the parser was correct. |
|
|
|
|
|
&run_make_with_options($makefile4, "", &get_logfile); |
|
|
$answer = "touch foo.x\ntouch baz\n\$^ = foo.x\n\$| = baz\ntouch foo.w\n"; |
|
|
&compare_output($answer,&get_logfile(1)); |
|
100 |
|
|
101 |
# TEST #8 -- now we do it again: this time foo.w won't be built |
# TEST #8 -- now we do it again: this time foo.w won't be built |
102 |
|
|
103 |
&run_make_with_options($makefile4, "", &get_logfile); |
run_make_test(undef, '', "touch baz\n"); |
|
$answer = "touch baz\n"; |
|
|
&compare_output($answer,&get_logfile(1)); |
|
104 |
|
|
105 |
unlink(qw(foo.w foo.x baz)); |
unlink(qw(foo.w foo.x baz)); |
106 |
|
|
111 |
%r: | baz ; @echo $< $^ $| |
%r: | baz ; @echo $< $^ $| |
112 |
bar: foo |
bar: foo |
113 |
foo:;@: |
foo:;@: |
114 |
baz:;@: |
baz:;@:', |
115 |
', '', "foo foo baz\n"); |
'', "foo foo baz\n"); |
116 |
|
|
117 |
|
|
118 |
1; |
1; |