xref: /freebsd/contrib/bmake/unit-tests/varname-make_print_var_on_error-jobs.mk (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1# $NetBSD: varname-make_print_var_on_error-jobs.mk,v 1.4 2023/11/19 22:32:44 rillig Exp $
2#
3# Tests for the special MAKE_PRINT_VAR_ON_ERROR variable, which prints the
4# values of selected variables on error.
5#
6# The variable .ERROR_CMD contains all commands of the target, with
7# expressions expanded, just as they were printed to the shell command file.
8#
9# The commands in .ERROR_CMD are space-separated.  Since each command usually
10# contains spaces as well, this value is only intended as a first hint to what
11# happened.  For more details, use the debug options -de, -dj, -dl, -dn, -dx.
12#
13# See also:
14#	compat-error.mk
15
16# XXX: As of 2021-02-04, PrintOnError calls Var_Subst with SCOPE_GLOBAL, which
17# does not expand the node-local variables like .TARGET.  This results in the
18# double '${.TARGET}' in the output.
19
20# As of 2020-10-23, .ERROR_CMD only works in parallel mode.
21.MAKEFLAGS: -j1
22
23MAKE_PRINT_VAR_ON_ERROR=	.ERROR_TARGET .ERROR_CMD
24
25all:
26	@: before '${.TARGET}' '$${.TARGET}' '$$$${.TARGET}'
27	echo fail ${.TARGET}; false '${.TARGET}' '$${.TARGET}' '$$$${.TARGET}'
28	@: after '${.TARGET}' '$${.TARGET}' '$$$${.TARGET}'
29