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 deferred varia...
details: https://anonhg.NetBSD.org/src/rev/eb5aae180a21
branches: trunk
changeset: 937626:eb5aae180a21
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Aug 22 16:51:25 2020 +0000
description:
make(1): add test for deferred variable expansion in dependencies
diffstat:
distrib/sets/lists/tests/mi | 6 +++++-
usr.bin/make/unit-tests/Makefile | 3 ++-
usr.bin/make/unit-tests/dep-var.exp | 2 ++
usr.bin/make/unit-tests/dep-var.mk | 33 +++++++++++++++++++++++++++++++++
4 files changed, 42 insertions(+), 2 deletions(-)
diffs (80 lines):
diff -r 2c9ab1438f90 -r eb5aae180a21 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Sat Aug 22 16:00:52 2020 +0000
+++ b/distrib/sets/lists/tests/mi Sat Aug 22 16:51:25 2020 +0000
@@ -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
diff -r 2c9ab1438f90 -r eb5aae180a21 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile Sat Aug 22 16:00:52 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile Sat Aug 22 16:51:25 2020 +0000
@@ -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-double-colon
TESTS+= dep-exclam
TESTS+= dep-none
+TESTS+= dep-var
TESTS+= dep-wildcards
TESTS+= depsrc
TESTS+= depsrc-exec
diff -r 2c9ab1438f90 -r eb5aae180a21 usr.bin/make/unit-tests/dep-var.exp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/dep-var.exp Sat Aug 22 16:51:25 2020 +0000
@@ -0,0 +1,2 @@
+def2
+exit status 0
diff -r 2c9ab1438f90 -r eb5aae180a21 usr.bin/make/unit-tests/dep-var.mk
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/dep-var.mk Sat Aug 22 16:51:25 2020 +0000
@@ -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}
Home |
Main Index |
Thread Index |
Old Index