Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make/unit-tests make(1): add unit tests for parse er...
details: https://anonhg.NetBSD.org/src/rev/a546af994fb8
branches: trunk
changeset: 1012409:a546af994fb8
user: rillig <rillig%NetBSD.org@localhost>
date: Wed Jul 29 18:48:47 2020 +0000
description:
make(1): add unit tests for parse errors in modifiers
diffstat:
usr.bin/make/unit-tests/moderrs.exp | 27 +++++++++++++++++++++++++++
usr.bin/make/unit-tests/moderrs.mk | 22 +++++++++++++++++++++-
usr.bin/make/unit-tests/modmisc.exp | 25 +++++++++++++++++++++++++
usr.bin/make/unit-tests/modmisc.mk | 33 ++++++++++++++++++++++++++++++++-
4 files changed, 105 insertions(+), 2 deletions(-)
diffs (159 lines):
diff -r cb173f030496 -r a546af994fb8 usr.bin/make/unit-tests/moderrs.exp
--- a/usr.bin/make/unit-tests/moderrs.exp Wed Jul 29 14:23:59 2020 +0000
+++ b/usr.bin/make/unit-tests/moderrs.exp Wed Jul 29 18:48:47 2020 +0000
@@ -35,4 +35,31 @@
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
diff -r cb173f030496 -r a546af994fb8 usr.bin/make/unit-tests/moderrs.mk
--- a/usr.bin/make/unit-tests/moderrs.mk Wed Jul 29 14:23:59 2020 +0000
+++ b/usr.bin/make/unit-tests/moderrs.mk Wed Jul 29 18:48:47 2020 +0000
@@ -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: modloop-close
all: modwords
all: modexclam
+all: mod-subst-delimiter
modunkn:
@echo "Expect: Unknown modifier 'Z'"
@@ -79,3 +80,22 @@
# 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,}
diff -r cb173f030496 -r a546af994fb8 usr.bin/make/unit-tests/modmisc.exp
--- a/usr.bin/make/unit-tests/modmisc.exp Wed Jul 29 14:23:59 2020 +0000
+++ b/usr.bin/make/unit-tests/modmisc.exp Wed Jul 29 18:48:47 2020 +0000
@@ -93,4 +93,29 @@
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
diff -r cb173f030496 -r a546af994fb8 usr.bin/make/unit-tests/modmisc.mk
--- a/usr.bin/make/unit-tests/modmisc.mk Wed Jul 29 14:23:59 2020 +0000
+++ b/usr.bin/make/unit-tests/modmisc.mk Wed Jul 29 18:48:47 2020 +0000
@@ -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-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-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
Home |
Main Index |
Thread Index |
Old Index