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 .PARSEFILE
details: https://anonhg.NetBSD.org/src/rev/3a4a4d48eb87
branches: trunk
changeset: 954843:3a4a4d48eb87
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Sep 12 11:55:28 2020 +0000
description:
make(1): add test for .PARSEFILE
diffstat:
usr.bin/make/unit-tests/varname-dot-parsedir.exp | 7 ++-
usr.bin/make/unit-tests/varname-dot-parsedir.mk | 13 +++++++-
usr.bin/make/unit-tests/varname-dot-parsefile.exp | 4 ++
usr.bin/make/unit-tests/varname-dot-parsefile.mk | 35 ++++++++++++++++++++--
4 files changed, 50 insertions(+), 9 deletions(-)
diffs (97 lines):
diff -r 02a0edd1cbdf -r 3a4a4d48eb87 usr.bin/make/unit-tests/varname-dot-parsedir.exp
--- a/usr.bin/make/unit-tests/varname-dot-parsedir.exp Sat Sep 12 11:45:47 2020 +0000
+++ b/usr.bin/make/unit-tests/varname-dot-parsedir.exp Sat Sep 12 11:55:28 2020 +0000
@@ -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
diff -r 02a0edd1cbdf -r 3a4a4d48eb87 usr.bin/make/unit-tests/varname-dot-parsedir.mk
--- a/usr.bin/make/unit-tests/varname-dot-parsedir.mk Sat Sep 12 11:45:47 2020 +0000
+++ b/usr.bin/make/unit-tests/varname-dot-parsedir.mk Sat Sep 12 11:55:28 2020 +0000
@@ -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}.
diff -r 02a0edd1cbdf -r 3a4a4d48eb87 usr.bin/make/unit-tests/varname-dot-parsefile.exp
--- a/usr.bin/make/unit-tests/varname-dot-parsefile.exp Sat Sep 12 11:45:47 2020 +0000
+++ b/usr.bin/make/unit-tests/varname-dot-parsefile.exp Sat Sep 12 11:55:28 2020 +0000
@@ -1,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
diff -r 02a0edd1cbdf -r 3a4a4d48eb87 usr.bin/make/unit-tests/varname-dot-parsefile.mk
--- a/usr.bin/make/unit-tests/varname-dot-parsefile.mk Sat Sep 12 11:45:47 2020 +0000
+++ b/usr.bin/make/unit-tests/varname-dot-parsefile.mk Sat Sep 12 11:55:28 2020 +0000
@@ -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.
+
+.if ${.PARSEFILE} != "varname-dot-parsefile.mk"
+. error
+.endif
-# TODO: Implementation
+# 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}.
Home |
Main Index |
Thread Index |
Old Index