Module Name: src
Committed By: rillig
Date: Sat Sep 12 11:55:28 UTC 2020
Modified Files:
src/usr.bin/make/unit-tests: varname-dot-parsedir.exp
varname-dot-parsedir.mk varname-dot-parsefile.exp
varname-dot-parsefile.mk
Log Message:
make(1): add test for .PARSEFILE
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varname-dot-parsedir.exp \
src/usr.bin/make/unit-tests/varname-dot-parsefile.mk
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varname-dot-parsedir.mk
cvs rdiff -u -r1.1 -r1.2 \
src/usr.bin/make/unit-tests/varname-dot-parsefile.exp
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.2 src/usr.bin/make/unit-tests/varname-dot-parsedir.exp:1.3
--- src/usr.bin/make/unit-tests/varname-dot-parsedir.exp:1.2 Sat Sep 12 11:45:47 2020
+++ src/usr.bin/make/unit-tests/varname-dot-parsedir.exp Sat Sep 12 11:55:28 2020
@@ -1,4 +1,5 @@
-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.
+make: "varname-dot-parsedir.mk" line 28: At this point, .PARSEDIR is undefined.
+make: "/fake-absolute-path/varname-dot-parsedir.mk" line 33: The location can be faked.
+make: "varname-dot-parsedir.mk" line 37: The location is no longer fake.
+At run time, .PARSEDIR is undefined.
exit status 0
Index: src/usr.bin/make/unit-tests/varname-dot-parsefile.mk
diff -u src/usr.bin/make/unit-tests/varname-dot-parsefile.mk:1.2 src/usr.bin/make/unit-tests/varname-dot-parsefile.mk:1.3
--- src/usr.bin/make/unit-tests/varname-dot-parsefile.mk:1.2 Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/varname-dot-parsefile.mk Sat Sep 12 11:55:28 2020
@@ -1,8 +1,35 @@
-# $NetBSD: varname-dot-parsefile.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: varname-dot-parsefile.mk,v 1.3 2020/09/12 11:55:28 rillig Exp $
#
-# Tests for the special .PARSEFILE variable.
+# Tests for the special .PARSEFILE variable, which contains the basename part
+# of the file that is currently parsed.
-# TODO: Implementation
+.if ${.PARSEFILE} != "varname-dot-parsefile.mk"
+. error
+.endif
+
+# During parsing, it is possible to undefine .PARSEFILE.
+# Not that anyone would ever want to do this, but there's code in parse.c,
+# function PrintLocation, that explicitly handles this situation.
+.if !defined(.PARSEFILE)
+. error
+.endif
+.undef .PARSEFILE
+.if defined(.PARSEFILE)
+. error
+.endif
+
+# The variable .PARSEFILE is indirectly used by the .info directive,
+# via PrintLocation.
+.info At this point, .PARSEFILE is undefined.
+
+# There is absolutely no point in faking the location of the file that is
+# being parsed. Technically, it's possible though.
+.PARSEFILE = fake-parsefile
+.info The location can be faked.
+
+# After including another file, .PARSEFILE is reset.
+.include "/dev/null"
+.info The location is no longer fake.
all:
- @:;
+ @echo At run time, .PARSEFILE is ${.PARSEFILE:Uundefined}.
Index: src/usr.bin/make/unit-tests/varname-dot-parsedir.mk
diff -u src/usr.bin/make/unit-tests/varname-dot-parsedir.mk:1.3 src/usr.bin/make/unit-tests/varname-dot-parsedir.mk:1.4
--- src/usr.bin/make/unit-tests/varname-dot-parsedir.mk:1.3 Sat Sep 12 11:45:47 2020
+++ src/usr.bin/make/unit-tests/varname-dot-parsedir.mk Sat Sep 12 11:55:28 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varname-dot-parsedir.mk,v 1.3 2020/09/12 11:45:47 rillig Exp $
+# $NetBSD: varname-dot-parsedir.mk,v 1.4 2020/09/12 11:55:28 rillig Exp $
#
# Tests for the special .PARSEDIR variable, which contains the directory part
# of the file that is currently parsed.
@@ -12,8 +12,17 @@
# 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.
+.if !defined(.PARSEDIR)
+. error
+.endif
.undef .PARSEDIR
+.if defined(.PARSEDIR)
+. error
+.endif
+# The variable .PARSEDIR is indirectly used by the .info directive,
+# via PrintLocation.
+#
# 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.
@@ -28,4 +37,4 @@
.info The location is no longer fake.
all:
- @:;
+ @echo At run time, .PARSEDIR is ${.PARSEDIR:Uundefined}.
Index: src/usr.bin/make/unit-tests/varname-dot-parsefile.exp
diff -u src/usr.bin/make/unit-tests/varname-dot-parsefile.exp:1.1 src/usr.bin/make/unit-tests/varname-dot-parsefile.exp:1.2
--- src/usr.bin/make/unit-tests/varname-dot-parsefile.exp:1.1 Sun Aug 16 12:07:52 2020
+++ src/usr.bin/make/unit-tests/varname-dot-parsefile.exp Sat Sep 12 11:55:28 2020
@@ -1 +1,5 @@
+make: "varname-dot-parsefile.mk" line 23: At this point, .PARSEFILE is undefined.
+make: "fake-parsefile" line 28: The location can be faked.
+make: "varname-dot-parsefile.mk" line 32: The location is no longer fake.
+At run time, .PARSEFILE is undefined.
exit status 0