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 test for the :gmtime mo...



details:   https://anonhg.NetBSD.org/src/rev/3a4079e7a8cb
branches:  trunk
changeset: 936889:3a4079e7a8cb
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Aug 08 13:09:55 2020 +0000

description:
make(1): add test for the :gmtime modifier with indirect time

diffstat:

 usr.bin/make/unit-tests/modmisc.exp |   3 +++
 usr.bin/make/unit-tests/modmisc.mk  |  13 ++++++++++++-
 2 files changed, 15 insertions(+), 1 deletions(-)

diffs (47 lines):

diff -r c654f81bdba6 -r 3a4079e7a8cb usr.bin/make/unit-tests/modmisc.exp
--- a/usr.bin/make/unit-tests/modmisc.exp       Sat Aug 08 13:05:24 2020 +0000
+++ b/usr.bin/make/unit-tests/modmisc.exp       Sat Aug 08 13:09:55 2020 +0000
@@ -107,6 +107,9 @@
 2020
 %Y
 %Y
+mod-gmtime-indirect:
+make: Unknown modifier '1'
+
 mod-localtime:
 %Y
 2020
diff -r c654f81bdba6 -r 3a4079e7a8cb usr.bin/make/unit-tests/modmisc.mk
--- a/usr.bin/make/unit-tests/modmisc.mk        Sat Aug 08 13:05:24 2020 +0000
+++ b/usr.bin/make/unit-tests/modmisc.mk        Sat Aug 08 13:09:55 2020 +0000
@@ -1,4 +1,4 @@
-# $Id: modmisc.mk,v 1.35 2020/08/08 13:03:13 rillig Exp $
+# $Id: modmisc.mk,v 1.36 2020/08/08 13:09:55 rillig Exp $
 #
 # miscellaneous modifier tests
 
@@ -30,6 +30,7 @@
 all:   mod-break-many-words
 all:   mod-remember
 all:   mod-gmtime
+all:   mod-gmtime-indirect
 all:   mod-localtime
 all:   mod-hash
 all:   mod-range
@@ -295,6 +296,16 @@
        @echo ${%Y:L:gmtimer=1593536400}        # modifier name too long
        @echo ${%Y:L:gm=gm:M*}
 
+mod-gmtime-indirect:
+       @echo $@:
+       # It's not possible to pass the seconds via a variable expression.
+       # Parsing of the :gmtime modifier stops at the '$' and returns to
+       # ApplyModifiers.  There, a colon would be skipped but not a dollar.
+       # Parsing continues by looking at the next modifier.  Now the ${:U}
+       # is expanded and interpreted as a variable modifier, which results
+       # in the error message "Unknown modifier '1'".
+       @echo ${%Y:L:gmtime=${:U1593536400}}
+
 mod-localtime:
        @echo $@:
        @echo ${%Y:L:localtim=1593536400}       # modifier name too short



Home | Main Index | Thread Index | Old Index