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 .PARSEDIR



details:   https://anonhg.NetBSD.org/src/rev/6e2cb164b7af
branches:  trunk
changeset: 976066:6e2cb164b7af
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Sep 12 11:45:47 2020 +0000

description:
make(1): add test for .PARSEDIR

diffstat:

 usr.bin/make/unit-tests/varname-dot-parsedir.exp |   3 ++
 usr.bin/make/unit-tests/varname-dot-parsedir.mk  |  29 +++++++++++++++++++++--
 2 files changed, 29 insertions(+), 3 deletions(-)

diffs (46 lines):

diff -r 06cc64805f53 -r 6e2cb164b7af usr.bin/make/unit-tests/varname-dot-parsedir.exp
--- a/usr.bin/make/unit-tests/varname-dot-parsedir.exp  Sat Sep 12 11:21:15 2020 +0000
+++ b/usr.bin/make/unit-tests/varname-dot-parsedir.exp  Sat Sep 12 11:45:47 2020 +0000
@@ -1,1 +1,4 @@
+make: "varname-dot-parsedir.mk" line 19: At this point, .PARSEDIR is undefined.
+make: "/fake-absolute-path/varname-dot-parsedir.mk" line 24: The location can be faked.
+make: "varname-dot-parsedir.mk" line 28: The location is no longer fake.
 exit status 0
diff -r 06cc64805f53 -r 6e2cb164b7af usr.bin/make/unit-tests/varname-dot-parsedir.mk
--- a/usr.bin/make/unit-tests/varname-dot-parsedir.mk   Sat Sep 12 11:21:15 2020 +0000
+++ b/usr.bin/make/unit-tests/varname-dot-parsedir.mk   Sat Sep 12 11:45:47 2020 +0000
@@ -1,8 +1,31 @@
-# $NetBSD: varname-dot-parsedir.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: varname-dot-parsedir.mk,v 1.3 2020/09/12 11:45:47 rillig Exp $
 #
-# Tests for the special .PARSEDIR variable.
+# Tests for the special .PARSEDIR variable, which contains the directory part
+# of the file that is currently parsed.
+
+# The .PARSEDIR may be absolute or relative, therefore there is not much that
+# can be tested here.
+.if !${.PARSEDIR:tA:M*/unit-tests}
+.  error
+.endif
 
-# TODO: Implementation
+# During parsing, it is possible to undefine .PARSEDIR.
+# Not that anyone would ever want to do this, but there's code in parse.c,
+# function PrintLocation, that explicitly handles this situation.
+.undef .PARSEDIR
+
+# The .rawout file contains the full path to the current directory.
+# In the .out file, it is filtered out.
+.info At this point, .PARSEDIR is undefined.
+
+# There is absolutely no point in faking the location of the file that is
+# being parsed.  Technically, it's possible though.
+.PARSEDIR = /fake-absolute-path
+.info The location can be faked.
+
+# After including another file, .PARSEDIR is reset.
+.include "/dev/null"
+.info The location is no longer fake.
 
 all:
        @:;



Home | Main Index | Thread Index | Old Index