Module Name: src Committed By: rillig Date: Sun Nov 8 16:44:47 UTC 2020
Modified Files: src/distrib/sets/lists/tests: mi src/usr.bin/make/unit-tests: Makefile Added Files: src/usr.bin/make/unit-tests: varparse-errors.exp varparse-errors.mk Log Message: make(1): add test for expanding variable expressions To generate a diff of this commit: cvs rdiff -u -r1.963 -r1.964 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.190 -r1.191 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/varparse-errors.exp \ src/usr.bin/make/unit-tests/varparse-errors.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.963 src/distrib/sets/lists/tests/mi:1.964 --- src/distrib/sets/lists/tests/mi:1.963 Sun Nov 8 02:33:18 2020 +++ src/distrib/sets/lists/tests/mi Sun Nov 8 16:44:47 2020 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.963 2020/11/08 02:33:18 rillig Exp $ +# $NetBSD: mi,v 1.964 2020/11/08 16:44:47 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -5499,6 +5499,8 @@ ./usr/tests/usr.bin/make/unit-tests/varname.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/varparse-dynamic.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/varparse-dynamic.mk tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/varparse-errors.exp tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/varparse-errors.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/varparse-mod.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/varparse-mod.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/varparse-undef-partial.exp tests-usr.bin-tests compattestfile,atf Index: src/usr.bin/make/unit-tests/Makefile diff -u src/usr.bin/make/unit-tests/Makefile:1.190 src/usr.bin/make/unit-tests/Makefile:1.191 --- src/usr.bin/make/unit-tests/Makefile:1.190 Sat Nov 7 23:25:06 2020 +++ src/usr.bin/make/unit-tests/Makefile Sun Nov 8 16:44:47 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.190 2020/11/07 23:25:06 rillig Exp $ +# $NetBSD: Makefile,v 1.191 2020/11/08 16:44:47 rillig Exp $ # # Unit tests for make(1) # @@ -371,6 +371,7 @@ TESTS+= varname-makeflags TESTS+= varname-pwd TESTS+= varname-vpath TESTS+= varparse-dynamic +TESTS+= varparse-errors TESTS+= varparse-mod TESTS+= varparse-undef-partial TESTS+= varquote Added files: Index: src/usr.bin/make/unit-tests/varparse-errors.exp diff -u /dev/null src/usr.bin/make/unit-tests/varparse-errors.exp:1.1 --- /dev/null Sun Nov 8 16:44:47 2020 +++ src/usr.bin/make/unit-tests/varparse-errors.exp Sun Nov 8 16:44:47 2020 @@ -0,0 +1 @@ +exit status 0 Index: src/usr.bin/make/unit-tests/varparse-errors.mk diff -u /dev/null src/usr.bin/make/unit-tests/varparse-errors.mk:1.1 --- /dev/null Sun Nov 8 16:44:47 2020 +++ src/usr.bin/make/unit-tests/varparse-errors.mk Sun Nov 8 16:44:47 2020 @@ -0,0 +1,35 @@ +# $NetBSD: varparse-errors.mk,v 1.1 2020/11/08 16:44:47 rillig Exp $ + +# Tests for parsing and evaluating all kinds of variable expressions. +# +# This is the basis for redesigning the error handling in Var_Parse and +# Var_Subst, collecting typical and not so typical use cases. +# +# See also: +# VarParseResult +# Var_Parse +# Var_Subst + +PLAIN= plain value + +LITERAL_DOLLAR= To get a dollar, double $$ it. + +INDIRECT= An ${:Uindirect} value. + +REF_UNDEF= A reference to an ${UNDEF}undefined variable. + +ERR_UNCLOSED= An ${UNCLOSED variable expression. + +ERR_BAD_MOD= An ${:Uindirect:Z} expression with an unknown modifier. + +ERR_EVAL= An evaluation error ${:Uvalue:C,.,\3,}. + +# In a conditional, a variable expression that is not enclosed in quotes is +# expanded using the flags VARE_UNDEFERR and VARE_WANTRES. +# The variable itself must be defined. +# It may refer to undefined variables though. +.if ${REF_UNDEF} != "A reference to an undefined variable." +. error +.endif + +all: