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

This commit is contained in:
rillig 2020-12-01 20:37:30 +00:00
parent 0ab8d018af
commit 71bfc5d9d5
5 changed files with 44 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,3 @@
echo "$MAKEFLAGS"
-r -k -d 00000 -D VARNAME WITH SPACES
exit status 0

View File

@ -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"
@:;

View File

@ -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:
@:;