diff options
Diffstat (limited to 'unit-tests')
| -rw-r--r-- | unit-tests/dep.exp | 20 | ||||
| -rw-r--r-- | unit-tests/dep.mk | 54 | ||||
| -rw-r--r-- | unit-tests/dir.mk | 4 | ||||
| -rw-r--r-- | unit-tests/varmod-match.mk | 12 |
4 files changed, 75 insertions, 15 deletions
diff --git a/unit-tests/dep.exp b/unit-tests/dep.exp index c08f86bc73db..99295ee12b4f 100644 --- a/unit-tests/dep.exp +++ b/unit-tests/dep.exp @@ -1,5 +1,17 @@ -make: dep.mk:11: Inconsistent operator for only-colon -make: dep.mk:13: Inconsistent operator for only-colon +make: dep.mk:18: Inconsistent operator for only-colon + in make[1] in directory "<curdir>" +make: dep.mk:20: Inconsistent operator for only-colon + in make[1] in directory "<curdir>" make: Fatal errors encountered -- cannot continue -make: stopped making "all" in unit-tests -exit status 1 +make: stopped making "parse-only-colon" in unit-tests +sub exit status 1 +Making renamed-parse-semicolon-in-source out of nothing. +Making parse-semicolon-in-source from renamed-parse-semicolon-in-source. +make: Malformed expression at "$$-rest" + in make[1] in directory "<curdir>" +semicolon-in-modifier.param: after semicolon +parentheses-in-modifier.1-12-23-3: after semicolon +var-semicolon.: after semicolon +double-dollar.$-rest: after semicolon +sub exit status 2 +exit status 0 diff --git a/unit-tests/dep.mk b/unit-tests/dep.mk index 53fadc789b13..259085e27b1d 100644 --- a/unit-tests/dep.mk +++ b/unit-tests/dep.mk @@ -1,8 +1,15 @@ -# $NetBSD: dep.mk,v 1.4 2023/06/01 07:27:30 rillig Exp $ +# $NetBSD: dep.mk,v 1.6 2026/06/09 08:27:08 rillig Exp $ # # Tests for dependency declarations, such as "target: sources". -.MAIN: all +all: .PHONY + @${MAKE} -f ${MAKEFILE} parse-only-colon || echo "sub exit status $$?" + @${MAKE} -f ${MAKEFILE} parse-semicolon-in-source + @${MAKE} -f ${MAKEFILE} parse-semicolon || echo "sub exit status $$?" + + +.if make(parse-only-colon) +parse-only-colon: .PHONY # As soon as a target is defined using one of the dependency operators, it is # restricted to this dependency operator and cannot use the others anymore. @@ -15,16 +22,47 @@ only-colon:: # would be another error message. only-colon: +.endif + # Before parse.c 1.158 from 2009-10-07, the parser broke dependency lines at # the first ';', without parsing expressions as such. It interpreted the # first ';' as the separator between the dependency and its commands, and the # '^' as a shell command. -all: for-subst -.for file in ${.PARSEFILE} -for-subst: ${file:S;^;./;g} - @echo ".for with :S;... OK" -.endfor +.if make(parse-semicolon-in-source) +parse-semicolon-in-source: .PHONY + +. for file in parse-semicolon-in-source +parse-semicolon-in-source: ${file:S;^;renamed-;g} + @echo "Making ${.TARGET} from ${.ALLSRC}." +renamed-parse-semicolon-in-source: + @echo "Making ${.TARGET} out of nothing." +. endfor + +.endif + + +# Before parse.c 1.757 from 2026-06-09, the parser counted "$(" and "${" as +# opening a brace level, and ")" and "}" as closing it. It didn't count a +# plain "(" or "{" as opening, though. This simple counting resulted in +# parse errors on modifiers containing parentheses or braces, as well as +# semicolons. +.if make(parse-semicolon) +parse-semicolon: .PHONY + +semicolon-in-modifier.${:Utarget:S;target;param;}:; @echo '$@: after semicolon' +parse-semicolon: semicolon-in-modifier.param + +parentheses-in-modifier.${:U123:C;(.);\1-\1;g}:; @echo '$@: after semicolon' +parse-semicolon: parentheses-in-modifier.1-12-23-3 + +var-semicolon.$;:; @echo '$@: after semicolon' +parse-semicolon: var-semicolon. +# Using actual dollars in target names is still tricky and not recommended, +# due to multiple levels of expansion, that's where the 8 dollars come from. +# expect: make: Malformed expression at "$$-rest" +double-dollar.$$$;-$$$$-rest:; @echo '$@: after semicolon' +parse-semicolon: double-dollar.$$$$-$$$$$$$$-rest -all: +.endif diff --git a/unit-tests/dir.mk b/unit-tests/dir.mk index 956285393489..685a4660f01c 100644 --- a/unit-tests/dir.mk +++ b/unit-tests/dir.mk @@ -1,4 +1,4 @@ -# $NetBSD: dir.mk,v 1.11 2023/12/19 19:33:40 rillig Exp $ +# $NetBSD: dir.mk,v 1.12 2026/07/03 15:31:35 sjg Exp $ # # Tests for dir.c. @@ -21,7 +21,7 @@ all: {one,two,three} .if target({one,two,three}) . error .endif -.if ${.ALLTARGETS:M{one,two,three}} != "{one,two,three}" +.if ${.ALLTARGETS:M\{one,two,three\}} != "{one,two,three}" . error .endif diff --git a/unit-tests/varmod-match.mk b/unit-tests/varmod-match.mk index 5894196c9cd5..0e5664bb3870 100644 --- a/unit-tests/varmod-match.mk +++ b/unit-tests/varmod-match.mk @@ -1,4 +1,4 @@ -# $NetBSD: varmod-match.mk,v 1.32 2025/06/29 09:40:13 rillig Exp $ +# $NetBSD: varmod-match.mk,v 1.33 2026/07/03 15:31:35 sjg Exp $ # # Tests for the ':M' modifier, which keeps only those words that match the # given pattern. @@ -388,3 +388,13 @@ WORDS= [x- x x- y yyyyy .if ${:U:${:UM\\\:\\}} . error .endif + +# :M supports alternation +.if ${/bin/sh ../Makefile.inc cat .../mk/sys.mk:L:M*{Makefile*,.mk}} != "../Makefile.inc .../mk/sys.mk" +. error +.endif + +# :M supports alternation +.if ${{a} one and two {o} yes:L:M\{{a,e,i,o,u}\}} != "{a} {o}" +. error +.endif |
