Module Name: src Committed By: rillig Date: Tue Mar 5 23:07:58 UTC 2024
Modified Files: src/usr.bin/make/unit-tests: var-scope-local.exp var-scope-local.mk Log Message: tests/make: clean up test for local scope variables Use the same style of quotes for both kinds of variables. To make the variable values more easily comparable, write them to a single line. Add the output to the 'expect' lines. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/var-scope-local.exp cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/var-scope-local.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/var-scope-local.exp diff -u src/usr.bin/make/unit-tests/var-scope-local.exp:1.8 src/usr.bin/make/unit-tests/var-scope-local.exp:1.9 --- src/usr.bin/make/unit-tests/var-scope-local.exp:1.8 Fri Mar 1 20:15:59 2024 +++ src/usr.bin/make/unit-tests/var-scope-local.exp Tue Mar 5 23:07:58 2024 @@ -60,19 +60,12 @@ dir/subdir/inference-rule-chain.ir-to: * : Making var-scope-local.c out of nothing. : Making var-scope-local.o from var-scope-local.c. : Making basename "var-scope-local.o" in "." from "var-scope-local.c" in ".". -: Making var-scope-local-assign.o with VAR="local". -var-scope-local-assign.o env has VAR='local' -: Making var-scope-local-append.o with VAR="local to var-scope-local-append.o". -var-scope-local-append.o env has VAR='local to var-scope-local-append.o' -: Making var-scope-local-append-global.o with VAR="global+local". -var-scope-local-append-global.o env has VAR='global+local' -: Making var-scope-local-default.o with VAR="global". -var-scope-local-default.o env has VAR='global' -: Making var-scope-local-subst.o with VAR="global+local". -var-scope-local-subst.o env has VAR='global+local' -: Making var-scope-local-shell.o with VAR="output". -var-scope-local-shell.o env has VAR='output' -: var-scope-local-use.o uses .USE VAR="global" -var-scope-local-use.o env has VAR='global' +Making var-scope-local-assign.o with make 'local' and env 'local'. +Making var-scope-local-append.o with make 'local to var-scope-local-append.o' and env 'local to var-scope-local-append.o'. +Making var-scope-local-append-global.o with make 'global+local' and env 'global+local'. +Making var-scope-local-default.o with make 'global' and env 'global'. +Making var-scope-local-subst.o with make 'global+local' and env 'global+local'. +Making var-scope-local-shell.o with make 'output' and env 'output'. +Making .USE var-scope-local-use.o with make 'global' and env 'global'. : all overwritten exit status 0 Index: src/usr.bin/make/unit-tests/var-scope-local.mk diff -u src/usr.bin/make/unit-tests/var-scope-local.mk:1.10 src/usr.bin/make/unit-tests/var-scope-local.mk:1.11 --- src/usr.bin/make/unit-tests/var-scope-local.mk:1.10 Fri Mar 1 20:15:59 2024 +++ src/usr.bin/make/unit-tests/var-scope-local.mk Tue Mar 5 23:07:58 2024 @@ -1,4 +1,4 @@ -# $NetBSD: var-scope-local.mk,v 1.10 2024/03/01 20:15:59 sjg Exp $ +# $NetBSD: var-scope-local.mk,v 1.11 2024/03/05 23:07:58 rillig Exp $ # # Tests for target-local variables, such as ${.TARGET} or $@. These variables # are relatively short-lived as they are created just before making the @@ -199,8 +199,7 @@ var-scope-local-append-global.o \ var-scope-local-default.o \ var-scope-local-subst.o \ var-scope-local-shell.o: - : Making ${.TARGET} with VAR="${VAR}". - @echo "${.TARGET} env has VAR='$$VAR'" + @echo "Making ${.TARGET} with make '"${VAR:Q}"' and env '$$VAR'." # Target-local variables are enabled by default. Force them to be enabled # just in case a test above has disabled them. @@ -215,7 +214,7 @@ VAR= global # irrelevant. # # expect-reset -# expect: : Making var-scope-local-assign.o with VAR="local". +# expect: Making var-scope-local-assign.o with make 'local' and env 'local'. var-scope-local-assign.o: VAR= local # Assignments using '+=' do *not* look up the global value, instead they only @@ -225,7 +224,7 @@ var-scope-local-append.o: VAR+= local # behaves as expected. Note that the expression '${.TARGET}' is not resolved # when parsing the dependency line, its evaluation is deferred until the # target is actually made. -# expect: : Making var-scope-local-append.o with VAR="local to var-scope-local-append.o". +# expect: Making var-scope-local-append.o with make 'local to var-scope-local-append.o' and env 'local to var-scope-local-append.o'. var-scope-local-append.o: VAR += to ${.TARGET} # To access the value of a global variable, use an expression. This # expression is expanded before parsing the whole dependency line. Since the @@ -235,7 +234,7 @@ var-scope-local-append.o: VAR += to ${.T # not influence the parsing of the variable assignment. The effective # variable assignment, after expanding the whole line first, is thus # 'VAR= global+local'. -# expect: : Making var-scope-local-append-global.o with VAR="global+local". +# expect: Making var-scope-local-append-global.o with make 'global+local' and env 'global+local'. var-scope-local-append-global.o: VAR= ${VAR}+local var-scope-local-default.o: VAR ?= first @@ -243,7 +242,7 @@ var-scope-local-default.o: VAR ?= second # XXX: '?=' does look at the global variable. That's a long-standing # inconsistency between the assignment operators '+=' and '?='. See # Var_AppendExpand and VarAssign_Eval. -# expect: : Making var-scope-local-default.o with VAR="global". +# expect: Making var-scope-local-default.o with make 'global' and env 'global'. # Using the variable assignment operator ':=' provides another way of # accessing a global variable and extending it with local modifications. The @@ -251,7 +250,7 @@ var-scope-local-default.o: VAR ?= second # dependency line as a whole. After that, the parser sees the variable # assignment as 'VAR := ${VAR}+local' and searches for the variable 'VAR' in # the usual scopes, picking up the variable from the global scope. -# expect: : Making var-scope-local-subst.o with VAR="global+local". +# expect: Making var-scope-local-subst.o with make 'global+local' and env 'global+local'. var-scope-local-subst.o: VAR := $${VAR}+local # The variable assignment operator '!=' assigns the output of the shell @@ -263,10 +262,9 @@ var-scope-local-shell.o: VAR != echo out # While VAR=use will be set for a .USE node, it will never be seen since only # the ultimate target's context is searched; the variable assignments from the # .USE target are not copied to the ultimate target's. -# expect: : var-scope-local-use.o uses .USE VAR="global" +# expect: Making .USE var-scope-local-use.o with make 'global' and env 'global'. a_use: .USE VAR=use - : ${.TARGET} uses .USE VAR="${VAR}" - @echo "${.TARGET} env has VAR='$$VAR'" + @echo "Making .USE ${.TARGET} with make '"${VAR:Q}"' and env '$$VAR'." all: var-scope-local-use.o var-scope-local-use.o: a_use