Module Name: src Committed By: rillig Date: Thu Oct 19 18:24:33 UTC 2023
Modified Files: src/usr.bin/make/unit-tests: cond-short.exp cond-short.mk directive-for.exp directive-for.mk directive-ifndef.mk directive-include-guard.exp directive-include-guard.mk escape.exp escape.mk hanoi-include.mk recursive.exp recursive.mk unexport.mk var-eval-short.mk varmisc.exp varmisc.mk varmod-gmtime.mk Log Message: tests/make: clean up, explain and reorganize several tests To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/cond-short.exp \ src/usr.bin/make/unit-tests/directive-include-guard.mk cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/unit-tests/cond-short.mk cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/directive-for.exp \ src/usr.bin/make/unit-tests/varmod-gmtime.mk cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/unit-tests/directive-for.mk cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/directive-ifndef.mk cvs rdiff -u -r1.11 -r1.12 \ src/usr.bin/make/unit-tests/directive-include-guard.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/escape.exp cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/escape.mk cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/hanoi-include.mk \ src/usr.bin/make/unit-tests/recursive.exp cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/recursive.mk cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/unexport.mk cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/var-eval-short.mk cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/varmisc.exp cvs rdiff -u -r1.32 -r1.33 src/usr.bin/make/unit-tests/varmisc.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/cond-short.exp diff -u src/usr.bin/make/unit-tests/cond-short.exp:1.12 src/usr.bin/make/unit-tests/cond-short.exp:1.13 --- src/usr.bin/make/unit-tests/cond-short.exp:1.12 Sat Mar 4 13:42:36 2023 +++ src/usr.bin/make/unit-tests/cond-short.exp Thu Oct 19 18:24:33 2023 @@ -7,7 +7,7 @@ expected M pattern expected or expected or exists expected or empty -make: "cond-short.mk" line 214: Comparison with '<' requires both operands '' and '42' to be numeric +make: "cond-short.mk" line 231: Comparison with '<' requires both operands '' and '42' to be numeric make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/directive-include-guard.mk diff -u src/usr.bin/make/unit-tests/directive-include-guard.mk:1.12 src/usr.bin/make/unit-tests/directive-include-guard.mk:1.13 --- src/usr.bin/make/unit-tests/directive-include-guard.mk:1.12 Fri Aug 11 04:56:31 2023 +++ src/usr.bin/make/unit-tests/directive-include-guard.mk Thu Oct 19 18:24:33 2023 @@ -1,4 +1,4 @@ -# $NetBSD: directive-include-guard.mk,v 1.12 2023/08/11 04:56:31 rillig Exp $ +# $NetBSD: directive-include-guard.mk,v 1.13 2023/10/19 18:24:33 rillig Exp $ # # Tests for multiple-inclusion guards in makefiles. # @@ -15,8 +15,9 @@ # .endif # # When such a file is included for the second or later time, and the guard -# variable or the guard target is defined, including the file has no effect, -# as all its content is skipped. +# variable or the guard target is defined, the file is skipped completely, as +# including it would not have any effect, not even on the special variable +# '.MAKE.MAKEFILES', as that variable skips duplicate pathnames. # # See also: # https://gcc.gnu.org/onlinedocs/cppinternals/Guard-Macros.html @@ -46,6 +47,25 @@ LINES.variable-ifndef-reuse= \ # expect: Parse_PushInput: file variable-ifndef-reuse.tmp, line 1 # expect: Skipping 'variable-ifndef-reuse.tmp' because 'VARIABLE_IFNDEF' is defined +# The guard variable cannot be a number, as numbers are interpreted +# differently from bare words. +INCS+= variable-ifndef-zero +LINES.variable-ifndef-zero= \ + '.ifndef 0e0' \ + 'syntax error' \ + '.endif' +# expect: Parse_PushInput: file variable-ifndef-zero.tmp, line 1 +# expect: Parse_PushInput: file variable-ifndef-zero.tmp, line 1 + +# The guard variable cannot be a number, as numbers are interpreted +# differently from bare words. +INCS+= variable-ifndef-one +LINES.variable-ifndef-one= \ + '.ifndef 1' \ + '.endif' +# expect: Parse_PushInput: file variable-ifndef-one.tmp, line 1 +# expect: Parse_PushInput: file variable-ifndef-one.tmp, line 1 + # Comments and empty lines do not affect the multiple-inclusion guard. INCS+= comments LINES.comments= \ @@ -124,10 +144,10 @@ LINES.variable-name-exclamation= \ # expect: Parse_PushInput: file variable-name-exclamation.tmp, line 1 # expect: Parse_PushInput: file variable-name-exclamation.tmp, line 1 -# A variable name can contain a '!' in the middle, as that character is -# interpreted as an ordinary character in conditions as well as on the left -# side of a variable assignment. For guard variable names, the '!' is not -# supported in any place, though. +# In general, a variable name can contain a '!' in the middle, as that +# character is interpreted as an ordinary character in conditions as well as +# on the left side of a variable assignment. For guard variable names, the +# '!' is not supported in any place, though. INCS+= variable-name-exclamation-middle LINES.variable-name-exclamation-middle= \ '.ifndef VARIABLE_NAME!MIDDLE' \ Index: src/usr.bin/make/unit-tests/cond-short.mk diff -u src/usr.bin/make/unit-tests/cond-short.mk:1.20 src/usr.bin/make/unit-tests/cond-short.mk:1.21 --- src/usr.bin/make/unit-tests/cond-short.mk:1.20 Sat Mar 4 13:42:36 2023 +++ src/usr.bin/make/unit-tests/cond-short.mk Thu Oct 19 18:24:33 2023 @@ -1,4 +1,4 @@ -# $NetBSD: cond-short.mk,v 1.20 2023/03/04 13:42:36 rillig Exp $ +# $NetBSD: cond-short.mk,v 1.21 2023/10/19 18:24:33 rillig Exp $ # # Demonstrates that in conditions, the right-hand side of an && or || # is only evaluated if it can actually influence the result. @@ -178,6 +178,23 @@ INDIR_UNDEF= ${UNDEF} . error .endif + +# Since cond.c 1.76 from 2020.06.28 and before var.c 1.225 from 2020.07.01, +# the following snippet resulted in the error message 'Variable VAR is +# recursive'. The condition '0' evaluated to false, which made the right-hand +# side of the '&&' irrelevant. Back then, irrelevant condition parts were +# still evaluated, but in "irrelevant mode", which allowed undefined variables +# to occur in expressions. In this mode, the variable name 'VAR' was +# unnecessarily evaluated, resulting in the expression '${VAR${:U1}}'. In +# this expression, the variable name was 'VAR${:U1}', and of this variable +# name, only the fixed part 'VAR' was evaluated, without the part '${:U1}'. +# This partial evaluation led to the wrong error message about 'VAR' being +# recursive. +VAR= ${VAR${:U1}} +.if 0 && !empty(VAR) +.endif + + # Enclosing the expression in double quotes changes how that expression is # evaluated. In irrelevant expressions that are enclosed in double quotes, # expressions based on undefined variables are allowed and evaluate to an Index: src/usr.bin/make/unit-tests/directive-for.exp diff -u src/usr.bin/make/unit-tests/directive-for.exp:1.19 src/usr.bin/make/unit-tests/directive-for.exp:1.20 --- src/usr.bin/make/unit-tests/directive-for.exp:1.19 Thu Jun 1 20:56:35 2023 +++ src/usr.bin/make/unit-tests/directive-for.exp Thu Oct 19 18:24:33 2023 @@ -18,13 +18,14 @@ make: "directive-for.mk" line 166: inval make: "directive-for.mk" line 173: invalid character '$' in .for loop variable name make: "directive-for.mk" line 185: invalid character '$' in .for loop variable name make: "directive-for.mk" line 196: Unknown modifier "Z" -make: "directive-for.mk" line 197: XXX: Not reached word1 -make: "directive-for.mk" line 197: XXX: Not reached word3 -make: "directive-for.mk" line 204: no iteration variables in for -make: "directive-for.mk" line 230: 1 open conditional -make: "directive-for.mk" line 246: for-less endfor -make: "directive-for.mk" line 247: if-less endif -make: "directive-for.mk" line 255: if-less endif +make: "directive-for.mk" line 197: XXX: Should not reach word1 +make: "directive-for.mk" line 197: XXX: Should not reach before--after +make: "directive-for.mk" line 197: XXX: Should not reach word3 +make: "directive-for.mk" line 205: no iteration variables in for +make: "directive-for.mk" line 231: 1 open conditional +make: "directive-for.mk" line 247: for-less endfor +make: "directive-for.mk" line 248: if-less endif +make: "directive-for.mk" line 256: if-less endif For: new loop 2 For: end for 2 For: end for 1 @@ -35,7 +36,7 @@ For: loop body with outer = o: endfor For: end for 1 For: loop body with inner = i: -make: "directive-for.mk" line 303: newline-item=(a) +make: "directive-for.mk" line 304: newline-item=(a) make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/varmod-gmtime.mk diff -u src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.19 src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.20 --- src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.19 Sat Aug 19 11:53:10 2023 +++ src/usr.bin/make/unit-tests/varmod-gmtime.mk Thu Oct 19 18:24:33 2023 @@ -1,4 +1,4 @@ -# $NetBSD: varmod-gmtime.mk,v 1.19 2023/08/19 11:53:10 rillig Exp $ +# $NetBSD: varmod-gmtime.mk,v 1.20 2023/10/19 18:24:33 rillig Exp $ # # Tests for the :gmtime variable modifier, which formats a timestamp # using strftime(3) in UTC. @@ -174,4 +174,15 @@ TIMESTAMPS+= $t . endif .endfor + +.if ${year=%Y month=%m day=%d:L:gmtime=1459494000} != "year=2016 month=04 day=01" +. error +.endif +# Slightly contorted syntax to convert a UTC timestamp from an expression to a +# formatted timestamp. +.if ${%Y%m%d:L:${gmtime=${:U1459494000}:L}} != "20160401" +. error +.endif + + all: Index: src/usr.bin/make/unit-tests/directive-for.mk diff -u src/usr.bin/make/unit-tests/directive-for.mk:1.22 src/usr.bin/make/unit-tests/directive-for.mk:1.23 --- src/usr.bin/make/unit-tests/directive-for.mk:1.22 Thu Jun 1 20:56:35 2023 +++ src/usr.bin/make/unit-tests/directive-for.mk Thu Oct 19 18:24:33 2023 @@ -1,4 +1,4 @@ -# $NetBSD: directive-for.mk,v 1.22 2023/06/01 20:56:35 rillig Exp $ +# $NetBSD: directive-for.mk,v 1.23 2023/10/19 18:24:33 rillig Exp $ # # Tests for the .for directive. # @@ -193,11 +193,12 @@ INDIRECT= direct # should skip the whole loop. As of 2023-05-09, the loop is expanded as # usual. # expect+1: Unknown modifier "Z" -.for var in word1 ${:Uword2:Z} word3 -. info XXX: Not reached ${var} +.for var in word1 before-${:Uword2:Z}-after word3 +. info XXX: Should not reach ${var} .endfor -# expect-2: XXX: Not reached word1 -# expect-3: XXX: Not reached word3 +# expect-2: XXX: Should not reach word1 +# expect-3: XXX: Should not reach before--after +# expect-4: XXX: Should not reach word3 # An empty list of variables to the left of the 'in' is a parse error. Index: src/usr.bin/make/unit-tests/directive-ifndef.mk diff -u src/usr.bin/make/unit-tests/directive-ifndef.mk:1.8 src/usr.bin/make/unit-tests/directive-ifndef.mk:1.9 --- src/usr.bin/make/unit-tests/directive-ifndef.mk:1.8 Mon Jun 19 20:44:06 2023 +++ src/usr.bin/make/unit-tests/directive-ifndef.mk Thu Oct 19 18:24:33 2023 @@ -1,4 +1,4 @@ -# $NetBSD: directive-ifndef.mk,v 1.8 2023/06/19 20:44:06 rillig Exp $ +# $NetBSD: directive-ifndef.mk,v 1.9 2023/10/19 18:24:33 rillig Exp $ # # Tests for the .ifndef directive, which can be used for multiple-inclusion # guards. In contrast to C, where #ifndef and #define nicely line up the @@ -50,4 +50,38 @@ DEFINED= . error .endif + +# The negation from the 'if-not-defined' directive only applies to bare words, +# but not to numbers, quoted strings or expressions. Those are evaluated +# without extra negation, just like in a plain '.if' directive. +.ifndef 0 +. error +.endif +.ifndef 1 +.else +. error +.endif +.ifndef "" +. error +.endif +.ifndef "word" +.else +. error +.endif +.ifndef ${:UUNDEFINED} +.else +. error +.endif +.ifndef ${:UDEFINED} +. error +.endif +.ifndef ${:U0} +. error +.endif +.ifndef ${:U1} +.else +. error +.endif + + all: Index: src/usr.bin/make/unit-tests/directive-include-guard.exp diff -u src/usr.bin/make/unit-tests/directive-include-guard.exp:1.11 src/usr.bin/make/unit-tests/directive-include-guard.exp:1.12 --- src/usr.bin/make/unit-tests/directive-include-guard.exp:1.11 Fri Aug 11 04:56:31 2023 +++ src/usr.bin/make/unit-tests/directive-include-guard.exp Thu Oct 19 18:24:33 2023 @@ -2,6 +2,10 @@ Parse_PushInput: file variable-ifndef.tm Skipping 'variable-ifndef.tmp' because 'VARIABLE_IFNDEF' is defined Parse_PushInput: file variable-ifndef-reuse.tmp, line 1 Skipping 'variable-ifndef-reuse.tmp' because 'VARIABLE_IFNDEF' is defined +Parse_PushInput: file variable-ifndef-zero.tmp, line 1 +Parse_PushInput: file variable-ifndef-zero.tmp, line 1 +Parse_PushInput: file variable-ifndef-one.tmp, line 1 +Parse_PushInput: file variable-ifndef-one.tmp, line 1 Parse_PushInput: file comments.tmp, line 1 Skipping 'comments.tmp' because 'COMMENTS' is defined Parse_PushInput: file variable-if.tmp, line 1 Index: src/usr.bin/make/unit-tests/escape.exp diff -u src/usr.bin/make/unit-tests/escape.exp:1.7 src/usr.bin/make/unit-tests/escape.exp:1.8 --- src/usr.bin/make/unit-tests/escape.exp:1.7 Tue Sep 9 10:22:27 2014 +++ src/usr.bin/make/unit-tests/escape.exp Thu Oct 19 18:24:33 2023 @@ -1,5 +1,4 @@ var-1bs -printf "%s=:%s:\n" VAR1BS 111\\111; printf "%s=:%s:\n" VAR1BSa 111\\aaa; printf "%s=:%s:\n" VAR1BSA 111\\aaa; printf "%s=:%s:\n" VAR1BSda 111\\\$\{a\}; printf "%s=:%s:\n" VAR1BSdA 111\\\$\{A\}; printf "%s=:%s:\n" VAR1BSc 111\#\ backslash\ escapes\ comment\ char,\ so\ this\ is\ part\ of\ the\ value; printf "%s=:%s:\n" VAR1BSsc 111\\\ ; VAR1BS=:111\111: VAR1BSa=:111\aaa: VAR1BSA=:111\aaa: @@ -8,25 +7,22 @@ VAR1BSdA=:111\${A}: VAR1BSc=:111# backslash escapes comment char, so this is part of the value: VAR1BSsc=:111\ : var-2bs -printf "%s=:%s:\n" VAR2BS 222\\\\222; printf "%s=:%s:\n" VAR2BSa 222\\\\aaa; printf "%s=:%s:\n" VAR2BSA 222\\\\aaa; printf "%s=:%s:\n" VAR2BSda 222\\\\\$\{a\}; printf "%s=:%s:\n" VAR2BSdA 222\\\\\$\{A\}; printf "%s=:%s:\n" VAR2BSc 222\\\\; printf "%s=:%s:\n" VAR2BSsc 222\\\\; -VAR2BS=:222\\222: -VAR2BSa=:222\\aaa: -VAR2BSA=:222\\aaa: -VAR2BSda=:222\\${a}: -VAR2BSdA=:222\\${A}: -VAR2BSc=:222\\: -VAR2BSsc=:222\\: -var-1bsnl -printf "%s=:%s:\n" VAR1BSNL 111\ 111; printf "%s=:%s:\n" VAR1BSNLa 111\ aaa; printf "%s=:%s:\n" VAR1BSNLA 111\ aaa; printf "%s=:%s:\n" VAR1BSNLda 111\ \$\{a\}; printf "%s=:%s:\n" VAR1BSNLdA 111\ \$\{A\}; printf "%s=:%s:\n" VAR1BSNLc 111; printf "%s=:%s:\n" VAR1BSNLsc 111; -VAR1BSNL=:111 111: -VAR1BSNLa=:111 aaa: -VAR1BSNLA=:111 aaa: -VAR1BSNLda=:111 ${a}: -VAR1BSNLdA=:111 ${A}: -VAR1BSNLc=:111: -VAR1BSNLsc=:111: +VAR2.BS=:222\\222: +VAR2.BS.a=:222\\aaa: +VAR2.BS.A=:222\\aaa: +VAR2.BS.d.a=:222\\${a}: +VAR2.BS.d.A=:222\\${A}: +VAR2.BS.c=:222\\: +VAR2.BS.s.c=:222\\: +var-1bs-nl +VAR1.BS-NL=:111 111: +VAR1.BS-NL.a=:111 aaa: +VAR1.BS-NL.A=:111 aaa: +VAR1.BS-NL.d-a=:111 ${a}: +VAR1.BS-NL.d-A=:111 ${A}: +VAR1.BS-NL.c=:111: +VAR1.BS-NL.s-c=:111: var-2bsnl -printf "%s=:%s:\n" VAR2BSNL 222\\\\; printf "%s=:%s:\n" VAR2BSNLa 222\\\\; printf "%s=:%s:\n" VAR2BSNLA 222\\\\; printf "%s=:%s:\n" VAR2BSNLda 222\\\\; printf "%s=:%s:\n" VAR2BSNLdA 222\\\\; printf "%s=:%s:\n" VAR2BSNLc 222\\\\; printf "%s=:%s:\n" VAR2BSNLsc 222\\\\; VAR2BSNL=:222\\: VAR2BSNLa=:222\\: VAR2BSNLA=:222\\: @@ -35,7 +31,6 @@ VAR2BSNLdA=:222\\: VAR2BSNLc=:222\\: VAR2BSNLsc=:222\\: var-3bsnl -printf "%s=:%s:\n" VAR3BSNL 333\\\\\ 333=; printf "%s=:%s:\n" VAR3BSNLa 333\\\\\ aaa=; printf "%s=:%s:\n" VAR3BSNLA 333\\\\\ aaa=; printf "%s=:%s:\n" VAR3BSNLda 333\\\\\ \$\{a\}=; printf "%s=:%s:\n" VAR3BSNLdA 333\\\\\ \$\{A\}=; printf "%s=:%s:\n" VAR3BSNLc 333\\\\; printf "%s=:%s:\n" VAR3BSNLsc 333\\\\; VAR3BSNL=:333\\ 333=: VAR3BSNLa=:333\\ aaa=: VAR3BSNLA=:333\\ aaa=: @@ -44,7 +39,6 @@ VAR3BSNLdA=:333\\ ${A}=: VAR3BSNLc=:333\\: VAR3BSNLsc=:333\\: var-1bsnl-space -printf "%s=:%s:\n" VAR1BSNL00 first\ line; printf "%s=:%s:\n" VAR1BSNL0 first\ line\ no\ space\ on\ second\ line; printf "%s=:%s:\n" VAR1BSNLs first\ line\ one\ space\ on\ second\ line; printf "%s=:%s:\n" VAR1BSNLss first\ line\ two\ spaces\ on\ second\ line; printf "%s=:%s:\n" VAR1BSNLt first\ line\ one\ tab\ on\ second\ line; printf "%s=:%s:\n" VAR1BSNLtt first\ line\ two\ tabs\ on\ second\ line; printf "%s=:%s:\n" VAR1BSNLxx first\ line\ many\ spaces\ and\ tabs\ \[\ \ \ \ \]\ on\ second\ line; VAR1BSNL00=:first line: VAR1BSNL0=:first line no space on second line: VAR1BSNLs=:first line one space on second line: Index: src/usr.bin/make/unit-tests/escape.mk diff -u src/usr.bin/make/unit-tests/escape.mk:1.14 src/usr.bin/make/unit-tests/escape.mk:1.15 --- src/usr.bin/make/unit-tests/escape.mk:1.14 Tue Nov 3 17:38:45 2020 +++ src/usr.bin/make/unit-tests/escape.mk Thu Oct 19 18:24:33 2023 @@ -1,4 +1,4 @@ -# $NetBSD: escape.mk,v 1.14 2020/11/03 17:38:45 rillig Exp $ +# $NetBSD: escape.mk,v 1.15 2023/10/19 18:24:33 rillig Exp $ # # Test backslash escaping. @@ -53,7 +53,7 @@ should continue the comment. \ __printvars: .USE .MADE @echo ${.TARGET} - ${.ALLSRC:@v@ printf "%s=:%s:\n" ${v:Q} ${${v}:Q}; @} + @${.ALLSRC:@v@ printf "%s=:%s:\n" ${v:Q} ${${v}:Q}; @} # Embedded backslash in variable should be taken literally. # @@ -83,7 +83,8 @@ all: var-2bs var-2bs: .PHONY __printvars VAR2BS VAR2BSa VAR2BSA VAR2BSda VAR2BSdA \ VAR2BSc VAR2BSsc -# Backslash-newline in a variable setting is replaced by a single space. +# In a variable assignment, when the sequence <backslash><newline> occurs at +# the end of a physical line, it is replaced with a single space. # VAR1BSNL= 111\ 111 Index: src/usr.bin/make/unit-tests/hanoi-include.mk diff -u src/usr.bin/make/unit-tests/hanoi-include.mk:1.4 src/usr.bin/make/unit-tests/hanoi-include.mk:1.5 --- src/usr.bin/make/unit-tests/hanoi-include.mk:1.4 Thu Jan 19 22:48:42 2023 +++ src/usr.bin/make/unit-tests/hanoi-include.mk Thu Oct 19 18:24:33 2023 @@ -1,4 +1,4 @@ -# $NetBSD: hanoi-include.mk,v 1.4 2023/01/19 22:48:42 rillig Exp $ +# $NetBSD: hanoi-include.mk,v 1.5 2023/10/19 18:24:33 rillig Exp $ # # Implements the Towers of Hanoi puzzle, demonstrating a bunch of more or less # useful programming techniques: @@ -6,14 +6,15 @@ # * default assignment using the ?= assignment operator # * including the same file recursively (rather unusual) # * extracting the current value of a variable using the .for loop -# * using shell commands for calculations since make is a text processor # * using the :: dependency operator for adding commands to a target # * on-the-fly variable assignment expressions using the ::= modifier # # usage: # env N=3 make -r -f hanoi-include.mk # -# endless loop, since command line variables cannot be overridden: +# Specifying N in the command line instead of in the environment would produce +# an endless loop, since variables from the command line cannot be overridden +# by global variables: # make -r -f hanoi-include.mk N=3 N?= 5 # Move this number of disks ... Index: src/usr.bin/make/unit-tests/recursive.exp diff -u src/usr.bin/make/unit-tests/recursive.exp:1.4 src/usr.bin/make/unit-tests/recursive.exp:1.5 --- src/usr.bin/make/unit-tests/recursive.exp:1.4 Thu Jun 1 20:56:35 2023 +++ src/usr.bin/make/unit-tests/recursive.exp Thu Oct 19 18:24:33 2023 @@ -1,5 +1,5 @@ -make: "recursive.mk" line 37: Unclosed variable "MISSING_PAREN" -make: "recursive.mk" line 39: Unclosed variable "MISSING_BRACE" +make: "recursive.mk" line 38: Unclosed variable "MISSING_PAREN" +make: "recursive.mk" line 40: Unclosed variable "MISSING_BRACE" make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/recursive.mk diff -u src/usr.bin/make/unit-tests/recursive.mk:1.6 src/usr.bin/make/unit-tests/recursive.mk:1.7 --- src/usr.bin/make/unit-tests/recursive.mk:1.6 Thu Jun 1 20:56:35 2023 +++ src/usr.bin/make/unit-tests/recursive.mk Thu Oct 19 18:24:33 2023 @@ -1,4 +1,4 @@ -# $NetBSD: recursive.mk,v 1.6 2023/06/01 20:56:35 rillig Exp $ +# $NetBSD: recursive.mk,v 1.7 2023/10/19 18:24:33 rillig Exp $ # # In -dL mode, a variable may get expanded before it makes sense. # This would stop make from doing anything since the "recursive" error @@ -8,22 +8,23 @@ # whether there are unclosed variables. The variable value is therefore # parsed with VARE_PARSE_ONLY for that purpose. # -# Seen in pkgsrc/x11/libXfixes, and probably many more package that use -# GNU Automake. .MAKEFLAGS: -dL + AM_V_lt= ${am__v_lt_${V}} am__v_lt_= ${am__v_lt_${AM_DEFAULT_VERBOSITY}} am__v_lt_0= --silent am__v_lt_1= -# On 2020-08-06, make reported: "Variable am__v_lt_ is recursive." +# Since parse.c 1.243 from 2020-07-31 and before parse.c 1.249 from +# 2020-08-06, when make ran in -dL mode, it reported: "Variable am__v_lt_ is +# recursive." +# +# Seen in pkgsrc/x11/libXfixes, and probably many more package that use +# GNU Automake. libXfixes_la_LINK= ... ${AM_V_lt} ... -# somewhere later ... -AM_DEFAULT_VERBOSITY= 1 - # The purpose of the -dL flag is to detect unclosed variables. This # can be achieved by just parsing the variable and not evaluating it. Index: src/usr.bin/make/unit-tests/unexport.mk diff -u src/usr.bin/make/unit-tests/unexport.mk:1.5 src/usr.bin/make/unit-tests/unexport.mk:1.6 --- src/usr.bin/make/unit-tests/unexport.mk:1.5 Sat Oct 24 08:50:17 2020 +++ src/usr.bin/make/unit-tests/unexport.mk Thu Oct 19 18:24:33 2023 @@ -1,4 +1,4 @@ -# $NetBSD: unexport.mk,v 1.5 2020/10/24 08:50:17 rillig Exp $ +# $NetBSD: unexport.mk,v 1.6 2023/10/19 18:24:33 rillig Exp $ # pick up a bunch of exported vars FILTER_CMD= grep ^UT_ @@ -10,7 +10,7 @@ UT_TEST= unexport # Until 2020-08-08, Var_UnExport had special handling for '\n', that code # was not reachable though. At that point, backslash-newline has already -# been replaced with a simple space, and variables are not yet expanded. +# been replaced with a simple space, and expressions are not yet expanded. UT_BEFORE_NL= before UT_AFTER_NL= after .export UT_BEFORE_NL UT_AFTER_NL Index: src/usr.bin/make/unit-tests/var-eval-short.mk diff -u src/usr.bin/make/unit-tests/var-eval-short.mk:1.10 src/usr.bin/make/unit-tests/var-eval-short.mk:1.11 --- src/usr.bin/make/unit-tests/var-eval-short.mk:1.10 Thu Jun 1 20:56:35 2023 +++ src/usr.bin/make/unit-tests/var-eval-short.mk Thu Oct 19 18:24:33 2023 @@ -1,4 +1,4 @@ -# $NetBSD: var-eval-short.mk,v 1.10 2023/06/01 20:56:35 rillig Exp $ +# $NetBSD: var-eval-short.mk,v 1.11 2023/10/19 18:24:33 rillig Exp $ # # Tests for each variable modifier to ensure that they only do the minimum # necessary computations. If the result of the expression is irrelevant, @@ -18,7 +18,7 @@ FAIL= ${:!echo unexpected 1>&2!} # is ignored as well. To do that, it is necessary to step through the code of # each modifier. -# TODO: Test the modifiers in the same order as they appear in ApplyModifier. +# TODO: Test the modifiers in the same order as they occur in ApplyModifier. .if 0 && ${FAIL} .endif Index: src/usr.bin/make/unit-tests/varmisc.exp diff -u src/usr.bin/make/unit-tests/varmisc.exp:1.17 src/usr.bin/make/unit-tests/varmisc.exp:1.18 --- src/usr.bin/make/unit-tests/varmisc.exp:1.17 Tue Feb 23 15:56:30 2021 +++ src/usr.bin/make/unit-tests/varmisc.exp Thu Oct 19 18:24:33 2023 @@ -17,12 +17,9 @@ false FALSE do not evaluate or expand :? if discarding is set -year=2016 month=04 day=01 -date=20160401 Version=123.456.789 == 123456789 Literal=3.4.5 == 3004005 We have target specific vars -MAN= make.1 save-dollars: 0 = $ save-dollars: 1 = $$ save-dollars: 2 = $$ Index: src/usr.bin/make/unit-tests/varmisc.mk diff -u src/usr.bin/make/unit-tests/varmisc.mk:1.32 src/usr.bin/make/unit-tests/varmisc.mk:1.33 --- src/usr.bin/make/unit-tests/varmisc.mk:1.32 Sun Dec 5 10:02:51 2021 +++ src/usr.bin/make/unit-tests/varmisc.mk Thu Oct 19 18:24:33 2023 @@ -1,9 +1,9 @@ -# $NetBSD: varmisc.mk,v 1.32 2021/12/05 10:02:51 rillig Exp $ +# $NetBSD: varmisc.mk,v 1.33 2023/10/19 18:24:33 rillig Exp $ # # Miscellaneous variable tests. all: unmatched_var_paren D_true U_true D_false U_false Q_lhs Q_rhs NQ_none \ - strftime cmpv manok + cmpv all: save-dollars all: export-appended all: parse-dynamic @@ -46,13 +46,6 @@ NQ_none: @echo do not evaluate or expand :? if discarding @echo ${VSET:U${1:L:?${True}:${False}}} -April1= 1459494000 - -# slightly contorted syntax to use utc via variable -strftime: - @echo ${year=%Y month=%m day=%d:L:gmtime=1459494000} - @echo date=${%Y%m%d:L:${gmtime=${April1}:L}} - # big jumps to handle 3 digits per step M_cmpv.units= 1 1000 1000000 M_cmpv= S,., ,g:_:range:@i@+ $${_:[-$$i]} \* $${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh @@ -65,17 +58,6 @@ cmpv: @echo Literal=3.4.5 == ${3.4.5:L:${M_cmpv}} @echo We have ${${.TARGET:T}.only} -# catch mishandling of nested variables in .for loop -MAN= -MAN1= make.1 -.for s in 1 2 -. if defined(MAN$s) && !empty(MAN$s) -MAN+= ${MAN$s} -. endif -.endfor - -manok: - @echo MAN=${MAN} # Test parsing of boolean values. # begin .MAKE.SAVE_DOLLARS; see Var_SetWithFlags and ParseBoolean. @@ -130,10 +112,10 @@ VAR.${PARAM}+= 2 .if ${VAR.+} != "1 2" . error "${VAR.+}" .endif -.for param in + ! ? +.for param in : + ! ? VAR.${param}= ${param} .endfor -.if ${VAR.+} != "+" || ${VAR.!} != "!" || ${VAR.?} != "?" +.if ${VAR.${:U\:}} != ":" || ${VAR.+} != "+" || ${VAR.!} != "!" || ${VAR.?} != "?" . error "${VAR.+}" "${VAR.!}" "${VAR.?}" .endif