Debian Codegraph @

tests/scripts/features/grouped_targets

raw
1 # -*-perl-*-
2
3 $description = "This test is about grouped multiple targets indicated by &:";
4 $details = "Here we test for requirements like\n"
5 ."- if multiple such targets are updated, the recipe is run once\n"
6 ."- parsing issues related to the &: syntax itself\n";
7
8 # Parsing: &: allowed without any targets.
9 run_make_test(q{
10 .PHONY: all
11 &:;
12 all: ;@printf ''
13 },
14 '', "");
15
16 # Parsing: &: works not preceded by whitespace.
17 run_make_test(q{
18 foo&:;@echo foo
19 },
20 'foo', "foo");
21
22 # Ordinary rule runs recipe four times for t1 t2 t3 t4.
23 # Grouped target rule runs recipe once; others are considered updated.
24 run_make_test(q{
25 .PHONY: t1 t2 t3 t4 g1 g2 g3 g4
26 t1 t2 t3 t4: ; @echo $@
27 g1 g2 g3 g4 &: ; @echo $@
28 },
29 't1 t2 t3 t4 g1 g2 g3 g4',
30 "t1\n"
31 ."t2\n"
32 ."t3\n"
33 ."t4\n"
34 ."g1\n"
35 ."#MAKE#: Nothing to be done for 'g2'.\n"
36 ."#MAKE#: Nothing to be done for 'g3'.\n"
37 ."#MAKE#: Nothing to be done for 'g4'.");
38
39 # Similar to previous test, but targets come from m1 phony
40 # rather than from the command line. We don't see "Nothing to
41 # be done for" messages. Also, note reversed order g4 g3 ...
42 # Thus the auto variable $@ is "g4" when that rule fires.
43 run_make_test(q{
44 .PHONY: m1 t1 t2 t3 t4 g1 g2 g3 g4
45 m1: t1 t2 t3 t4 g4 g3 g2 g1
46 t1 t2 t3 t4: ; @echo $@
47 g1 g2 g3 g4&: ; @echo $@
48 },
49 '',
50 "t1\nt2\nt3\nt4\ng4");
51
52 # Set a grouped target recipe for existing targets
53 run_make_test(q{
54 .PHONY: M a b
55 M: a b
56 a:
57 a b&: ; @echo Y
58 b:
59 },
60 '',
61 "Y");
62
63 # grouped targets require a recipe
64 run_make_test(q{
65 .PHONY: M a b
66 M: a b
67 a b&:
68 },
69 '',
70 "#MAKEFILE#:4: *** grouped targets must provide a recipe. Stop.", 512);
71
72 # Pattern rules use grouped targets anyway so it's a no-op
73 run_make_test(q{
74 .PHONY: M
75 M: a.q b.q
76 a.% b.%&: ; @echo Y
77 },
78 '',
79 "Y");
80
81 # Double-colon grouped target rules.
82 run_make_test(q{
83 .PHONY: M a b c d e f g h
84 M: a b
85 a b c&:: ; @echo X
86 c d e&:: ; @echo Y
87 f g h&:: ; @echo Z
88 },
89 '',
90 "X");
91
92 run_make_test(q{
93 .PHONY: M a b c d e f g h
94 M: c
95 a b c&:: ; @echo X
96 c d e&:: ; @echo Y
97 f g h&:: ; @echo Z
98 },
99 '',
100 "X\nY");
101
102 run_make_test(q{
103 .PHONY: M a b c d e f g h
104 M: a b c d e
105 a b c&:: ; @echo X
106 c d e&:: ; @echo Y
107 f g h&:: ; @echo Z
108 },
109 '',
110 "X\nY");
111
112 run_make_test(q{
113 .PHONY: M a b c d e f g h
114 M: d e
115 a b c&:: ; @echo X
116 c d e&:: ; @echo Y
117 f g h&:: ; @echo Z
118 },
119 '',
120 "Y");
121
122 run_make_test(q{
123 .PHONY: M a b c d e f g h
124 M: f g h
125 a b c&:: ; @echo X
126 c d e&:: ; @echo Y
127 f g h&:: ; @echo Z
128 },
129 '',
130 "Z");
131
132 # This tells the test driver that the perl test script executed properly.
133 1;