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 tests/make: clean up tests for MAKEF...
details: https://anonhg.NetBSD.org/src/rev/519133002752
branches: trunk
changeset: 373752:519133002752
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Feb 25 19:24:07 2023 +0000
description:
tests/make: clean up tests for MAKEFLAGS and related variables
diffstat:
usr.bin/make/unit-tests/varname-dot-makeflags.exp | 6 +++---
usr.bin/make/unit-tests/varname-dot-makeflags.mk | 15 +++++++++++++--
usr.bin/make/unit-tests/varname-makeflags.mk | 16 ++++++++--------
3 files changed, 24 insertions(+), 13 deletions(-)
diffs (80 lines):
diff -r 6e8cc92235d3 -r 519133002752 usr.bin/make/unit-tests/varname-dot-makeflags.exp
--- a/usr.bin/make/unit-tests/varname-dot-makeflags.exp Sat Feb 25 18:35:54 2023 +0000
+++ b/usr.bin/make/unit-tests/varname-dot-makeflags.exp Sat Feb 25 19:24:07 2023 +0000
@@ -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>
diff -r 6e8cc92235d3 -r 519133002752 usr.bin/make/unit-tests/varname-dot-makeflags.mk
--- a/usr.bin/make/unit-tests/varname-dot-makeflags.mk Sat Feb 25 18:35:54 2023 +0000
+++ b/usr.bin/make/unit-tests/varname-dot-makeflags.mk Sat Feb 25 19:24:07 2023 +0000
@@ -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}'>'
diff -r 6e8cc92235d3 -r 519133002752 usr.bin/make/unit-tests/varname-makeflags.mk
--- a/usr.bin/make/unit-tests/varname-makeflags.mk Sat Feb 25 18:35:54 2023 +0000
+++ b/usr.bin/make/unit-tests/varname-makeflags.mk Sat Feb 25 19:24:07 2023 +0000
@@ -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 @@
.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
Home |
Main Index |
Thread Index |
Old Index