Module Name: src
Committed By: rillig
Date: Sat Sep 12 11:45:48 UTC 2020
Modified Files:
src/usr.bin/make/unit-tests: varname-dot-parsedir.exp
varname-dot-parsedir.mk
Log Message:
make(1): add test for .PARSEDIR
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/varname-dot-parsedir.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varname-dot-parsedir.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/varname-dot-parsedir.exp
diff -u src/usr.bin/make/unit-tests/varname-dot-parsedir.exp:1.1 src/usr.bin/make/unit-tests/varname-dot-parsedir.exp:1.2
--- src/usr.bin/make/unit-tests/varname-dot-parsedir.exp:1.1 Sun Aug 16 12:07:52 2020
+++ src/usr.bin/make/unit-tests/varname-dot-parsedir.exp Sat Sep 12 11:45:47 2020
@@ -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
Index: src/usr.bin/make/unit-tests/varname-dot-parsedir.mk
diff -u src/usr.bin/make/unit-tests/varname-dot-parsedir.mk:1.2 src/usr.bin/make/unit-tests/varname-dot-parsedir.mk:1.3
--- src/usr.bin/make/unit-tests/varname-dot-parsedir.mk:1.2 Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/varname-dot-parsedir.mk Sat Sep 12 11:45:47 2020
@@ -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.
-# TODO: Implementation
+# 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
+
+# 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:
@:;