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 .M...
details: https://anonhg.NetBSD.org/src/rev/c85214ff107d
branches: trunk
changeset: 946576:c85214ff107d
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Dec 01 20:37:30 2020 +0000
description:
make(1): add test for the special .MAKEFLAGS variable
diffstat:
distrib/sets/lists/tests/mi | 4 ++-
usr.bin/make/unit-tests/Makefile | 3 +-
usr.bin/make/unit-tests/varname-dot-makeflags.exp | 3 ++
usr.bin/make/unit-tests/varname-dot-makeflags.mk | 15 ++++++++++++++
usr.bin/make/unit-tests/varname-makeflags.mk | 24 ++++++++++++++++++++--
5 files changed, 44 insertions(+), 5 deletions(-)
diffs (94 lines):
diff -r e13ca8ae4ee8 -r c85214ff107d distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Tue Dec 01 20:15:23 2020 +0000
+++ b/distrib/sets/lists/tests/mi Tue Dec 01 20:37:30 2020 +0000
@@ -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
diff -r e13ca8ae4ee8 -r c85214ff107d usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile Tue Dec 01 20:15:23 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile Tue Dec 01 20:37:30 2020 +0000
@@ -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-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
diff -r e13ca8ae4ee8 -r c85214ff107d usr.bin/make/unit-tests/varname-dot-makeflags.exp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/varname-dot-makeflags.exp Tue Dec 01 20:37:30 2020 +0000
@@ -0,0 +1,3 @@
+echo "$MAKEFLAGS"
+ -r -k -d 00000 -D VARNAME WITH SPACES
+exit status 0
diff -r e13ca8ae4ee8 -r c85214ff107d usr.bin/make/unit-tests/varname-dot-makeflags.mk
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/varname-dot-makeflags.mk Tue Dec 01 20:37:30 2020 +0000
@@ -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"
+ @:;
diff -r e13ca8ae4ee8 -r c85214ff107d usr.bin/make/unit-tests/varname-makeflags.mk
--- a/usr.bin/make/unit-tests/varname-makeflags.mk Tue Dec 01 20:15:23 2020 +0000
+++ b/usr.bin/make/unit-tests/varname-makeflags.mk Tue Dec 01 20:37:30 2020 +0000
@@ -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:
- @:;
Home |
Main Index |
Thread Index |
Old Index