Module Name: src Committed By: rillig Date: Sat Aug 22 16:51:26 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: dep-var.exp dep-var.mk Log Message: make(1): add test for deferred variable expansion in dependencies To generate a diff of this commit: cvs rdiff -u -r1.898 -r1.899 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.108 -r1.109 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/dep-var.exp \ src/usr.bin/make/unit-tests/dep-var.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.898 src/distrib/sets/lists/tests/mi:1.899 --- src/distrib/sets/lists/tests/mi:1.898 Sat Aug 22 11:27:02 2020 +++ src/distrib/sets/lists/tests/mi Sat Aug 22 16:51:25 2020 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.898 2020/08/22 11:27:02 rillig Exp $ +# $NetBSD: mi,v 1.899 2020/08/22 16:51:25 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -4593,6 +4593,10 @@ ./usr/tests/usr.bin/make/unit-tests/dep-double-colon.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/dep-exclam.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/dep-exclam.mk tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/dep-none.exp tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/dep-none.mk tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/dep-var.exp tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/dep-var.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/dep-wildcards.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/dep-wildcards.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/dep.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.108 src/usr.bin/make/unit-tests/Makefile:1.109 --- src/usr.bin/make/unit-tests/Makefile:1.108 Sat Aug 22 15:25:50 2020 +++ src/usr.bin/make/unit-tests/Makefile Sat Aug 22 16:51:26 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.108 2020/08/22 15:25:50 sjg Exp $ +# $NetBSD: Makefile,v 1.109 2020/08/22 16:51:26 rillig Exp $ # # Unit tests for make(1) # @@ -66,6 +66,7 @@ TESTS+= dep-colon TESTS+= dep-double-colon TESTS+= dep-exclam TESTS+= dep-none +TESTS+= dep-var TESTS+= dep-wildcards TESTS+= depsrc TESTS+= depsrc-exec Added files: Index: src/usr.bin/make/unit-tests/dep-var.exp diff -u /dev/null src/usr.bin/make/unit-tests/dep-var.exp:1.1 --- /dev/null Sat Aug 22 16:51:26 2020 +++ src/usr.bin/make/unit-tests/dep-var.exp Sat Aug 22 16:51:26 2020 @@ -0,0 +1,2 @@ +def2 +exit status 0 Index: src/usr.bin/make/unit-tests/dep-var.mk diff -u /dev/null src/usr.bin/make/unit-tests/dep-var.mk:1.1 --- /dev/null Sat Aug 22 16:51:26 2020 +++ src/usr.bin/make/unit-tests/dep-var.mk Sat Aug 22 16:51:26 2020 @@ -0,0 +1,33 @@ +# $NetBSD: dep-var.mk,v 1.1 2020/08/22 16:51:26 rillig Exp $ +# +# Tests for variable references in dependency declarations. +# +# Uh oh, this feels so strange that probably nobody uses it. But it seems to +# be the only way to reach the lower half of SuffExpandChildren. + +# XXX: The -dv log says: +# Var_Parse: ${UNDEF1} with VARE_UNDEFERR|VARE_WANTRES +# but no error message is generated for this line. +# The variable expression ${UNDEF1} simply expands to an empty string. +all: ${UNDEF1} + +# Using a double dollar in order to circumvent immediate variable expansion +# feels like unintended behavior. At least the manual page says nothing at +# all about defined or undefined variables in dependency lines. +# +# At the point where the expression ${DEF2} is expanded, the variable DEF2 +# is defined, so everything's fine. +all: $${DEF2} + +# This variable is not defined at all. +# XXX: The -dv log says: +# Var_Parse: ${UNDEF3} with VARE_UNDEFERR|VARE_WANTRES +# but no error message is generated for this line, just like for UNDEF1. +# The variable expression ${UNDEF3} simply expands to an empty string. +all: $${UNDEF3} + +UNDEF1= undef1 +DEF2= def2 + +undef1 def2: + @echo ${.TARGET}