Module Name:    src
Committed By:   rillig
Date:           Fri Sep  4 17:05:39 UTC 2020

Modified Files:
        src/distrib/sets/lists/tests: mi
        src/usr.bin/make/unit-tests: Makefile
Added Files:
        src/usr.bin/make/unit-tests: varname-makefile.exp varname-makefile.mk

Log Message:
make(1): add test for the special variable MAKEFILE


To generate a diff of this commit:
cvs rdiff -u -r1.917 -r1.918 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.131 -r1.132 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/varname-makefile.exp \
    src/usr.bin/make/unit-tests/varname-makefile.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.917 src/distrib/sets/lists/tests/mi:1.918
--- src/distrib/sets/lists/tests/mi:1.917	Fri Sep  4 11:43:50 2020
+++ src/distrib/sets/lists/tests/mi	Fri Sep  4 17:05:39 2020
@@ -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

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.131 src/usr.bin/make/unit-tests/Makefile:1.132
--- src/usr.bin/make/unit-tests/Makefile:1.131	Fri Sep  4 05:23:25 2020
+++ src/usr.bin/make/unit-tests/Makefile	Fri Sep  4 17:05:39 2020
@@ -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-dot-targets
 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

Added files:

Index: src/usr.bin/make/unit-tests/varname-makefile.exp
diff -u /dev/null src/usr.bin/make/unit-tests/varname-makefile.exp:1.1
--- /dev/null	Fri Sep  4 17:05:39 2020
+++ src/usr.bin/make/unit-tests/varname-makefile.exp	Fri Sep  4 17:05:39 2020
@@ -0,0 +1 @@
+exit status 0
Index: src/usr.bin/make/unit-tests/varname-makefile.mk
diff -u /dev/null src/usr.bin/make/unit-tests/varname-makefile.mk:1.1
--- /dev/null	Fri Sep  4 17:05:39 2020
+++ src/usr.bin/make/unit-tests/varname-makefile.mk	Fri Sep  4 17:05:39 2020
@@ -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:
+	@:;

Reply via email to