Module Name:    src
Committed By:   rillig
Date:           Tue Dec  1 20:37:30 UTC 2020

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

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


To generate a diff of this commit:
cvs rdiff -u -r1.980 -r1.981 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.232 -r1.233 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/varname-dot-makeflags.exp \
    src/usr.bin/make/unit-tests/varname-dot-makeflags.mk
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varname-makeflags.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.980 src/distrib/sets/lists/tests/mi:1.981
--- src/distrib/sets/lists/tests/mi:1.980	Tue Dec  1 17:50:04 2020
+++ src/distrib/sets/lists/tests/mi	Tue Dec  1 20:37:30 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.980 2020/12/01 17:50:04 rillig Exp $
+# $NetBSD: mi,v 1.981 2020/12/01 20:37:30 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -5501,6 +5501,8 @@
 ./usr/tests/usr.bin/make/unit-tests/varname-dot-make-ppid.mk			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varname-dot-make-save_dollars.exp		tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varname-dot-make-save_dollars.mk		tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/varname-dot-makeflags.exp			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/varname-dot-makeflags.mk			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varname-dot-makeoverrides.exp		tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varname-dot-makeoverrides.mk		tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varname-dot-newline.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.232 src/usr.bin/make/unit-tests/Makefile:1.233
--- src/usr.bin/make/unit-tests/Makefile:1.232	Tue Dec  1 17:50:04 2020
+++ src/usr.bin/make/unit-tests/Makefile	Tue Dec  1 20:37:30 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.232 2020/12/01 17:50:04 rillig Exp $
+# $NetBSD: Makefile,v 1.233 2020/12/01 20:37:30 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -375,6 +375,7 @@ TESTS+=		varname-dot-make-path_filemon
 TESTS+=		varname-dot-make-pid
 TESTS+=		varname-dot-make-ppid
 TESTS+=		varname-dot-make-save_dollars
+TESTS+=		varname-dot-makeflags
 TESTS+=		varname-dot-makeoverrides
 TESTS+=		varname-dot-newline
 TESTS+=		varname-dot-objdir

Index: src/usr.bin/make/unit-tests/varname-makeflags.mk
diff -u src/usr.bin/make/unit-tests/varname-makeflags.mk:1.2 src/usr.bin/make/unit-tests/varname-makeflags.mk:1.3
--- src/usr.bin/make/unit-tests/varname-makeflags.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/varname-makeflags.mk	Tue Dec  1 20:37:30 2020
@@ -1,8 +1,26 @@
-# $NetBSD: varname-makeflags.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: varname-makeflags.mk,v 1.3 2020/12/01 20:37:30 rillig Exp $
 #
-# Tests for the special MAKEFLAGS variable.
+# Tests for the special MAKEFLAGS variable, which is basically just a normal
+# environment variable.  It is closely related to .MAKEFLAGS but captures the
+# state of .MAKEFLAGS at the very beginning of make, before any makefiles are
+# read.
 
 # TODO: Implementation
 
+.MAKEFLAGS: -d0
+
+# The unit tests are run with an almost empty environment.  In particular,
+# the variable MAKEFLAGS is not set.  The '.MAKEFLAGS:' above also doesn't
+# influence the environment variable MAKEFLAGS, therefore it is still
+# undefined at this point.
+.if ${MAKEFLAGS:Uundefined} != "undefined"
+.  error
+.endif
+
+# The special variable .MAKEFLAGS is influenced though.
+# See varname-dot-makeflags.mk for more details.
+.if ${.MAKEFLAGS} != " -r -k -d 0"
+.  error
+.endif
+
 all:
-	@:;

Added files:

Index: src/usr.bin/make/unit-tests/varname-dot-makeflags.exp
diff -u /dev/null src/usr.bin/make/unit-tests/varname-dot-makeflags.exp:1.1
--- /dev/null	Tue Dec  1 20:37:30 2020
+++ src/usr.bin/make/unit-tests/varname-dot-makeflags.exp	Tue Dec  1 20:37:30 2020
@@ -0,0 +1,3 @@
+echo "$MAKEFLAGS"
+ -r -k -d 00000 -D VARNAME WITH SPACES 
+exit status 0
Index: src/usr.bin/make/unit-tests/varname-dot-makeflags.mk
diff -u /dev/null src/usr.bin/make/unit-tests/varname-dot-makeflags.mk:1.1
--- /dev/null	Tue Dec  1 20:37:30 2020
+++ src/usr.bin/make/unit-tests/varname-dot-makeflags.mk	Tue Dec  1 20:37:30 2020
@@ -0,0 +1,15 @@
+# $NetBSD: varname-dot-makeflags.mk,v 1.1 2020/12/01 20:37:30 rillig Exp $
+#
+# Tests for the special .MAKEFLAGS variable, which collects almost all
+# command line arguments and passes them on to any child processes via
+# the environment variable MAKEFLAGS (without leading '.').
+
+# When options are parsed, the option and its argument are appended as
+# separate words to .MAKEFLAGS.  Special characters in the option argument
+# are not quoted though.  It seems to have not been necessary at least from
+# 1993 until 2020.
+.MAKEFLAGS: -d00000 -D"VARNAME WITH SPACES"
+
+all:
+	echo "$$MAKEFLAGS"
+	@:;

Reply via email to