Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make/unit-tests make(1): add test for assigning to t...



details:   https://anonhg.NetBSD.org/src/rev/993bf2878bb8
branches:  trunk
changeset: 937637:993bf2878bb8
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Aug 22 20:23:14 2020 +0000

description:
make(1): add test for assigning to the variable named ""

This has been possible at least since 2013, probably much longer.

diffstat:

 distrib/sets/lists/tests/mi               |   4 +++-
 usr.bin/make/unit-tests/Makefile          |   3 ++-
 usr.bin/make/unit-tests/varname-empty.exp |   3 +++
 usr.bin/make/unit-tests/varname-empty.mk  |  21 +++++++++++++++++++++
 4 files changed, 29 insertions(+), 2 deletions(-)

diffs (67 lines):

diff -r dfb2841d6ba6 -r 993bf2878bb8 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sat Aug 22 20:03:41 2020 +0000
+++ b/distrib/sets/lists/tests/mi       Sat Aug 22 20:23:14 2020 +0000
@@ -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
diff -r dfb2841d6ba6 -r 993bf2878bb8 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Sat Aug 22 20:03:41 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Sat Aug 22 20:23:14 2020 +0000
@@ -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-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
diff -r dfb2841d6ba6 -r 993bf2878bb8 usr.bin/make/unit-tests/varname-empty.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/varname-empty.exp Sat Aug 22 20:23:14 2020 +0000
@@ -0,0 +1,3 @@
+value
+value value value
+exit status 0
diff -r dfb2841d6ba6 -r 993bf2878bb8 usr.bin/make/unit-tests/varname-empty.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/varname-empty.mk  Sat Aug 22 20:23:14 2020 +0000
@@ -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}



Home | Main Index | Thread Index | Old Index