freebsd-src/unit-tests/var-op-append.mk
Simon J. Gerraty ee914ef902 Import bmake-20210621
Lots more unit tests and code cleanup

Relevant changes from ChangeLog

	o job.c: Print -de error information when running multiple jobs
	o var.c: only report error for unmatched regex subexpression
	when linting (-dL) since we cannot tell when an unmatched
	subexpression is an expected result.
	reduce memory allocations in the modifiers ':D' and ':U'
	reduce memory allocation and strlen calls in modifier ':from=to'
	in the ':Q' modifier, only allocate memory if necessary
	improve performance for LazyBuf
	reduce debug logging and memory allocation for ${:U...}
	reduce verbosity of the -dv debug logging for standard cases
	fix double varname expansion in the variable modifier '::='
	o var.c: avoid evaluating many modifiers in parse only mode
	in strict mode (-dL) many variable references are parsed twice,
	the first time just to report parse errors early, so we want to
	avoid side effects and wasted effort to the extent possible.
2021-06-25 11:16:24 -07:00

47 lines
1.2 KiB
Makefile

# $NetBSD: var-op-append.mk,v 1.9 2021/04/04 10:13:09 rillig Exp $
#
# Tests for the += variable assignment operator, which appends to a variable,
# creating it if necessary.
# Appending to an undefined variable is possible.
# The variable is created, and no extra space is added before the value.
VAR+= one
.if ${VAR} != "one"
. error
.endif
# Appending to an existing variable adds a single space and the value.
VAR+= two
.if ${VAR} != "one two"
. error
.endif
# Appending an empty string nevertheless adds a single space.
VAR+= # empty
.if ${VAR} != "one two "
. error
.endif
# Variable names may contain '+', and this character is also part of the
# '+=' assignment operator. As far as possible, the '+' is interpreted as
# part of the assignment operator.
#
# See Parse_Var
C++= value
.if ${C+} != "value" || defined(C++)
. error
.endif
# Before var.c 1.793 from 2021-02-03, the variable name of a newly created
# variable was expanded two times in a row, which was unexpected but
# irrelevant in practice since variable names containing dollars lead to
# strange side effects in several other places as well.
.MAKEFLAGS: -dv
VAR.${:U\$\$\$\$\$\$\$\$}+= dollars
.MAKEFLAGS: -d0
.if ${VAR.${:U\$\$\$\$\$\$\$\$}} != "dollars"
. error
.endif
all: