Module Name: src Committed By: rillig Date: Sat Aug 22 20:23:14 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: varname-empty.exp varname-empty.mk Log Message: make(1): add test for assigning to the variable named "" This has been possible at least since 2013, probably much longer. To generate a diff of this commit: cvs rdiff -u -r1.899 -r1.900 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.109 -r1.110 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/varname-empty.exp \ src/usr.bin/make/unit-tests/varname-empty.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.899 src/distrib/sets/lists/tests/mi:1.900 --- src/distrib/sets/lists/tests/mi:1.899 Sat Aug 22 16:51:25 2020 +++ src/distrib/sets/lists/tests/mi Sat Aug 22 20:23:14 2020 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.899 2020/08/22 16:51:25 rillig Exp $ +# $NetBSD: mi,v 1.900 2020/08/22 20:23:14 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -5051,6 +5051,8 @@ ./usr/tests/usr.bin/make/unit-tests/varname-dot-path.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/varname-dot-targets.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/varname-dot-targets.mk tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/varname-empty.exp tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/varname-empty.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/varname-make.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/varname-make.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/varname-make_print_var_on_error.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.109 src/usr.bin/make/unit-tests/Makefile:1.110 --- src/usr.bin/make/unit-tests/Makefile:1.109 Sat Aug 22 16:51:26 2020 +++ src/usr.bin/make/unit-tests/Makefile Sat Aug 22 20:23:14 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.109 2020/08/22 16:51:26 rillig Exp $ +# $NetBSD: Makefile,v 1.110 2020/08/22 20:23:14 rillig Exp $ # # Unit tests for make(1) # @@ -293,6 +293,7 @@ TESTS+= varname-dot-parsedir TESTS+= varname-dot-parsefile TESTS+= varname-dot-path TESTS+= varname-dot-targets +TESTS+= varname-empty TESTS+= varname-make TESTS+= varname-make_print_var_on_error TESTS+= varname-makeflags Added files: Index: src/usr.bin/make/unit-tests/varname-empty.exp diff -u /dev/null src/usr.bin/make/unit-tests/varname-empty.exp:1.1 --- /dev/null Sat Aug 22 20:23:14 2020 +++ src/usr.bin/make/unit-tests/varname-empty.exp Sat Aug 22 20:23:14 2020 @@ -0,0 +1,3 @@ +value +value value value +exit status 0 Index: src/usr.bin/make/unit-tests/varname-empty.mk diff -u /dev/null src/usr.bin/make/unit-tests/varname-empty.mk:1.1 --- /dev/null Sat Aug 22 20:23:14 2020 +++ src/usr.bin/make/unit-tests/varname-empty.mk Sat Aug 22 20:23:14 2020 @@ -0,0 +1,21 @@ +# $NetBSD: varname-empty.mk,v 1.1 2020/08/22 20:23:14 rillig Exp $ +# +# Tests for the special variable with the empty name. +# +# The variable "" is not supposed to be assigned any value. +# This is because it is heavily used in the .for loop expansion, +# as well as to generate arbitrary strings, as in ${:Ufallback}. + +# Oops. +!= echo 'value' + +# The .for loop expands the expression ${i} to ${:U1}, ${:U2} and so on. +# This only works if the variable with the empty name is guaranteed to +# be undefined. +.for i in 1 2 3 +NUMBERS+= ${i} +.endfor + +all: + @echo ${:Ufallback} + @echo ${NUMBERS}