xref: /freebsd/contrib/bmake/unit-tests/deptgt-end-jobs.mk (revision 956e45f6fb3e18b8e89b1341708db60c30bb9f27)
1*956e45f6SSimon J. Gerraty# $NetBSD: deptgt-end-jobs.mk,v 1.1 2020/09/23 03:06:38 rillig Exp $
2*956e45f6SSimon J. Gerraty#
3*956e45f6SSimon J. Gerraty# Tests for the special target .END in dependency declarations,
4*956e45f6SSimon J. Gerraty# which is run after making the desired targets.
5*956e45f6SSimon J. Gerraty#
6*956e45f6SSimon J. Gerraty# This test is very similar to deptgt-end.mk, except for the -j option.
7*956e45f6SSimon J. Gerraty# This option enables parallel mode, in which the code from job.c partially
8*956e45f6SSimon J. Gerraty# replaces the code from compat.c.
9*956e45f6SSimon J. Gerraty#
10*956e45f6SSimon J. Gerraty# Before 2020-08-22, this test crashed with a null pointer dereference.
11*956e45f6SSimon J. Gerraty# Before 2020-09-23, this test crashed with an assertion failure.
12*956e45f6SSimon J. Gerraty.MAKEFLAGS: -j 8
13*956e45f6SSimon J. Gerraty
14*956e45f6SSimon J. GerratyVAR=	Should not be expanded.
15*956e45f6SSimon J. Gerraty
16*956e45f6SSimon J. Gerraty.BEGIN:
17*956e45f6SSimon J. Gerraty	: $@ '$${VAR}'
18*956e45f6SSimon J. Gerraty	...
19*956e45f6SSimon J. Gerraty	: $@ '$${VAR}' deferred
20*956e45f6SSimon J. Gerraty# Oops: The deferred command must not be expanded twice.
21*956e45f6SSimon J. Gerraty# The Var_Subst in Compat_RunCommand looks suspicious.
22*956e45f6SSimon J. Gerraty# The Var_Subst in JobSaveCommand looks suspicious.
23*956e45f6SSimon J. Gerraty
24*956e45f6SSimon J. Gerraty.END:
25*956e45f6SSimon J. Gerraty	: $@ '$${VAR}'
26*956e45f6SSimon J. Gerraty	...
27*956e45f6SSimon J. Gerraty	: $@ '$${VAR}' deferred
28*956e45f6SSimon J. Gerraty
29*956e45f6SSimon J. Gerratyall:
30*956e45f6SSimon J. Gerraty	: $@ '$${VAR}'
31*956e45f6SSimon J. Gerraty	...
32*956e45f6SSimon J. Gerraty	: $@ '$${VAR}' deferred
33*956e45f6SSimon J. Gerraty# Oops: The deferred command must not be expanded twice.
34*956e45f6SSimon J. Gerraty# The Var_Subst in Compat_RunCommand looks suspicious.
35*956e45f6SSimon J. Gerraty# The Var_Subst in JobSaveCommand looks suspicious.
36*956e45f6SSimon J. Gerraty
37*956e45f6SSimon J. Gerraty# The deferred commands are run in the order '.END .BEGIN all'.
38*956e45f6SSimon J. Gerraty# This may be unexpected at first since the natural order would be
39*956e45f6SSimon J. Gerraty# '.BEGIN all .END', but it is implemented correctly.
40*956e45f6SSimon J. Gerraty#
41*956e45f6SSimon J. Gerraty# At the point where the commands of a node with deferred commands are run,
42*956e45f6SSimon J. Gerraty# the deferred commands are appended to the commands of the .END node.
43*956e45f6SSimon J. Gerraty# This happens in Compat_RunCommand, and to prevent an endless loop, the
44*956e45f6SSimon J. Gerraty# deferred commands of the .END node itself are not appended to itself.
45*956e45f6SSimon J. Gerraty# Instead, the deferred commands of the .END node are run as if they were
46*956e45f6SSimon J. Gerraty# immediate commands.
47