Module Name: src Committed By: rillig Date: Sat Oct 31 11:06:24 UTC 2020
Modified Files: src/distrib/sets/lists/tests: mi src/usr.bin/make/unit-tests: Makefile varmod-sysv.mk Removed Files: src/usr.bin/make/unit-tests: sysv.exp sysv.mk Log Message: make(1): merge the SysV modifier tests into varmod-sysv To generate a diff of this commit: cvs rdiff -u -r1.952 -r1.953 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.177 -r1.178 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r1.10 -r0 src/usr.bin/make/unit-tests/sysv.exp cvs rdiff -u -r1.15 -r0 src/usr.bin/make/unit-tests/sysv.mk cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-sysv.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.952 src/distrib/sets/lists/tests/mi:1.953 --- src/distrib/sets/lists/tests/mi:1.952 Sat Oct 31 11:03:18 2020 +++ src/distrib/sets/lists/tests/mi Sat Oct 31 11:06:24 2020 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.952 2020/10/31 11:03:18 rillig Exp $ +# $NetBSD: mi,v 1.953 2020/10/31 11:06:24 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -5264,8 +5264,8 @@ ./usr/tests/usr.bin/make/unit-tests/suffixes.mk tests-obsolete obsolete ./usr/tests/usr.bin/make/unit-tests/sunshcmd.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/sunshcmd.mk tests-usr.bin-tests compattestfile,atf -./usr/tests/usr.bin/make/unit-tests/sysv.exp tests-usr.bin-tests compattestfile,atf -./usr/tests/usr.bin/make/unit-tests/sysv.mk tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/sysv.exp tests-obsolete obsolete +./usr/tests/usr.bin/make/unit-tests/sysv.mk tests-obsolete obsolete ./usr/tests/usr.bin/make/unit-tests/ternary.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/ternary.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/unexport-env.exp tests-usr.bin-tests compattestfile,atf Index: src/usr.bin/make/unit-tests/Makefile diff -u src/usr.bin/make/unit-tests/Makefile:1.177 src/usr.bin/make/unit-tests/Makefile:1.178 --- src/usr.bin/make/unit-tests/Makefile:1.177 Fri Oct 30 15:03:58 2020 +++ src/usr.bin/make/unit-tests/Makefile Sat Oct 31 11:06:24 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.177 2020/10/30 15:03:58 rillig Exp $ +# $NetBSD: Makefile,v 1.178 2020/10/31 11:06:24 rillig Exp $ # # Unit tests for make(1) # @@ -261,7 +261,6 @@ TESTS+= suff-transform-endless TESTS+= suff-transform-expand TESTS+= suff-transform-select TESTS+= sunshcmd -TESTS+= sysv TESTS+= ternary TESTS+= unexport TESTS+= unexport-env Index: src/usr.bin/make/unit-tests/varmod-sysv.mk diff -u src/usr.bin/make/unit-tests/varmod-sysv.mk:1.8 src/usr.bin/make/unit-tests/varmod-sysv.mk:1.9 --- src/usr.bin/make/unit-tests/varmod-sysv.mk:1.8 Sat Oct 31 10:18:32 2020 +++ src/usr.bin/make/unit-tests/varmod-sysv.mk Sat Oct 31 11:06:24 2020 @@ -1,4 +1,4 @@ -# $NetBSD: varmod-sysv.mk,v 1.8 2020/10/31 10:18:32 rillig Exp $ +# $NetBSD: varmod-sysv.mk,v 1.9 2020/10/31 11:06:24 rillig Exp $ # # Tests for the ${VAR:from=to} variable modifier, which replaces the suffix # "from" with "to". It can also use '%' as a wildcard. @@ -35,6 +35,13 @@ . error .endif +# The :from=to modifier can also be used to surround each word by strings. +# It might be tempting to use this for enclosing a string in quotes for the +# shell, but that's the job of the :Q modifier. +.if ${one two three:L:%=(%)} != "(one) (two) (three)" +. error +.endif + # When the :from=to modifier is parsed, it lasts until the closing brace # or parenthesis. The :Q in the below expression may look like a modifier # but isn't. It is part of the replacement string. @@ -42,6 +49,38 @@ . error .endif +# In the :from=to modifier, both parts can contain variable expressions. +.if ${one two:L:${:Uone}=${:U1}} != "1 two" +. error +.endif + +# In the :from=to modifier, the "from" part is expanded exactly once. +.if ${:U\$ \$\$ \$\$\$\$:${:U\$\$\$\$}=4} != "\$ \$\$ 4" +. error +.endif + +# In the :from=to modifier, the "to" part is expanded exactly twice. +# XXX: The right-hand side should be expanded only once. +# XXX: It's hard to get the escaping correct here, and to read that. +# XXX: It's not intuitive why the closing brace must be escaped but not +# the opening brace. +.if ${:U1 2 4:4=${:Uonce\${\:Utwice\}}} != "1 2 oncetwice" +. error +.endif + +# The replacement string can contain spaces, thereby changing the number +# of words in the variable expression. +.if ${In:L:%=% ${:Uthe Sun}} != "In the Sun" +. error +.endif + +# If the variable is empty, it is debatable whether it consists of a single +# empty word, or no word at all. The :from=to modifier treats it as no +# word at all. +.if ${:L:=suffix} != "" +. error +.endif + # Before 2020-07-19, an ampersand could be used in the replacement part # of a SysV substitution modifier, and it was replaced with the whole match, # just like in the :S modifier. @@ -87,6 +126,12 @@ . error .endif +# It's also possible to modify each word by replacing the prefix and adding +# a suffix. +.if ${one two:L:o%=a%w} != "anew two" +. error +.endif + # Each word gets the suffix "X" appended. .if ${one two:L:=X} != "oneX twoX" . error @@ -143,6 +188,14 @@ . error .endif +# The :from=to modifier can be used to replace both the prefix and a suffix +# of a word with other strings. This is not possible with a single :S +# modifier, and using a :C modifier for the same task looks more complicated +# in many cases. +.if ${prefix-middle-suffix:L:prefix-%-suffix=p-%-s} != "p-middle-s" +. error +.endif + # As of 2020-10-06, the right-hand side of the SysV modifier is expanded # twice. The first expansion happens in ApplyModifier_SysV, where the # modifier is split into its two parts. The second expansion happens