diff options
| author | sjg <sjg@NetBSD.org> | 2006-05-11 15:37:07 +0000 |
|---|---|---|
| committer | sjg <sjg@NetBSD.org> | 2006-05-11 15:37:07 +0000 |
| commit | 03cbcf6532e8656e0bc4bc53feaa8e593e42e14d (patch) | |
| tree | 812dfe26961e12b6af2a6cff5809aa382332a8f9 /usr.bin/make/unit-tests | |
| parent | 6daaa2e383ede7eab11f4f90169c2e2e204b6b4d (diff) | |
Extract the variable modifier logic to a separate function.
This cuts Var_Parse in half! and allows the modifier logic to
be used recursively - when getting modifiers via variables.
Add new unit-test, to check that certain error cases are handled
correctly.
Diffstat (limited to 'usr.bin/make/unit-tests')
| -rw-r--r-- | usr.bin/make/unit-tests/Makefile | 3 | ||||
| -rw-r--r-- | usr.bin/make/unit-tests/moderrs | 36 | ||||
| -rw-r--r-- | usr.bin/make/unit-tests/modmisc | 19 | ||||
| -rw-r--r-- | usr.bin/make/unit-tests/test.exp | 23 |
4 files changed, 78 insertions, 3 deletions
diff --git a/usr.bin/make/unit-tests/Makefile b/usr.bin/make/unit-tests/Makefile index ef05c8a7027..928892022c9 100644 --- a/usr.bin/make/unit-tests/Makefile +++ b/usr.bin/make/unit-tests/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.19 2006/02/26 22:45:46 apb Exp $ +# $NetBSD: Makefile,v 1.20 2006/05/11 15:37:07 sjg Exp $ # # Unit tests for make(1) # The main targets are: @@ -22,6 +22,7 @@ SUBFILES= \ comment \ cond1 \ dotwait \ + moderrs \ modmatch \ modmisc \ modorder \ diff --git a/usr.bin/make/unit-tests/moderrs b/usr.bin/make/unit-tests/moderrs new file mode 100644 index 00000000000..e8292e70c23 --- /dev/null +++ b/usr.bin/make/unit-tests/moderrs @@ -0,0 +1,36 @@ +# $Id: moderrs,v 1.1 2006/05/11 15:37:07 sjg Exp $ +# +# various modifier error tests + +VAR=TheVariable +# incase we have to change it ;-) +MOD_UNKN=Z +MOD_TERM=S,V,v +MOD_S:= ${MOD_TERM}, + +all: modunkn modunknV varterm vartermV modterm modtermV + +modunkn: + @echo "Expect: Unknown modifier 'Z'" + @echo "VAR:Z=${VAR:Z}" + +modunknV: + @echo "Expect: Unknown modifier 'Z'" + @echo "VAR:${MOD_UNKN}=${VAR:${MOD_UNKN}}" + +varterm: + @echo "Expect: Unclosed variable specification for VAR" + @echo VAR:S,V,v,=${VAR:S,V,v, + +vartermV: + @echo "Expect: Unclosed variable specification for VAR" + @echo VAR:${MOD_TERM},=${VAR:${MOD_S} + +modterm: + @echo "Expect: Unclosed substitution for VAR (, missing)" + @echo "and: Syntax error: Unterminated quoted string" + -@echo "VAR:S,V,v=${VAR:S,V,v}" + +modtermV: + @echo "Expect: Unclosed substitution for VAR (, missing)" + -@echo "VAR:${MOD_TERM}=${VAR:${MOD_TERM}}" diff --git a/usr.bin/make/unit-tests/modmisc b/usr.bin/make/unit-tests/modmisc index bc66711bb73..11f22eaed5a 100644 --- a/usr.bin/make/unit-tests/modmisc +++ b/usr.bin/make/unit-tests/modmisc @@ -1,4 +1,4 @@ -# $Id: modmisc,v 1.3 2006/02/26 22:40:50 wiz Exp $ +# $Id: modmisc,v 1.4 2006/05/11 15:37:07 sjg Exp $ # # miscellaneous modifier tests @@ -8,11 +8,26 @@ MOD_NODOT=S/:/ /g:N.:ts: # and decorate, note that $'s need to be doubled. Also note that # the modifier_variable can be used with other modifiers. MOD_NODOTX=S/:/ /g:N.:@d@'$$d'@ +# another mod - pretend it is more interesting +MOD_HOMES=S,/home/,/homes/, +MOD_OPT=@d@$${exists($$d):?$$d:$${d:S,/usr,/opt,}}@ +MOD_SEP=S,:, ,g -all: modvar +all: modvar modvarloop modvar: @echo "path='${path}'" @echo "path='${path:${MOD_NODOT}}'" @echo "path='${path:S,home,homes,:${MOD_NODOT}}'" @echo "path=${path:${MOD_NODOTX}:ts:}" + @echo "path=${path:${MOD_HOMES}:${MOD_NODOTX}:ts:}" + +.for d in ${path:${MOD_SEP}:N.} /usr/xbin +path_$d?= ${d:${MOD_OPT}:${MOD_HOMES}}/ +paths+= ${d:${MOD_OPT}:${MOD_HOMES}} +.endfor + +modvarloop: + @echo "path_/usr/xbin=${path_/usr/xbin}" + @echo "paths=${paths}" + @echo "PATHS=${paths:tu}" diff --git a/usr.bin/make/unit-tests/test.exp b/usr.bin/make/unit-tests/test.exp index be5e203c326..84223d850fe 100644 --- a/usr.bin/make/unit-tests/test.exp +++ b/usr.bin/make/unit-tests/test.exp @@ -49,6 +49,25 @@ make: Graph cycles through `cycle.2.98' make: Graph cycles through `cycle.2.97' cycle.1.99 cycle.1.99 +Expect: Unknown modifier 'Z' +make: Unknown modifier 'Z' +VAR:Z= +Expect: Unknown modifier 'Z' +make: Unknown modifier 'Z' +VAR:Z= +Expect: Unclosed variable specification for VAR +make: Unclosed variable specification for VAR +VAR:S,V,v,=Thevariable +Expect: Unclosed variable specification for VAR +VAR:S,V,v,=Thevariable +Expect: Unclosed substitution for VAR (, missing) +and: Syntax error: Unterminated quoted string +make: Unclosed substitution for VAR (, missing) +Syntax error: Unterminated quoted string +Expect: Unclosed substitution for VAR (, missing) +make: Unclosed substitution for VAR (, missing) +VAR:S,V,v= +*** Error code 2 (ignored) LIB=a X_LIBS:M${LIB${LIB:tu}} is "/tmp/liba.a" LIB=a X_LIBS:M*/lib${LIB}.a is "/tmp/liba.a" LIB=a X_LIBS:M*/lib${LIB}.a:tu is "/TMP/LIBA.A" @@ -68,6 +87,10 @@ path=':/bin:/usr/bin::/sbin:/usr/sbin:.:/home/user/bin:.' path='/bin:/usr/bin:/sbin:/usr/sbin:/home/user/bin' path='/bin:/usr/bin:/sbin:/usr/sbin:/homes/user/bin' path='/bin':'/usr/bin':'/sbin':'/usr/sbin':'/home/user/bin' +path='/bin':'/usr/bin':'/sbin':'/usr/sbin':'/homes/user/bin' +path_/usr/xbin=/opt/xbin/ +paths=/bin /usr/bin /sbin /usr/sbin /homes/user/bin /opt/xbin +PATHS=/BIN /USR/BIN /SBIN /USR/SBIN /HOMES/USER/BIN /OPT/XBIN LIST = one two three four five six seven eigth nine ten LIST:O = eigth five four nine one seven six ten three two # Note that 1 in every 10! trials two independently generated |
