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 :P variabl...



details:   https://anonhg.NetBSD.org/src/rev/af3e75520df5
branches:  trunk
changeset: 1013226:af3e75520df5
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Aug 23 08:10:49 2020 +0000

description:
make(1): add test for the :P variable modifier

diffstat:

 usr.bin/make/unit-tests/varmod-path.exp |   3 ++
 usr.bin/make/unit-tests/varmod-path.mk  |  34 +++++++++++++++++++++++++++++---
 2 files changed, 33 insertions(+), 4 deletions(-)

diffs (51 lines):

diff -r 339aa14182b1 -r af3e75520df5 usr.bin/make/unit-tests/varmod-path.exp
--- a/usr.bin/make/unit-tests/varmod-path.exp   Sun Aug 23 06:54:01 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-path.exp   Sun Aug 23 08:10:49 2020 +0000
@@ -1,1 +1,4 @@
+varmod-path.subdir/varmod-path.phony
+varmod-path.subdir/varmod-path.real
+varmod-path.enoent
 exit status 0
diff -r 339aa14182b1 -r af3e75520df5 usr.bin/make/unit-tests/varmod-path.mk
--- a/usr.bin/make/unit-tests/varmod-path.mk    Sun Aug 23 06:54:01 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-path.mk    Sun Aug 23 08:10:49 2020 +0000
@@ -1,9 +1,35 @@
-# $NetBSD: varmod-path.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: varmod-path.mk,v 1.3 2020/08/23 08:10:49 rillig Exp $
 #
 # Tests for the :P variable modifier, which looks up the path for a given
 # target.
+#
+# The phony target does not have a corresponding path, therefore ... oops,
+# as of 2020-08-23 it is nevertheless resolved to a path.  This is probably
+# unintended.
+#
+# The real target is located in a subdirectory, and its full path is returned.
+# If it had been in the current directory, the difference between its path and
+# its name would not be visible.
+#
+# The enoent target does not exist, therefore the target name is returned.
 
-# TODO: Implementation
+.MAIN: all
 
-all:
-       @:;
+_!=    rm -rf varmod-path.subdir
+_!=    mkdir varmod-path.subdir
+_!=    > varmod-path.subdir/varmod-path.phony
+_!=    > varmod-path.subdir/varmod-path.real
+
+# To have an effect, this .PATH declaration must be after the directory is created.
+.PATH: varmod-path.subdir
+
+varmod-path.phony: .PHONY
+varmod-path.real:
+
+all: varmod-path.phony varmod-path.real
+       @echo ${varmod-path.phony:P}
+       @echo ${varmod-path.real:P}
+       @echo ${varmod-path.enoent:P}
+
+.END:
+       @rm -rf varmod-path.subdir



Home | Main Index | Thread Index | Old Index