Module Name:    src
Committed By:   rillig
Date:           Tue Dec 22 19:38:44 UTC 2020

Modified Files:
        src/usr.bin/make/unit-tests: depsrc.exp depsrc.mk

Log Message:
make(1): add test for undefined variable in dependency declaration


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/depsrc.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/depsrc.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/depsrc.exp
diff -u src/usr.bin/make/unit-tests/depsrc.exp:1.1 src/usr.bin/make/unit-tests/depsrc.exp:1.2
--- src/usr.bin/make/unit-tests/depsrc.exp:1.1	Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/depsrc.exp	Tue Dec 22 19:38:44 2020
@@ -1 +1,4 @@
+: 'Undefined variables are expanded directly in the dependency'
+: 'declaration.  They are not preserved and maybe expanded later.'
+: 'This is in contrast to local variables such as ${.TARGET}.'
 exit status 0

Index: src/usr.bin/make/unit-tests/depsrc.mk
diff -u src/usr.bin/make/unit-tests/depsrc.mk:1.3 src/usr.bin/make/unit-tests/depsrc.mk:1.4
--- src/usr.bin/make/unit-tests/depsrc.mk:1.3	Sun Nov 15 20:20:58 2020
+++ src/usr.bin/make/unit-tests/depsrc.mk	Tue Dec 22 19:38:44 2020
@@ -1,4 +1,4 @@
-# $NetBSD: depsrc.mk,v 1.3 2020/11/15 20:20:58 rillig Exp $
+# $NetBSD: depsrc.mk,v 1.4 2020/12/22 19:38:44 rillig Exp $
 #
 # Tests for special sources (those starting with a dot, followed by
 # uppercase letters) in dependency declarations, such as .PHONY.
@@ -7,5 +7,20 @@
 
 # TODO: Test 'target: ${:U.SILENT}'
 
+# Demonstrate when exactly undefined variables are expanded in a dependency
+# declaration.
+target: .PHONY source-${DEFINED_LATER}
+#
+DEFINED_LATER=	later
+#
+source-: .PHONY
+	: 'Undefined variables are expanded directly in the dependency'
+	: 'declaration.  They are not preserved and maybe expanded later.'
+	: 'This is in contrast to local variables such as $${.TARGET}.'
+source-later: .PHONY
+	: 'Undefined variables are tried to be expanded in a dependency'
+	: 'declaration.  If that fails because the variable is undefined,'
+	: 'the expression is preserved and tried to be expanded later.'
+
 all:
 	@:;

Reply via email to