Module Name: src Committed By: rillig Date: Wed Jul 29 18:48:47 UTC 2020
Modified Files: src/usr.bin/make/unit-tests: moderrs.exp moderrs.mk modmisc.exp modmisc.mk Log Message: make(1): add unit tests for parse errors in modifiers To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/moderrs.mk cvs rdiff -u -r1.30 -r1.31 src/usr.bin/make/unit-tests/modmisc.exp cvs rdiff -u -r1.27 -r1.28 src/usr.bin/make/unit-tests/modmisc.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/moderrs.exp diff -u src/usr.bin/make/unit-tests/moderrs.exp:1.6 src/usr.bin/make/unit-tests/moderrs.exp:1.7 --- src/usr.bin/make/unit-tests/moderrs.exp:1.6 Tue Jul 28 00:13:29 2020 +++ src/usr.bin/make/unit-tests/moderrs.exp Wed Jul 29 18:48:47 2020 @@ -35,4 +35,31 @@ make: Unclosed substitution for VARNAME make: Unclosed substitution for ! (! missing) +mod-subst-delimiter: +make: Unclosed substitution for VAR (@ missing) + +make: Unclosed substitution for VAR (, missing) + +make: Unclosed substitution for VAR (, missing) + +make: Unclosed substitution for VAR (, missing) + +make: Unclosed substitution for VAR (, missing) + +make: Unclosed variable specification (expecting '}') for "VAR" (value "TheVariable") modifier S +TheVariable +TheVariable +make: Unclosed variable specification (expecting '}') for "VAR" (value "TheVariable") modifier S +1: TheVariable +make: Unclosed substitution for VAR (, missing) +2: +make: Unclosed substitution for VAR (, missing) +3: +make: Unclosed substitution for VAR (, missing) + +make: Unclosed substitution for VAR (, missing) + +make: Unclosed variable specification (expecting '}') for "VAR" (value "TheVariable") modifier S +TheVariable +TheVariable exit status 0 Index: src/usr.bin/make/unit-tests/moderrs.mk diff -u src/usr.bin/make/unit-tests/moderrs.mk:1.5 src/usr.bin/make/unit-tests/moderrs.mk:1.6 --- src/usr.bin/make/unit-tests/moderrs.mk:1.5 Tue Jul 28 00:13:29 2020 +++ src/usr.bin/make/unit-tests/moderrs.mk Wed Jul 29 18:48:47 2020 @@ -1,4 +1,4 @@ -# $Id: moderrs.mk,v 1.5 2020/07/28 00:13:29 rillig Exp $ +# $Id: moderrs.mk,v 1.6 2020/07/29 18:48:47 rillig Exp $ # # various modifier error tests @@ -12,6 +12,7 @@ all: modunkn modunknV varterm vartermV m all: modloop-close all: modwords all: modexclam +all: mod-subst-delimiter modunkn: @echo "Expect: Unknown modifier 'Z'" @@ -79,3 +80,22 @@ modexclam: # If there were a fallback, the output would be "exclam", # and the above would have produced an "Unknown modifier '!'". @echo ${!:L:!=exclam} + +# XXX: For "${VAR:S", I wonder where the "(@ missing)" comes from. +# This could be undefined behavior, but it's reproducible. +mod-subst-delimiter: + @echo $@: + @echo ${VAR:S + @echo ${VAR:S, + @echo ${VAR:S,from + @echo ${VAR:S,from, + @echo ${VAR:S,from,to + @echo ${VAR:S,from,to, + @echo ${VAR:S,from,to,} + @echo 1: ${VAR:S + @echo 2: ${VAR:S, + @echo 3: ${VAR:S,from + @echo ${VAR:S,from, + @echo ${VAR:S,from,to + @echo ${VAR:S,from,to, + @echo ${VAR:S,from,to,} Index: src/usr.bin/make/unit-tests/modmisc.exp diff -u src/usr.bin/make/unit-tests/modmisc.exp:1.30 src/usr.bin/make/unit-tests/modmisc.exp:1.31 --- src/usr.bin/make/unit-tests/modmisc.exp:1.30 Mon Jul 27 21:54:25 2020 +++ src/usr.bin/make/unit-tests/modmisc.exp Wed Jul 29 18:48:47 2020 @@ -93,4 +93,29 @@ line mod-break-many-words: 500 mod-remember: 1 2 3 1 2 3 1 2 3 mod-remember: 1 2 3, SAVED=3 +mod-gmtime: +%Y +2020 +%Y +mod-localtime: +%Y +2020 +%Y +mod-hash: +make: Unknown modifier 'h' + +26bb0f5f +12345 +make: Unknown modifier 'h' + +make: Unknown modifier 'h' + +mod-range: +make: Unknown modifier 'r' + +1 2 3 +make: Unknown modifier 'r' + +make: Unknown modifier 'r' + exit status 0 Index: src/usr.bin/make/unit-tests/modmisc.mk diff -u src/usr.bin/make/unit-tests/modmisc.mk:1.27 src/usr.bin/make/unit-tests/modmisc.mk:1.28 --- src/usr.bin/make/unit-tests/modmisc.mk:1.27 Mon Jul 27 21:54:25 2020 +++ src/usr.bin/make/unit-tests/modmisc.mk Wed Jul 29 18:48:47 2020 @@ -1,4 +1,4 @@ -# $Id: modmisc.mk,v 1.27 2020/07/27 21:54:25 rillig Exp $ +# $Id: modmisc.mk,v 1.28 2020/07/29 18:48:47 rillig Exp $ # # miscellaneous modifier tests @@ -28,6 +28,10 @@ all: mod-tu-space all: mod-quote all: mod-break-many-words all: mod-remember +all: mod-gmtime +all: mod-localtime +all: mod-hash +all: mod-range # See also sysv.mk. modsysv: @@ -251,3 +255,30 @@ mod-break-many-words: mod-remember: @echo $@: ${1 2 3:L:_:@var@${_}@} @echo $@: ${1 2 3:L:@var@${var:_=SAVED:}@}, SAVED=${SAVED} + +mod-gmtime: + @echo $@: + @echo ${%Y:L:gmtim=1593536400} # modifier name too short + @echo ${%Y:L:gmtime=1593536400} # 2020-07-01T00:00:00Z + @echo ${%Y:L:gmtimer=1593536400} # modifier name too long + +mod-localtime: + @echo $@: + @echo ${%Y:L:localtim=1593536400} # modifier name too short + @echo ${%Y:L:localtime=1593536400} # 2020-07-01T00:00:00Z + @echo ${%Y:L:localtimer=1593536400} # modifier name too long + +mod-hash: + @echo $@: + @echo ${12345:L:has} # modifier name too short + @echo ${12345:L:hash} # ok + @echo ${12345:L:hash=SHA-256} # :hash does not accept '=' + @echo ${12345:L:hasX} # misspelled + @echo ${12345:L:hashed} # modifier name too long + +mod-range: + @echo $@: + @echo ${a b c:L:rang} # modifier name too short + @echo ${a b c:L:range} # ok + @echo ${a b c:L:rango} # misspelled + @echo ${a b c:L:ranger} # modifier name too long