xref: /freebsd/contrib/bmake/unit-tests/opt-debug-var.mk (revision 6a7405f5a6b639682cacf01e35d561411ff556aa)
1*6a7405f5SSimon J. Gerraty# $NetBSD: opt-debug-var.mk,v 1.5 2025/01/11 21:21:33 rillig Exp $
2956e45f6SSimon J. Gerraty#
3956e45f6SSimon J. Gerraty# Tests for the -dv command line option, which adds debug logging about
4956e45f6SSimon J. Gerraty# variable assignment and evaluation.
5956e45f6SSimon J. Gerraty
69f45a3c8SSimon J. Gerraty.MAKEFLAGS: -dv
7956e45f6SSimon J. Gerraty
89f45a3c8SSimon J. Gerraty# expect: Global: ASSIGNED = value
99f45a3c8SSimon J. GerratyASSIGNED=	value
109f45a3c8SSimon J. Gerraty
119f45a3c8SSimon J. Gerraty# TODO: Explain why the empty assignment "Global: SUBST = " is needed.
12*6a7405f5SSimon J. Gerraty# expect: Global: SUBST = # (empty)
139f45a3c8SSimon J. Gerraty# expect: Global: SUBST = value
149f45a3c8SSimon J. GerratySUBST:=		value
159f45a3c8SSimon J. Gerraty
169f45a3c8SSimon J. Gerraty.if defined(ASSIGNED)
179f45a3c8SSimon J. Gerraty.endif
189f45a3c8SSimon J. Gerraty
19d5e0a182SSimon J. Gerraty# The usual form of expressions is ${VAR}.  The form $(VAR) is used
209f45a3c8SSimon J. Gerraty# less often as it can be visually confused with the shell construct for
219f45a3c8SSimon J. Gerraty# capturing the output of a subshell, which looks the same.
229f45a3c8SSimon J. Gerraty#
239f45a3c8SSimon J. Gerraty# In conditions, a call to the function 'empty' is syntactically similar to
249f45a3c8SSimon J. Gerraty# the form $(VAR), only that the initial '$' is the 'y' of 'empty'.
259f45a3c8SSimon J. Gerraty#
269f45a3c8SSimon J. Gerraty# expect: Var_Parse: y(ASSIGNED) (eval)
279f45a3c8SSimon J. Gerraty.if !empty(ASSIGNED)
289f45a3c8SSimon J. Gerraty.endif
299f45a3c8SSimon J. Gerraty
309f45a3c8SSimon J. Gerraty
31*6a7405f5SSimon J. Gerraty# An expression for a variable with a single-character ordinary name.
32*6a7405f5SSimon J. Gerraty# expect: Var_Parse: $U (eval-defined-loud)
33*6a7405f5SSimon J. Gerraty# expect+1: Variable "U" is undefined
34*6a7405f5SSimon J. Gerraty.if $U
35*6a7405f5SSimon J. Gerraty.endif
36*6a7405f5SSimon J. Gerraty
37*6a7405f5SSimon J. Gerraty# An expression for a target-specific variable with a single-character name.
38*6a7405f5SSimon J. Gerraty# expect: Var_Parse: $< (eval-defined-loud)
39*6a7405f5SSimon J. Gerraty# expect+1: Variable "<" is undefined
40*6a7405f5SSimon J. Gerraty.if $<
41*6a7405f5SSimon J. Gerraty.endif
42*6a7405f5SSimon J. Gerraty
43*6a7405f5SSimon J. Gerraty
44*6a7405f5SSimon J. Gerraty.MAKEFLAGS: -d0
45