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 special va...
details: https://anonhg.NetBSD.org/src/rev/ade867502fd0
branches: trunk
changeset: 943474:ade867502fd0
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Sep 04 17:05:39 2020 +0000
description:
make(1): add test for the special variable MAKEFILE
diffstat:
distrib/sets/lists/tests/mi | 4 +-
usr.bin/make/unit-tests/Makefile | 3 +-
usr.bin/make/unit-tests/varname-makefile.exp | 1 +
usr.bin/make/unit-tests/varname-makefile.mk | 44 ++++++++++++++++++++++++++++
4 files changed, 50 insertions(+), 2 deletions(-)
diffs (88 lines):
diff -r 59965e060252 -r ade867502fd0 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Fri Sep 04 17:05:09 2020 +0000
+++ b/distrib/sets/lists/tests/mi Fri Sep 04 17:05:39 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.917 2020/09/04 11:43:50 rillig Exp $
+# $NetBSD: mi,v 1.918 2020/09/04 17:05:39 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -5092,6 +5092,8 @@
./usr/tests/usr.bin/make/unit-tests/varname-make.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/varname-make_print_var_on_error.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/varname-make_print_var_on_error.mk tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/varname-makefile.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/varname-makefile.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/varname-makeflags.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/varname-makeflags.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/varname-pwd.exp tests-usr.bin-tests compattestfile,atf
diff -r 59965e060252 -r ade867502fd0 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile Fri Sep 04 17:05:09 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile Fri Sep 04 17:05:39 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.131 2020/09/04 05:23:25 rillig Exp $
+# $NetBSD: Makefile,v 1.132 2020/09/04 17:05:39 rillig Exp $
#
# Unit tests for make(1)
#
@@ -310,6 +310,7 @@
TESTS+= varname-empty
TESTS+= varname-make
TESTS+= varname-make_print_var_on_error
+TESTS+= varname-makefile
TESTS+= varname-makeflags
TESTS+= varname-pwd
TESTS+= varname-vpath
diff -r 59965e060252 -r ade867502fd0 usr.bin/make/unit-tests/varname-makefile.exp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/varname-makefile.exp Fri Sep 04 17:05:39 2020 +0000
@@ -0,0 +1,1 @@
+exit status 0
diff -r 59965e060252 -r ade867502fd0 usr.bin/make/unit-tests/varname-makefile.mk
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/varname-makefile.mk Fri Sep 04 17:05:39 2020 +0000
@@ -0,0 +1,44 @@
+# $NetBSD: varname-makefile.mk,v 1.1 2020/09/04 17:05:39 rillig Exp $
+#
+# Tests for the special MAKEFILE variable, which contains the current
+# makefile from the -f command line option.
+#
+# When there are multiple -f options, the variable MAKEFILE is set
+# again for each of these makefiles, before the file is parsed.
+# Including a file via .include does not influence the MAKEFILE
+# variable though.
+
+.if ${MAKEFILE} != "varname-makefile.mk"
+. error
+.endif
+
+# This variable lives in the "Internal" namespace.
+# TODO: Why does it do that, and what consequences does this have?
+
+# Deleting the variable does not work since this variable does not live in
+# the "Global" namespace but in "Internal", which is kind of a child
+# namespace.
+#
+.undef MAKEFILE
+.if ${MAKEFILE} != "varname-makefile.mk"
+. error
+.endif
+
+# Overwriting this variable is possible since the "Internal" namespace
+# serves as a fallback for the "Global" namespace (see VarFind).
+#
+MAKEFILE= overwritten
+.if ${MAKEFILE} != "overwritten"
+. error
+.endif
+
+# When the overwritten value is deleted, the fallback value becomes
+# visible again.
+#
+.undef MAKEFILE
+.if ${MAKEFILE} != "varname-makefile.mk"
+. error
+.endif
+
+all:
+ @:;
Home |
Main Index |
Thread Index |
Old Index