- Enhance .POSIX to set -e when invoking shells, as demanded by a
[make.git] / tests / scripts / features / order_only
blob4ebdc2b8da86168567ab435b71e8c09c9a90375d
1 #                                                                    -*-perl-*-
2 $description = "Test order-only prerequisites.";
4 $details = "\
5 Create makefiles with various combinations of normal and order-only
6 prerequisites and ensure they behave properly.  Test the \$| variable.";
8 # TEST #0 -- Basics
10 run_make_test('
11 %r: | baz ; @echo $< $^ $|
12 bar: foo
13 foo:;@:
14 baz:;@:',
15               '', "foo foo baz\n");
17 # TEST #1 -- First try: the order-only prereqs need to be built.
19 run_make_test(q!
20 foo: bar | baz
21         @echo '$$^ = $^'
22         @echo '$$| = $|'
23         touch $@
25 .PHONY: baz
27 bar baz:
28         touch $@!,
29               '', "touch bar\ntouch baz\n\$^ = bar\n\$| = baz\ntouch foo\n");
32 # TEST #2 -- now we do it again: baz is PHONY but foo should _NOT_ be updated
34 run_make_test(undef, '', "touch baz\n");
36 unlink(qw(foo bar baz));
38 # TEST #3 -- Make sure the order-only prereq was promoted to normal.
40 run_make_test(q!
41 foo: bar | baz
42         @echo '$$^ = $^'
43         @echo '$$| = $|'
44         touch $@
46 foo: baz
48 .PHONY: baz
50 bar baz:
51         touch $@!,
52               '', "touch bar\ntouch baz\n\$^ = bar baz\n\$| = \ntouch foo\n");
55 # TEST #4 -- now we do it again
57 run_make_test(undef, '', "touch baz\n\$^ = bar baz\n\$| = \ntouch foo\n");
59 unlink(qw(foo bar baz));
61 # Test empty normal prereqs
63 # TEST #5 -- make sure the parser was correct.
65 run_make_test(q!
66 foo:| baz
67         @echo '$$^ = $^'
68         @echo '$$| = $|'
69         touch $@
71 .PHONY: baz
73 baz:
74         touch $@!,
75               '', "touch baz\n\$^ = \n\$| = baz\ntouch foo\n");
77 # TEST #6 -- now we do it again: this time foo won't be built
79 run_make_test(undef, '', "touch baz\n");
81 unlink(qw(foo baz));
83 # Test order-only in pattern rules
85 # TEST #7 -- make sure the parser was correct.
87 run_make_test(q!
88 %.w : %.x | baz
89         @echo '$$^ = $^'
90         @echo '$$| = $|'
91         touch $@
93 all: foo.w
95 .PHONY: baz
96 foo.x baz:
97         touch $@!,
98               '',
99               "touch foo.x\ntouch baz\n\$^ = foo.x\n\$| = baz\ntouch foo.w\n");
101 # TEST #8 -- now we do it again: this time foo.w won't be built
103 run_make_test(undef, '', "touch baz\n");
105 unlink(qw(foo.w foo.x baz));
107 # TEST #9 -- make sure that $< is set correctly in the face of order-only
108 # prerequisites in pattern rules.
110 run_make_test('
111 %r: | baz ; @echo $< $^ $|
112 bar: foo
113 foo:;@:
114 baz:;@:',
115               '', "foo foo baz\n");