summaryrefslogtreecommitdiff
path: root/tests/scripts/targets/WAIT
blob: b981023f8f7c69830554d90b23b74055ed934b78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#                                                                    -*-perl-*-

$description = "Test the behaviour of the .WAIT target.";

$details = "";

# Ensure .WAIT doesn't appear in any automatic variables

run_make_test(q!
all: .WAIT pre1 .WAIT pre2 | .WAIT pre3 ; @echo '<=$< ^=$^ ?=$? +=$+ |=$|'
pre1 pre2 pre3:;

# This is just here so we don't fail with older versions of make
.WAIT:
!,
    '', '<=pre1 ^=pre1 pre2 ?=pre1 pre2 +=pre1 pre2 |=pre3');

run_make_test(q!
.SECONDEXPANSION:
all: $$(pre) ; @echo '<=$< ^=$^ ?=$? +=$+ |=$|'
pre1 pre2 pre3:;

pre = .WAIT pre1 .WAIT pre2 | .WAIT pre3
# This is just here so we don't fail with older versions of make
.WAIT:
!,
    '', '<=pre1 ^=pre1 pre2 ?=pre1 pre2 +=pre1 pre2 |=pre3');

run_make_test(q!
all: pre
p% : .WAIT p%1 .WAIT p%2 | .WAIT p%3; @echo '<=$< ^=$^ ?=$? +=$+ |=$|'
pre1 pre2 pre3: ;

# This is just here so we don't fail with older versions of make
.WAIT:
!,
              '', "<=pre1 ^=pre1 pre2 ?=pre1 pre2 +=pre1 pre2 |=pre3\n");

# Unfortunately I don't think we can get away from using sleep here; at least
# I can't think of any way to make sure .WAIT works without it.  Even with it,
# it's not reliable (in that even if .WAIT is not working we MIGHT succeed the
# test--it shouldn't ever be the case that we fail the test unexpectedly).
# That makes this test suite slow to run :-/.

run_make_test(q!
all : pre1 .WAIT pre2
pre1: ; @#HELPER# -q out start-$@ sleep 1 out end-$@
pre2: ; @#HELPER# -q out $@

# This is just here so we don't fail with older versions of make
.WAIT:
!,
              '-j10', "start-pre1\nend-pre1\npre2\n");

# Ensure .WAIT doesn't add extra a dependency between its targets

run_make_test(undef, '-j10 pre2', "pre2\n");

# Ensure .WAIT doesn't wait between all targets

run_make_test(q!
all : pre1 .WAIT pre2 pre3
pre1: ; @#HELPER# -q out start-$@ sleep 1 out end-$@
pre2: ; @#HELPER# -q out start-$@ file TWO wait THREE out end-$@
pre3: ; @#HELPER# -q wait TWO out $@ file THREE

# This is just here so we don't fail with older versions of make
.WAIT:
!,
              '-j10', "start-pre1\nend-pre1\nstart-pre2\npre3\nend-pre2\n");

unlink(qw(TWO THREE));

# Ensure .WAIT waits for ALL targets on the left before ANY targets on the right

run_make_test(q!
all : pre1 pre2 .WAIT post1 post2
pre1: ; @#HELPER# -q out start-$@ file PRE1 wait PRE2 sleep 1 out end-$@
pre2: ; @#HELPER# -q wait PRE1 out $@ file PRE2

post1: ; @#HELPER# -q wait POST2 out $@ file POST1
post2: ; @#HELPER# -q file POST2 wait POST1 out $@

# This is just here so we don't fail with older versions of make
.WAIT:
!,
              '-j10', "start-pre1\npre2\nend-pre1\npost1\npost2\n");

unlink(qw(PRE1 PRE2 POST1 POST2));

# See if .WAIT takes effect between different lists of prereqs
# In the current implementation, .WAIT waits only between two prerequisites
# in a given target.  These same two targets might be run in a different
# order if they appear as prerequisites of another target.  This is the way
# other implementations of .WAIT work.  I personally think it's gross and
# makes .WAIT just a toy when it comes to ordering, but it's much simpler
# to implement than creating an actual edge in the DAG to represent .WAIT
# and since that's what users expect, we'll do the same for now.

run_make_test(q!
all : one two
one: pre1 .WAIT pre2
two: pre2 pre1
pre1: ; @#HELPER# -q out start-$@ file PRE1 wait PRE2 out end-$@
pre2: ; @#HELPER# -q wait PRE1 out $@ file PRE2


# This is just here so we don't fail with older versions of make
.WAIT:
!,
              '-j10', "start-pre1\npre2\nend-pre1\n");
unlink(qw(PRE1 PRE2));

# Check that .WAIT works with pattern rules

run_make_test(q!
all: pre
p% : p%1 .WAIT p%2;
pre1: ; @#HELPER# -q out start-$@ sleep 1 out end-$@
pre2: ; @#HELPER# -q out $@

# This is just here so we don't fail with older versions of make
.WAIT:
!,
              '-j10', "start-pre1\nend-pre1\npre2\n");

# Check that .WAIT works with secondarily expanded rules

run_make_test(q!
.SECONDEXPANSION:
all: $$(pre)
pre1: ; @#HELPER# -q out start-$@ sleep 1 out end-$@
pre2: ; @#HELPER# -q out $@
pre3: ; @#HELPER# -q out $@

pre = .WAIT pre1 .WAIT pre2 | .WAIT pre3

# This is just here so we don't fail with older versions of make
.WAIT:
!,
              '-j10', "start-pre1\nend-pre1\npre2\npre3\n");

# Verify NOTPARALLEL works

run_make_test(q!
all : pre1 pre2
pre1: ; @#HELPER# -q out start-$@ sleep 1 out end-$@
pre2: ; @#HELPER# -q out $@

.NOTPARALLEL:
!,
              '-j10', "start-pre1\nend-pre1\npre2\n");

run_make_test(q!
all : p1 .WAIT np1

p1: pre1 pre2
pre1: ; @#HELPER# -q out start-$@ file PRE1 wait PRE2 out end-$@
pre2: ; @#HELPER# -q wait PRE1 out $@ file PRE2


np1: npre1 npre2
npre1: ; @#HELPER# -q out start-$@ sleep 1 out end-$@
npre2: ; @#HELPER# -q out $@

.NOTPARALLEL: np1
!,
              '-j10', "start-pre1\npre2\nend-pre1\nstart-npre1\nend-npre1\nnpre2\n");
unlink(qw(PRE1 PRE2));

# Ensure we don't shuffle if .WAIT is set

run_make_test(q!
all : pre1 .WAIT pre2
pre1: ; @#HELPER# -q out start-$@ sleep 1 out end-$@
pre2: ; @#HELPER# -q out $@

# This is just here so we don't fail with older versions of make
.WAIT:
!,
              '-j10 --shuffle=reverse', "start-pre1\nend-pre1\npre2\n");

# Warn about invalid .WAIT definitions

run_make_test(q!
.WAIT: foo
.WAIT: ; echo oops
all:;@:
!,
              '', "#MAKEFILE#:2: .WAIT should not have prerequisites\n#MAKEFILE#:3: .WAIT should not have commands\n");

# This tells the test driver that the perl test script executed properly.
1;