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 the obsolete v...
details: https://anonhg.NetBSD.org/src/rev/593d63d05937
branches: trunk
changeset: 956908:593d63d05937
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Nov 10 00:19:19 2020 +0000
description:
make(1): add test for the obsolete variable VPATH
diffstat:
usr.bin/make/unit-tests/Makefile | 3 +-
usr.bin/make/unit-tests/varname-vpath.exp | 11 ++++++++
usr.bin/make/unit-tests/varname-vpath.mk | 42 ++++++++++++++++++++++++++++--
3 files changed, 51 insertions(+), 5 deletions(-)
diffs (83 lines):
diff -r 97c463bc4fe7 -r 593d63d05937 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile Tue Nov 10 00:02:11 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile Tue Nov 10 00:19:19 2020 +0000
@@ -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_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
diff -r 97c463bc4fe7 -r 593d63d05937 usr.bin/make/unit-tests/varname-vpath.exp
--- a/usr.bin/make/unit-tests/varname-vpath.exp Tue Nov 10 00:02:11 2020 +0000
+++ b/usr.bin/make/unit-tests/varname-vpath.exp Tue Nov 10 00:19:19 2020 +0000
@@ -1,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
diff -r 97c463bc4fe7 -r 593d63d05937 usr.bin/make/unit-tests/varname-vpath.mk
--- a/usr.bin/make/unit-tests/varname-vpath.mk Tue Nov 10 00:02:11 2020 +0000
+++ b/usr.bin/make/unit-tests/varname-vpath.mk Tue Nov 10 00:19:19 2020 +0000
@@ -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, 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.
#
-# Tests for the special VPATH variable.
+# 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
Home |
Main Index |
Thread Index |
Old Index