summaryrefslogtreecommitdiff
path: root/tests/scripts/targets/WAIT
blob: 4d56f6e732076b8bac3899df6e9035162b3c8446 (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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
#                                                                    -*-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");

# sv 63856.
# .WAIT on the command line.

run_make_test(q!
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 pre1 .WAIT pre2', "start-pre1\nend-pre1\npre2\n");

# Multiple consecutive .WAITs.

run_make_test(q!
all : pre1 .WAIT .WAIT .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");

# First and last prerequsites are .WAIT.

run_make_test(q!
all : .WAIT pre1 .WAIT pre2 .WAIT
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");

# All prerequisites are .WAITs.

run_make_test(q!
all : .WAIT .WAIT .WAIT

# This is just here so we don't fail with older versions of make
.WAIT:
!,
              '-j10', "#MAKE#: Nothing to be done for 'all'.\n");

run_make_test(q!
all:
!,
              '-j10 .WAIT', "#MAKE#: Nothing to be done for 'all'.\n");

# Wait between the duplicate goals.

run_make_test(q!
all: hello.tsk .WAIT hello.tsk
hello.tsk:; $(info $@)
!,
              '-j10', "hello.tsk\n#MAKE#: Nothing to be done for 'all'.\n");

# Wait between the duplicate command line goals.

run_make_test(q!
hello.tsk:; $(info $@)
!,
              '-j10 hello.tsk .WAIT hello.tsk', "hello.tsk\n#MAKE#: 'hello.tsk' is up to date.\n#MAKE#: 'hello.tsk' is up to date.\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 on the command line doesn't wait between all targets.

run_make_test(q!
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 pre1 .WAIT pre2 pre3', "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));

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

run_make_test(q!
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 pre1 pre2 .WAIT post1 post2', "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");

# Ensure we don't shuffle if .WAIT is set on the command line.

run_make_test(q!
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 pre1 .WAIT pre2', "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");

# Wait for all double colon targets on the left, before building targets on the
# right.
# Subtest 1. First run this test without .WAIT and observe and A recipes
# interleave with B recipes.
# Then run the same test with .WAIT and observe that all A recipes get started
# sequentially before the 1st B recipe gets started and then all B recipes get
# started sequentially.

unlink('A-1-done', 'A-2-done', 'A-3-done', 'B-1-done', 'B-2-done', 'B-3-done');

run_make_test(q!
all: A B
A::; @#HELPER# -q out A-1 file A-1-done wait B-1-done out A-1-done
A::; @#HELPER# -q out A-2 file A-2-done wait B-2-done out A-2-done
A::; @#HELPER# -q out A-3 file A-3-done wait B-3-done out A-3-done
B::; @#HELPER# -q wait A-1-done out B-1 out B-1-done file B-1-done
B::; @#HELPER# -q wait A-2-done out B-2 out B-2-done file B-2-done
B::; @#HELPER# -q wait A-3-done out B-3 out B-3-done file B-3-done

# This is just here so we don't fail with older versions of make
.WAIT:
!,
              '-j10', "A-1\nB-1\nB-1-done\nA-1-done\nA-2\nB-2\nB-2-done\nA-2-done\nA-3\nB-3\nB-3-done\nA-3-done\n");

unlink('A-1-done', 'A-2-done', 'A-3-done', 'B-1-done', 'B-2-done', 'B-3-done');

# Subtest 2.
# Wait for all double colon targets on the left, before building targets on the
# right.

run_make_test(q!
all: A .WAIT B
A::; @#HELPER# -q out $@-1 out $@-1-done
A::; @#HELPER# -q out $@-2 out $@-2-done
A::; @#HELPER# -q out $@-3 out $@-3-done
B::; @#HELPER# -q out $@-1 out $@-1-done
B::; @#HELPER# -q out $@-2 out $@-2-done
B::; @#HELPER# -q out $@-3 out $@-3-done

# This is just here so we don't fail with older versions of make
.WAIT:
!,
              '-j10', "A-1\nA-1-done\nA-2\nA-2-done\nA-3\nA-3-done\nB-1\nB-1-done\nB-2\nB-2-done\nB-3\nB-3-done\n");

# sv 63856.
# Wait for all double colon targets on the left, before building targets on the
# right.
# Subtest 1. First run this test without .WAIT and observe and A recipes
# interleave with B recipes.
# Then run the same test with .WAIT and observe that all A recipes get started
# sequentially before the 1st B recipe gets started and then all B recipes get
# started sequentially.
# The targets are specified on the command line.

unlink('A-1-done', 'A-2-done', 'A-3-done', 'B-1-done', 'B-2-done', 'B-3-done');

run_make_test(q!
A::; @#HELPER# -q out A-1 file A-1-done wait B-1-done out A-1-done
A::; @#HELPER# -q out A-2 file A-2-done wait B-2-done out A-2-done
A::; @#HELPER# -q out A-3 file A-3-done wait B-3-done out A-3-done
B::; @#HELPER# -q wait A-1-done out B-1 out B-1-done file B-1-done
B::; @#HELPER# -q wait A-2-done out B-2 out B-2-done file B-2-done
B::; @#HELPER# -q wait A-3-done out B-3 out B-3-done file B-3-done

# This is just here so we don't fail with older versions of make
.WAIT:
!,
              '-j10 A B', "A-1\nB-1\nB-1-done\nA-1-done\nA-2\nB-2\nB-2-done\nA-2-done\nA-3\nB-3\nB-3-done\nA-3-done\n");

unlink('A-1-done', 'A-2-done', 'A-3-done', 'B-1-done', 'B-2-done', 'B-3-done');

# Subtest 2.
# sv 63856.
# Wait for all double colon targets on the left, before building targets on the
# right. The targets are specified on the command line.

run_make_test(q!
A::; @#HELPER# -q out $@-1 out $@-1-done
A::; @#HELPER# -q out $@-2 out $@-2-done
A::; @#HELPER# -q out $@-3 out $@-3-done
B::; @#HELPER# -q out $@-1 out $@-1-done
B::; @#HELPER# -q out $@-2 out $@-2-done
B::; @#HELPER# -q out $@-3 out $@-3-done

# This is just here so we don't fail with older versions of make
.WAIT:
!,
              '-j10 A .WAIT B', "A-1\nA-1-done\nA-2\nA-2-done\nA-3\nA-3-done\nB-1\nB-1-done\nB-2\nB-2-done\nB-3\nB-3-done\n");


# Wait for all double colon targets on the left, before building targets on the
# right.
# Regular targets which have double colon targets as prerequisites.
# Subtest 1. First run this test without .WAIT and observe and A recipes
# interleave with B recipes.
# The targets are specified in the makefile.

unlink('D', 'D-done', 'E', 'E-done');
unlink('A-1-done', 'A-2-done', 'A-3-done', 'B-1-done', 'B-2-done', 'B-3-done');

run_make_test(q!
all: C .WAIT A B
A::; @#HELPER# -q out A-1 file A-1-done wait B-1-done out A-1-done
A::; @#HELPER# -q out A-2 file A-2-done wait B-2-done out A-2-done
A::; @#HELPER# -q out A-3 file A-3-done wait B-3-done out A-3-done
B::; @#HELPER# -q wait A-1-done out B-1 out B-1-done file B-1-done
B::; @#HELPER# -q wait A-2-done out B-2 out B-2-done file B-2-done
B::; @#HELPER# -q wait A-3-done out B-3 out B-3-done file B-3-done

C: D E
D:; @#HELPER# -q out D file D wait E-done out D-done
E:; @#HELPER# -q wait D out E out E-done file E-done

.PHONY: C D E

# This is just here so we don't fail with older versions of make
.WAIT:
!,
              '-j10', "D\nE\nE-done\nD-done\nA-1\nB-1\nB-1-done\nA-1-done\nA-2\nB-2\nB-2-done\nA-2-done\nA-3\nB-3\nB-3-done\nA-3-done\n");

# Wait for all double colon targets on the left, before building targets on the
# right.
# Regular targets which have double colon targets as prerequisites.
# Subtest 2.
# Run the same test with .WAIT and observe that all A recipes get started
# sequentially before the 1st B recipe gets started and then all B recipes get
# started sequentially.
# The targets are specified in the makefile.
#

unlink('D', 'D-done', 'E', 'E-done');
unlink('A-1-done', 'A-2-done', 'A-3-done', 'B-1-done', 'B-2-done', 'B-3-done');

run_make_test(q!
all: C .WAIT A .WAIT B
A::; @#HELPER# -q out $@-1 out $@-1-done
A::; @#HELPER# -q out $@-2 out $@-2-done
A::; @#HELPER# -q out $@-3 out $@-3-done
B::; @#HELPER# -q out $@-1 out $@-1-done
B::; @#HELPER# -q out $@-2 out $@-2-done
B::; @#HELPER# -q out $@-3 out $@-3-done

C: D E
D:; @#HELPER# -q out D file D wait E-done out D-done
E:; @#HELPER# -q wait D out E out E-done file E-done

.PHONY: C D E

# This is just here so we don't fail with older versions of make
.WAIT:
!,
              '-j10', "D\nE\nE-done\nD-done\nA-1\nA-1-done\nA-2\nA-2-done\nA-3\nA-3-done\nB-1\nB-1-done\nB-2\nB-2-done\nB-3\nB-3-done\n");


# Wait for all double colon targets on the left, before building targets on the
# right.
# Regular targets which have double colon targets as prerequisites.
# Subtest 1. First run this test without .WAIT and observe and A recipes
# interleave with B recipes.
# The targets are specified on the command line.

unlink('D', 'D-done', 'E', 'E-done');
unlink('A-1-done', 'A-2-done', 'A-3-done', 'B-1-done', 'B-2-done', 'B-3-done');

run_make_test(q!
A::; @#HELPER# -q out A-1 file A-1-done wait B-1-done out A-1-done
A::; @#HELPER# -q out A-2 file A-2-done wait B-2-done out A-2-done
A::; @#HELPER# -q out A-3 file A-3-done wait B-3-done out A-3-done
B::; @#HELPER# -q wait A-1-done out B-1 out B-1-done file B-1-done
B::; @#HELPER# -q wait A-2-done out B-2 out B-2-done file B-2-done
B::; @#HELPER# -q wait A-3-done out B-3 out B-3-done file B-3-done

C: D E
D:; @#HELPER# -q out D file D wait E-done out D-done
E:; @#HELPER# -q wait D out E out E-done file E-done

.PHONY: C D E

# This is just here so we don't fail with older versions of make
.WAIT:
!,
              '-j10 C .WAIT A B', "D\nE\nE-done\nD-done\nA-1\nB-1\nB-1-done\nA-1-done\nA-2\nB-2\nB-2-done\nA-2-done\nA-3\nB-3\nB-3-done\nA-3-done\n");

# Wait for all double colon targets on the left, before building targets on the
# right.
# Regular targets which have double colon targets as prerequisites.
# Subtest 2.
# Run the same test with .WAIT and observe that all A recipes get started
# sequentially before the 1st B recipe gets started and then all B recipes get
# started sequentially.
# The targets are specified on the command line.

unlink('D', 'D-done', 'E', 'E-done');
unlink('A-1-done', 'A-2-done', 'A-3-done', 'B-1-done', 'B-2-done', 'B-3-done');

run_make_test(q!
A::; @#HELPER# -q out $@-1 out $@-1-done
A::; @#HELPER# -q out $@-2 out $@-2-done
A::; @#HELPER# -q out $@-3 out $@-3-done
B::; @#HELPER# -q out $@-1 out $@-1-done
B::; @#HELPER# -q out $@-2 out $@-2-done
B::; @#HELPER# -q out $@-3 out $@-3-done

C: D E
D:; @#HELPER# -q out D file D wait E-done out D-done
E:; @#HELPER# -q wait D out E out E-done file E-done

.PHONY: C D E

# This is just here so we don't fail with older versions of make
.WAIT:
!,
              '-j10 C .WAIT A .WAIT B', "D\nE\nE-done\nD-done\nA-1\nA-1-done\nA-2\nA-2-done\nA-3\nA-3-done\nB-1\nB-1-done\nB-2\nB-2-done\nB-3\nB-3-done\n");

unlink('D', 'D-done', 'E', 'E-done');
unlink('A-1-done', 'A-2-done', 'A-3-done', 'B-1-done', 'B-2-done', 'B-3-done');

# Wait for all double colon targets on the left, before building targets on the
# right.
# Double colon targets have reqular targets as prerequisites.
# Subtest 1. First run this test without .WAIT and observe and A recipes
# interleave with B recipes.
# The targets are specified in the makefile.

unlink('D', 'D-done', 'E', 'E-done');
unlink('A-1-done', 'A-2-done', 'A-3-done', 'B-1-done', 'B-2-done', 'B-3-done');

run_make_test(q!
all: A B
A:: D; @#HELPER# -q out A-1 file A-1-done wait B-1-done out A-1-done
A::; @#HELPER# -q out A-2 file A-2-done wait B-2-done out A-2-done
A::; @#HELPER# -q out A-3 file A-3-done wait B-3-done out A-3-done
B:: E; @#HELPER# -q wait A-1-done out B-1 out B-1-done file B-1-done
B::; @#HELPER# -q wait A-2-done out B-2 out B-2-done file B-2-done
B::; @#HELPER# -q wait A-3-done out B-3 out B-3-done file B-3-done

D:; @#HELPER# -q out D file D wait E-done out D-done
E:; @#HELPER# -q wait D out E out E-done file E-done

.PHONY: D E

# This is just here so we don't fail with older versions of make
.WAIT:
!,
              '-j10', "D\nE\nE-done\nD-done\nA-1\nB-1\nB-1-done\nA-1-done\nA-2\nB-2\nB-2-done\nA-2-done\nA-3\nB-3\nB-3-done\nA-3-done\n");

# Wait for all double colon targets on the left, before building targets on the
# right.
# Double colon targets have reqular targets as prerequisites.
# Subtest 2.
# Run the same test with .WAIT and observe that all A recipes get started
# sequentially before the 1st B recipe gets started and then all B recipes get
# started sequentially.
# The targets are specified in the makefile.

unlink('D', 'D-done', 'E', 'E-done');
unlink('A-1-done', 'A-2-done', 'A-3-done', 'B-1-done', 'B-2-done', 'B-3-done');

run_make_test(q!
all: A .WAIT B
A:: D; @#HELPER# -q out $@-1 out $@-1-done
A::  ; @#HELPER# -q out $@-2 out $@-2-done
A::  ; @#HELPER# -q out $@-3 out $@-3-done
B:: E; @#HELPER# -q out $@-1 out $@-1-done
B::  ; @#HELPER# -q out $@-2 out $@-2-done
B::  ; @#HELPER# -q out $@-3 out $@-3-done

D:; @#HELPER# -q out D out D-done
E:; @#HELPER# -q out E out E-done

.PHONY: D E

# This is just here so we don't fail with older versions of make
.WAIT:
!,
              '-j10', "D\nD-done\nA-1\nA-1-done\nA-2\nA-2-done\nA-3\nA-3-done\nE\nE-done\nB-1\nB-1-done\nB-2\nB-2-done\nB-3\nB-3-done\n");


# Wait for all double colon targets on the left, before building targets on the
# right.
# Double colon targets have reqular targets as prerequisites.
# Subtest 1. First run this test without .WAIT and observe and A recipes
# interleave with B recipes.
# The targets are specified on the command line.

unlink('D', 'D-done', 'E', 'E-done');
unlink('A-1-done', 'A-2-done', 'A-3-done', 'B-1-done', 'B-2-done', 'B-3-done');

run_make_test(q!
A:: D; @#HELPER# -q out A-1 file A-1-done wait B-1-done out A-1-done
A::; @#HELPER# -q out A-2 file A-2-done wait B-2-done out A-2-done
A::; @#HELPER# -q out A-3 file A-3-done wait B-3-done out A-3-done
B:: E; @#HELPER# -q wait A-1-done out B-1 out B-1-done file B-1-done
B::; @#HELPER# -q wait A-2-done out B-2 out B-2-done file B-2-done
B::; @#HELPER# -q wait A-3-done out B-3 out B-3-done file B-3-done

D:; @#HELPER# -q out D file D wait E-done out D-done
E:; @#HELPER# -q wait D out E out E-done file E-done

.PHONY: D E

# This is just here so we don't fail with older versions of make
.WAIT:
!,
              '-j10 A B', "D\nE\nE-done\nD-done\nA-1\nB-1\nB-1-done\nA-1-done\nA-2\nB-2\nB-2-done\nA-2-done\nA-3\nB-3\nB-3-done\nA-3-done\n");

# Wait for all double colon targets on the left, before building targets on the
# right.
# Double colon targets have reqular targets as prerequisites.
# Subtest 2.
# Run the same test with .WAIT and observe that all A recipes get started
# sequentially before the 1st B recipe gets started and then all B recipes get
# started sequentially.
# The targets are specified on the command line.

unlink('D', 'D-done', 'E', 'E-done');
unlink('A-1-done', 'A-2-done', 'A-3-done', 'B-1-done', 'B-2-done', 'B-3-done');

run_make_test(q!
A:: D; @#HELPER# -q out $@-1 out $@-1-done
A::  ; @#HELPER# -q out $@-2 out $@-2-done
A::  ; @#HELPER# -q out $@-3 out $@-3-done
B:: E; @#HELPER# -q out $@-1 out $@-1-done
B::  ; @#HELPER# -q out $@-2 out $@-2-done
B::  ; @#HELPER# -q out $@-3 out $@-3-done

D:; @#HELPER# -q out D out D-done
E:; @#HELPER# -q out E out E-done

.PHONY: D E

# This is just here so we don't fail with older versions of make
.WAIT:
!,
              '-j10 A .WAIT B', "D\nD-done\nA-1\nA-1-done\nA-2\nA-2-done\nA-3\nA-3-done\nE\nE-done\nB-1\nB-1-done\nB-2\nB-2-done\nB-3\nB-3-done\n");

unlink('D', 'D-done', 'E', 'E-done');
unlink('A-1-done', 'A-2-done', 'A-3-done', 'B-1-done', 'B-2-done', 'B-3-done');

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