Fri Apr 7 05:54:16 2023 UTC ()
tests/make: add cross references to command line tests


(rillig)
diff -r1.1 -r1.2 src/usr.bin/make/unit-tests/var-scope-cmdline.exp
diff -r1.1 -r1.2 src/usr.bin/make/unit-tests/var-scope-cmdline.mk
diff -r1.6 -r1.7 src/usr.bin/make/unit-tests/varcmd.mk

cvs diff -r1.1 -r1.2 src/usr.bin/make/unit-tests/var-scope-cmdline.exp (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/var-scope-cmdline.exp 2022/01/23 16:25:54 1.1
+++ src/usr.bin/make/unit-tests/var-scope-cmdline.exp 2023/04/07 05:54:16 1.2
@@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
1make: "var-scope-cmdline.mk" line 67: global 1make: "var-scope-cmdline.mk" line 71: global
2make: "var-scope-cmdline.mk" line 76: makeflags 2make: "var-scope-cmdline.mk" line 80: makeflags
3makeflags 3makeflags
4exit status 0 4exit status 0

cvs diff -r1.1 -r1.2 src/usr.bin/make/unit-tests/var-scope-cmdline.mk (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/var-scope-cmdline.mk 2022/01/23 16:25:54 1.1
+++ src/usr.bin/make/unit-tests/var-scope-cmdline.mk 2023/04/07 05:54:16 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: var-scope-cmdline.mk,v 1.1 2022/01/23 16:25:54 rillig Exp $ 1# $NetBSD: var-scope-cmdline.mk,v 1.2 2023/04/07 05:54:16 rillig Exp $
2# 2#
3# Tests for variables specified on the command line. 3# Tests for variables specified on the command line.
4# 4#
5# Variables that are specified on the command line override those from the 5# Variables that are specified on the command line override those from the
6# global scope. 6# global scope.
7# 7#
8# For performance reasons, the actual implementation is more complex than the 8# For performance reasons, the actual implementation is more complex than the
9# above single-sentence rule, in order to avoid unnecessary lookups in scopes, 9# above single-sentence rule, in order to avoid unnecessary lookups in scopes,
10# which before var.c 1.586 from 2020-10-25 calculated the hash value of the 10# which before var.c 1.586 from 2020-10-25 calculated the hash value of the
11# variable name once for each lookup. Instead, when looking up the value of 11# variable name once for each lookup. Instead, when looking up the value of
12# a variable, the search often starts in the global scope since that is where 12# a variable, the search often starts in the global scope since that is where
13# most of the variables are stored. This conflicts with the statement that 13# most of the variables are stored. This conflicts with the statement that
14# variables from the cmdline scope override global variables, since after the 14# variables from the cmdline scope override global variables, since after the
@@ -51,26 +51,30 @@ @@ -51,26 +51,30 @@
51# 51#
52# Another bug was the wrong assumption that "deleting a cmdline variable is 52# Another bug was the wrong assumption that "deleting a cmdline variable is
53# not possible". Deleting such a variable has been possible since var.c 1.204 53# not possible". Deleting such a variable has been possible since var.c 1.204
54# from 2016-02-19, when the variable modifier ':@' started to delete the 54# from 2016-02-19, when the variable modifier ':@' started to delete the
55# temporary loop variable after finishing the loop. It was probably not 55# temporary loop variable after finishing the loop. It was probably not
56# intended back then that a side effect of this seemingly simple change was 56# intended back then that a side effect of this seemingly simple change was
57# that both global and cmdline variables could now be undefined at will as a 57# that both global and cmdline variables could now be undefined at will as a
58# side effect of evaluating a variable expression. As of 2021-02-23, this is 58# side effect of evaluating a variable expression. As of 2021-02-23, this is
59# still possible. 59# still possible.
60# 60#
61# Most cmdline variables are set at the very beginning, when parsing the 61# Most cmdline variables are set at the very beginning, when parsing the
62# command line arguments. Using the special target '.MAKEFLAGS', it is 62# command line arguments. Using the special target '.MAKEFLAGS', it is
63# possible to set cmdline variables at any later time. 63# possible to set cmdline variables at any later time.
 64#
 65# See also:
 66# varcmd.mk
 67# varname-makeflags.mk
64 68
65# A normal global variable, without any cmdline variable nearby. 69# A normal global variable, without any cmdline variable nearby.
66VAR= global 70VAR= global
67.info ${VAR} 71.info ${VAR}
68 72
69# The global variable is "overridden" by simply deleting it and then 73# The global variable is "overridden" by simply deleting it and then
70# installing the cmdline variable instead. Since there is no obvious way to 74# installing the cmdline variable instead. Since there is no obvious way to
71# undefine a cmdline variable, there is no need to remember the old value 75# undefine a cmdline variable, there is no need to remember the old value
72# of the global variable could become visible again. 76# of the global variable could become visible again.
73# 77#
74# See varmod-loop.mk for a non-obvious way to undefine a cmdline variable. 78# See varmod-loop.mk for a non-obvious way to undefine a cmdline variable.
75.MAKEFLAGS: VAR=makeflags 79.MAKEFLAGS: VAR=makeflags
76.info ${VAR} 80.info ${VAR}

cvs diff -r1.6 -r1.7 src/usr.bin/make/unit-tests/varcmd.mk (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/varcmd.mk 2021/02/16 19:43:09 1.6
+++ src/usr.bin/make/unit-tests/varcmd.mk 2023/04/07 05:54:16 1.7
@@ -1,27 +1,31 @@ @@ -1,27 +1,31 @@
1# $NetBSD: varcmd.mk,v 1.6 2021/02/16 19:43:09 rillig Exp $ 1# $NetBSD: varcmd.mk,v 1.7 2023/04/07 05:54:16 rillig Exp $
2# 2#
3# Test behaviour of recursive make and vars set on command line. 3# Test behaviour of recursive make and vars set on command line.
4# 4#
5# FIXME: The purpose of this test is unclear. The test uses six levels of 5# FIXME: The purpose of this test is unclear. The test uses six levels of
6# sub-makes, which makes it incredibly hard to understand. There must be at 6# sub-makes, which makes it incredibly hard to understand. There must be at
7# least an introductory explanation about what _should_ happen here. 7# least an introductory explanation about what _should_ happen here.
8# The variable names are terrible, as well as their values. 8# The variable names are terrible, as well as their values.
9# 9#
10# This test produces different results if the large block with the condition 10# This test produces different results if the large block with the condition
11# "scope == SCOPE_GLOBAL" in Var_SetWithFlags is removed. This test should 11# "scope == SCOPE_GLOBAL" in Var_SetWithFlags is removed. This test should
12# be rewritten to make it clear why there is a difference and why this is 12# be rewritten to make it clear why there is a difference and why this is
13# actually intended. Removing that large block of code makes only this test 13# actually intended. Removing that large block of code makes only this test
14# and vardebug.mk fail, which is not enough. 14# and vardebug.mk fail, which is not enough.
 15#
 16# See also:
 17# var-scope-cmdline.mk
 18# varname-makeflags.mk
15 19
16FU= fu 20FU= fu
17FOO?= foo 21FOO?= foo
18.if !empty(.TARGETS) 22.if !empty(.TARGETS)
19TAG= ${.TARGETS} 23TAG= ${.TARGETS}
20.endif 24.endif
21TAG?= default 25TAG?= default
22 26
23all: one 27all: one
24 28
25show: 29show:
26 @echo "${TAG} FU=<v>${FU}</v> FOO=<v>${FOO}</v> VAR=<v>${VAR}</v>" 30 @echo "${TAG} FU=<v>${FU}</v> FOO=<v>${FOO}</v> VAR=<v>${VAR}</v>"
27 31