Module Name: src Committed By: rillig Date: Sat Feb 25 19:24:07 UTC 2023
Modified Files: src/usr.bin/make/unit-tests: varname-dot-makeflags.exp varname-dot-makeflags.mk varname-makeflags.mk Log Message: tests/make: clean up tests for MAKEFLAGS and related variables To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 \ src/usr.bin/make/unit-tests/varname-dot-makeflags.exp cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varname-dot-makeflags.mk \ 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/usr.bin/make/unit-tests/varname-dot-makeflags.exp diff -u src/usr.bin/make/unit-tests/varname-dot-makeflags.exp:1.5 src/usr.bin/make/unit-tests/varname-dot-makeflags.exp:1.6 --- src/usr.bin/make/unit-tests/varname-dot-makeflags.exp:1.5 Sat Feb 25 11:59:12 2023 +++ src/usr.bin/make/unit-tests/varname-dot-makeflags.exp Sat Feb 25 19:24:07 2023 @@ -1,9 +1,9 @@ make: "varname-dot-makeflags.mk" line 10: MAKEFLAGS=<undefined> make: "varname-dot-makeflags.mk" line 11: .MAKEFLAGS=< -r -k> make: "varname-dot-makeflags.mk" line 12: .MAKEOVERRIDES=<> -make: "varname-dot-makeflags.mk" line 17: MAKEFLAGS=<undefined> -make: "varname-dot-makeflags.mk" line 18: .MAKEFLAGS=< -r -k -D VARNAME -r> -make: "varname-dot-makeflags.mk" line 19: .MAKEOVERRIDES=< VAR> +make: "varname-dot-makeflags.mk" line 18: MAKEFLAGS=<undefined> +make: "varname-dot-makeflags.mk" line 20: .MAKEFLAGS=< -r -k -D VARNAME -r> +make: "varname-dot-makeflags.mk" line 22: .MAKEOVERRIDES=< VAR> runtime: MAKEFLAGS=< -r -k -D VARNAME -r VAR=value> runtime: .MAKEFLAGS=< -r -k -D VARNAME -r> runtime: .MAKEOVERRIDES=< VAR> Index: src/usr.bin/make/unit-tests/varname-dot-makeflags.mk diff -u src/usr.bin/make/unit-tests/varname-dot-makeflags.mk:1.6 src/usr.bin/make/unit-tests/varname-dot-makeflags.mk:1.7 --- src/usr.bin/make/unit-tests/varname-dot-makeflags.mk:1.6 Sat Feb 25 11:59:12 2023 +++ src/usr.bin/make/unit-tests/varname-dot-makeflags.mk Sat Feb 25 19:24:07 2023 @@ -1,4 +1,4 @@ -# $NetBSD: varname-dot-makeflags.mk,v 1.6 2023/02/25 11:59:12 rillig Exp $ +# $NetBSD: varname-dot-makeflags.mk,v 1.7 2023/02/25 19:24:07 rillig Exp $ # # Tests for the special .MAKEFLAGS variable, which collects almost all # command line arguments and passes them on to any child processes via @@ -14,11 +14,22 @@ # Append an option with argument, a plain option and a variable assignment. .MAKEFLAGS: -DVARNAME -r VAR=value +# expect+1: MAKEFLAGS=<undefined> .info MAKEFLAGS=<${MAKEFLAGS:Uundefined}> +# expect+1: .MAKEFLAGS=< -r -k -D VARNAME -r> .info .MAKEFLAGS=<${.MAKEFLAGS}> +# expect+1: .MAKEOVERRIDES=< VAR> .info .MAKEOVERRIDES=<${.MAKEOVERRIDES}> -# After parsing, the environment variable 'MAKEFLAGS' is set based on +# The environment variable 'MAKEFLAGS' is not available to child processes +# when parsing the makefiles. This is different from exported variables, +# which are already available during parse time. +.if ${:!echo "\${MAKEFLAGS-undef}"!} != "undef" +. error +.endif + +# After parsing, the environment variable 'MAKEFLAGS' is set based on the +# special variables '.MAKEFLAGS' and '.MAKEOVERRIDES'. runtime: @echo '$@: MAKEFLAGS=<'${MAKEFLAGS:Q}'>' @echo '$@: .MAKEFLAGS=<'${.MAKEFLAGS:Q}'>' Index: src/usr.bin/make/unit-tests/varname-makeflags.mk diff -u src/usr.bin/make/unit-tests/varname-makeflags.mk:1.6 src/usr.bin/make/unit-tests/varname-makeflags.mk:1.7 --- src/usr.bin/make/unit-tests/varname-makeflags.mk:1.6 Sat Feb 25 11:59:12 2023 +++ src/usr.bin/make/unit-tests/varname-makeflags.mk Sat Feb 25 19:24:07 2023 @@ -1,9 +1,11 @@ -# $NetBSD: varname-makeflags.mk,v 1.6 2023/02/25 11:59:12 rillig Exp $ +# $NetBSD: varname-makeflags.mk,v 1.7 2023/02/25 19:24:07 rillig Exp $ # -# 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. +# Tests for the environment variable 'MAKEFLAGS', from which additional +# command line arguments are read before the actual command line arguments. +# +# After reading the makefiles and before making the targets, the arguments +# that were collected in '.MAKEFLAGS' and '.MAKEOVERRIDES' are written back to +# the environment variable 'MAKEFLAGS'. all: spaces_stage_0 dollars_stage_0 append_stage_0 override_stage_0 @@ -11,9 +13,7 @@ all: spaces_stage_0 dollars_stage_0 appe .if !make(*stage*) # 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. +# the variable MAKEFLAGS is not set. . if ${MAKEFLAGS:Uundefined} != "undefined" . error . endif