Module Name: src
Committed By: rillig
Date: Tue Nov 10 00:19:19 UTC 2020
Modified Files:
src/usr.bin/make/unit-tests: Makefile varname-vpath.exp
varname-vpath.mk
Log Message:
make(1): add test for the obsolete variable VPATH
To generate a diff of this commit:
cvs rdiff -u -r1.195 -r1.196 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/varname-vpath.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varname-vpath.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/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.195 src/usr.bin/make/unit-tests/Makefile:1.196
--- src/usr.bin/make/unit-tests/Makefile:1.195 Mon Nov 9 20:50:56 2020
+++ src/usr.bin/make/unit-tests/Makefile Tue Nov 10 00:19:19 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.195 2020/11/09 20:50:56 rillig Exp $
+# $NetBSD: Makefile,v 1.196 2020/11/10 00:19:19 rillig Exp $
#
# Unit tests for make(1)
#
@@ -386,6 +386,7 @@ ENV.varmisc= FROM_ENV=env
ENV.varmisc+= FROM_ENV_BEFORE=env
ENV.varmisc+= FROM_ENV_AFTER=env
ENV.varmod-localtime+= TZ=Europe/Berlin
+ENV.varname-vpath+= VPATH=varname-vpath.dir:varname-vpath.dir2
# Override make flags for some of the tests; default is -k.
# If possible, write ".MAKEFLAGS: -dv" in the test .mk file instead of
Index: src/usr.bin/make/unit-tests/varname-vpath.exp
diff -u src/usr.bin/make/unit-tests/varname-vpath.exp:1.1 src/usr.bin/make/unit-tests/varname-vpath.exp:1.2
--- src/usr.bin/make/unit-tests/varname-vpath.exp:1.1 Sun Aug 16 12:07:52 2020
+++ src/usr.bin/make/unit-tests/varname-vpath.exp Tue Nov 10 00:19:19 2020
@@ -1 +1,12 @@
+CondParser_Eval: !defined(TEST_MAIN)
+CondParser_Eval: exists(file-in-subdirectory)
+exists(file-in-subdirectory) result is ""
+CondParser_Eval: exists(file2-in-subdirectory)
+exists(file2-in-subdirectory) result is ""
+CondParser_Eval: exists(file-in-subdirectory)
+exists(file-in-subdirectory) result is "varname-vpath.dir/file-in-subdirectory"
+: yes 1
+CondParser_Eval: exists(file2-in-subdirectory)
+exists(file2-in-subdirectory) result is "varname-vpath.dir2/file2-in-subdirectory"
+: yes 2
exit status 0
Index: src/usr.bin/make/unit-tests/varname-vpath.mk
diff -u src/usr.bin/make/unit-tests/varname-vpath.mk:1.2 src/usr.bin/make/unit-tests/varname-vpath.mk:1.3
--- src/usr.bin/make/unit-tests/varname-vpath.mk:1.2 Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/varname-vpath.mk Tue Nov 10 00:19:19 2020
@@ -1,8 +1,42 @@
-# $NetBSD: varname-vpath.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: varname-vpath.mk,v 1.3 2020/11/10 00:19:19 rillig Exp $
#
-# Tests for the special VPATH variable.
+# Tests for the special VPATH variable, which is an obsolete way of
+# specifying a colon-separated search path. This search path is not active
+# when the makefiles are read, but only later when the shell commands are run.
+#
+# Instead of the VPATH, better use the -I option or the special target .PATH.
+
+.if !defined(TEST_MAIN)
+
+all: .SILENT
+ rm -rf varname-vpath.dir
+ mkdir varname-vpath.dir
+ touch varname-vpath.dir/file-in-subdirectory
+ rm -rf varname-vpath.dir2
+ mkdir varname-vpath.dir2
+ touch varname-vpath.dir2/file2-in-subdirectory
+
+ TEST_MAIN=yes VPATH=varname-vpath.dir:varname-vpath.dir2 \
+ ${MAKE} -f ${MAKEFILE} -dc
-# TODO: Implementation
+ rm -r varname-vpath.dir
+ rm -r varname-vpath.dir2
+
+.else
+
+# The VPATH variable does not take effect at parse time.
+# It is evaluated only once, between reading the makefiles and making the
+# targets. Therefore it could also be an ordinary variable, it doesn't need
+# to be an environment variable or a command line variable.
+. if exists(file-in-subdirectory)
+. error
+. endif
+. if exists(file2-in-subdirectory)
+. error
+. endif
all:
- @:;
+ : ${exists(file-in-subdirectory):L:?yes 1:no 1}
+ : ${exists(file2-in-subdirectory):L:?yes 2:no 2}
+
+.endif