Module Name: src Committed By: rillig Date: Sun Aug 23 14:52:07 UTC 2020
Modified Files: src/usr.bin/make/unit-tests: sysv.exp sysv.mk varmod-sysv.exp varmod-sysv.mk Log Message: make(1): move some of the SysV modifier tests into another file To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/sysv.exp cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/sysv.mk cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/varmod-sysv.exp cvs rdiff -u -r1.2 -r1.3 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/usr.bin/make/unit-tests/sysv.exp diff -u src/usr.bin/make/unit-tests/sysv.exp:1.9 src/usr.bin/make/unit-tests/sysv.exp:1.10 --- src/usr.bin/make/unit-tests/sysv.exp:1.9 Sun Jul 26 11:19:04 2020 +++ src/usr.bin/make/unit-tests/sysv.exp Sun Aug 23 14:52:06 2020 @@ -12,11 +12,4 @@ asam.c.c asam.c a.c.c -ax:Q b c d eb -bcd.e -& -anchor-dollar: value -anchor-dollar: valux -mismatch: file.cpp file.h -mismatch: renamed.c other.c exit status 0 Index: src/usr.bin/make/unit-tests/sysv.mk diff -u src/usr.bin/make/unit-tests/sysv.mk:1.12 src/usr.bin/make/unit-tests/sysv.mk:1.13 --- src/usr.bin/make/unit-tests/sysv.mk:1.12 Sat Aug 1 13:35:13 2020 +++ src/usr.bin/make/unit-tests/sysv.mk Sun Aug 23 14:52:06 2020 @@ -1,7 +1,6 @@ -# $Id: sysv.mk,v 1.12 2020/08/01 13:35:13 rillig Exp $ +# $Id: sysv.mk,v 1.13 2020/08/23 14:52:06 rillig Exp $ -all: foo fun sam bla words ampersand anchor-dollar -all: mismatch +all: foo fun sam bla FOO ?= FOOBAR = ${FOO:=bar} @@ -42,56 +41,3 @@ BLA= bla: @echo $(BLA:%=foo/%x) - -# The :Q looks like a modifier but isn't. -# It is part of the replacement string. -words: - @echo a${a b c d e:L:%a=x:Q}b - -# Before 2020-07-19, an ampersand could be used in the replacement part -# of a SysV substitution modifier. This was probably a copy-and-paste -# mistake since the SysV modifier code looked a lot like the code for the -# :S and :C modifiers. The ampersand is not mentioned in the manual page. -ampersand: - @echo ${:U${a.bcd.e:L:a.%=%}:Q} - @echo ${:U${a.bcd.e:L:a.%=&}:Q} - -# Before 2020-07-20, when a SysV modifier was parsed, a single dollar -# before the '=' was interpreted as an anchor, which doesn't make sense -# since the anchor was discarded immediately. -anchor-dollar: - @echo $@: ${:U${value:L:e$=x}:Q} - @echo $@: ${:U${value:L:e=x}:Q} - -# Words that don't match are copied unmodified. -# The % placeholder can be anywhere in the string. -mismatch: - @echo $@: ${:Ufile.c file.h:%.c=%.cpp} - @echo $@: ${:Ufile.c other.c:file.%=renamed.%} - -# Trying to cover all possible variants of the SysV modifier. -LIST= one two -EXPR.1= ${LIST:o=X} -EXP.1= one twX -EXPR.2= ${LIST:o=} -EXP.2= one tw -EXPR.3= ${LIST:o=%} -EXP.3= one tw% -EXPR.4= ${LIST:%o=X} -EXP.4= one X -EXPR.5= ${LIST:o%=X} -EXP.5= X two -EXPR.6= ${LIST:o%e=X} -EXP.6= X two -EXPR.7= ${LIST:o%%e=X} # Only the first '%' is the wildcard. -EXP.7= one two # None of the words contains a literal '%'. -EXPR.8= ${LIST:%=%%} -EXP.8= one% two% -EXPR.9= ${LIST:%nes=%xxx} # lhs is longer than the word "one" -EXP.9= one two - -.for i in ${:U:range=9} -.if ${EXPR.$i} != ${EXP.$i} -.warning test case $i expected "${EXP.$i}", got "${EXPR.$i} -.endif -.endfor Index: src/usr.bin/make/unit-tests/varmod-sysv.exp diff -u src/usr.bin/make/unit-tests/varmod-sysv.exp:1.1 src/usr.bin/make/unit-tests/varmod-sysv.exp:1.2 --- src/usr.bin/make/unit-tests/varmod-sysv.exp:1.1 Sun Aug 16 12:07:51 2020 +++ src/usr.bin/make/unit-tests/varmod-sysv.exp Sun Aug 23 14:52:06 2020 @@ -1 +1,8 @@ +ax:Q b c d eb +bcd.e +& +anchor-dollar: value +anchor-dollar: valux +mismatch: file.cpp file.h +mismatch: renamed.c other.c exit status 0 Index: src/usr.bin/make/unit-tests/varmod-sysv.mk diff -u src/usr.bin/make/unit-tests/varmod-sysv.mk:1.2 src/usr.bin/make/unit-tests/varmod-sysv.mk:1.3 --- src/usr.bin/make/unit-tests/varmod-sysv.mk:1.2 Sun Aug 16 14:25:16 2020 +++ src/usr.bin/make/unit-tests/varmod-sysv.mk Sun Aug 23 14:52:06 2020 @@ -1,11 +1,61 @@ -# $NetBSD: varmod-sysv.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $ +# $NetBSD: varmod-sysv.mk,v 1.3 2020/08/23 14:52:06 rillig Exp $ # # Tests for the ${VAR:from=to} variable modifier, which replaces the suffix # "from" with "to". It can also use '%' as a wildcard. # # This modifier is applied when the other modifiers don't match exactly. -# TODO: Implementation +all: words ampersand anchor-dollar mismatch -all: - @:; +# The :Q looks like a modifier but isn't. +# It is part of the replacement string. +words: + @echo a${a b c d e:L:%a=x:Q}b + +# Before 2020-07-19, an ampersand could be used in the replacement part +# of a SysV substitution modifier. This was probably a copy-and-paste +# mistake since the SysV modifier code looked a lot like the code for the +# :S and :C modifiers. The ampersand is not mentioned in the manual page. +ampersand: + @echo ${:U${a.bcd.e:L:a.%=%}:Q} + @echo ${:U${a.bcd.e:L:a.%=&}:Q} + +# Before 2020-07-20, when a SysV modifier was parsed, a single dollar +# before the '=' was interpreted as an anchor, which doesn't make sense +# since the anchor was discarded immediately. +anchor-dollar: + @echo $@: ${:U${value:L:e$=x}:Q} + @echo $@: ${:U${value:L:e=x}:Q} + +# Words that don't match are copied unmodified. +# The % placeholder can be anywhere in the string. +mismatch: + @echo $@: ${:Ufile.c file.h:%.c=%.cpp} + @echo $@: ${:Ufile.c other.c:file.%=renamed.%} + +# Trying to cover all possible variants of the SysV modifier. +LIST= one two +EXPR.1= ${LIST:o=X} +EXP.1= one twX +EXPR.2= ${LIST:o=} +EXP.2= one tw +EXPR.3= ${LIST:o=%} +EXP.3= one tw% +EXPR.4= ${LIST:%o=X} +EXP.4= one X +EXPR.5= ${LIST:o%=X} +EXP.5= X two +EXPR.6= ${LIST:o%e=X} +EXP.6= X two +EXPR.7= ${LIST:o%%e=X} # Only the first '%' is the wildcard. +EXP.7= one two # None of the words contains a literal '%'. +EXPR.8= ${LIST:%=%%} +EXP.8= one% two% +EXPR.9= ${LIST:%nes=%xxx} # lhs is longer than the word "one" +EXP.9= one two + +.for i in ${:U:range=9} +.if ${EXPR.$i} != ${EXP.$i} +.warning test case $i expected "${EXP.$i}", got "${EXPR.$i} +.endif +.endfor