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): align tests for :localtime ...



details:   https://anonhg.NetBSD.org/src/rev/a5bdcbcbf391
branches:  trunk
changeset: 948232:a5bdcbcbf391
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Dec 21 20:47:29 2020 +0000

description:
make(1): align tests for :localtime with those for :gmtime

These tests had been almost the same before, now they are as similar as
possible again.

diffstat:

 usr.bin/make/unit-tests/Makefile             |    5 +-
 usr.bin/make/unit-tests/varmod-gmtime.exp    |   20 +-
 usr.bin/make/unit-tests/varmod-gmtime.mk     |    5 +-
 usr.bin/make/unit-tests/varmod-localtime.exp |   37 ++---
 usr.bin/make/unit-tests/varmod-localtime.mk  |  166 +++++++++++++++++---------
 5 files changed, 134 insertions(+), 99 deletions(-)

diffs (truncated from 311 to 300 lines):

diff -r 7e36e87f7f7f -r a5bdcbcbf391 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Mon Dec 21 20:35:17 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Mon Dec 21 20:47:29 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.255 2020/12/21 20:35:17 rillig Exp $
+# $NetBSD: Makefile,v 1.256 2020/12/21 20:47:29 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -503,9 +503,6 @@
        -e 's,^${.SHELL:T}: [ 0-9:]*,,' \
        -e '/command/s,No such.*,not found,'
 SED_CMDS.vardebug+=    -e 's,${.SHELL},</path/to/shell>,'
-SED_CMDS.varmod-localtime+=    -e 's,Tue Jan 19 04:14:08 2038,<normalized>,'
-SED_CMDS.varmod-localtime+=    ${:D FreeBSD i386 still has 32-bit time_t. }
-SED_CMDS.varmod-localtime+=    -e 's,Fri Dec 13 21:45:52 1901,<normalized>,'
 SED_CMDS.varmod-subst-regex+= \
                        -e 's,\(Regex compilation error:\).*,\1 (details omitted),'
 SED_CMDS.varname-dot-parsedir= -e '/in some cases/ s,^make: "[^"]*,make: "<normalized>,'
diff -r 7e36e87f7f7f -r a5bdcbcbf391 usr.bin/make/unit-tests/varmod-gmtime.exp
--- a/usr.bin/make/unit-tests/varmod-gmtime.exp Mon Dec 21 20:35:17 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-gmtime.exp Mon Dec 21 20:47:29 2020 +0000
@@ -1,18 +1,18 @@
-make: "varmod-gmtime.mk" line 57: Invalid time value: ${:U1593536400}} != "mtime=11593536400}"
+make: "varmod-gmtime.mk" line 60: Invalid time value: ${:U1593536400}} != "mtime=11593536400}"
 
-make: "varmod-gmtime.mk" line 57: Malformed conditional (${%Y:L:gmtime=${:U1593536400}} != "mtime=11593536400}")
-make: "varmod-gmtime.mk" line 67: Invalid time value: -1} != ""
+make: "varmod-gmtime.mk" line 60: Malformed conditional (${%Y:L:gmtime=${:U1593536400}} != "mtime=11593536400}")
+make: "varmod-gmtime.mk" line 70: Invalid time value: -1} != ""
 
-make: "varmod-gmtime.mk" line 67: Malformed conditional (${:L:gmtime=-1} != "")
-make: "varmod-gmtime.mk" line 76: Invalid time value:  1} != ""
+make: "varmod-gmtime.mk" line 70: Malformed conditional (${:L:gmtime=-1} != "")
+make: "varmod-gmtime.mk" line 79: Invalid time value:  1} != ""
 
-make: "varmod-gmtime.mk" line 76: Malformed conditional (${:L:gmtime= 1} != "")
-make: "varmod-gmtime.mk" line 115: Invalid time value: 10000000000000000000000000000000} != ""
+make: "varmod-gmtime.mk" line 79: Malformed conditional (${:L:gmtime= 1} != "")
+make: "varmod-gmtime.mk" line 118: Invalid time value: 10000000000000000000000000000000} != ""
 
-make: "varmod-gmtime.mk" line 115: Malformed conditional (${:L:gmtime=10000000000000000000000000000000} != "")
-make: "varmod-gmtime.mk" line 126: Invalid time value: error} != ""
+make: "varmod-gmtime.mk" line 118: Malformed conditional (${:L:gmtime=10000000000000000000000000000000} != "")
+make: "varmod-gmtime.mk" line 129: Invalid time value: error} != ""
 
-make: "varmod-gmtime.mk" line 126: Malformed conditional (${:L:gmtime=error} != "")
+make: "varmod-gmtime.mk" line 129: Malformed conditional (${:L:gmtime=error} != "")
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
diff -r 7e36e87f7f7f -r a5bdcbcbf391 usr.bin/make/unit-tests/varmod-gmtime.mk
--- a/usr.bin/make/unit-tests/varmod-gmtime.mk  Mon Dec 21 20:35:17 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-gmtime.mk  Mon Dec 21 20:47:29 2020 +0000
@@ -1,8 +1,11 @@
-# $NetBSD: varmod-gmtime.mk,v 1.7 2020/12/21 20:35:17 rillig Exp $
+# $NetBSD: varmod-gmtime.mk,v 1.8 2020/12/21 20:47:29 rillig Exp $
 #
 # Tests for the :gmtime variable modifier, which formats a timestamp
 # using strftime(3) in UTC.
 
+.if ${TZ:Uundefined} != "undefined"    # see unit-tests/Makefile
+.  error
+.endif
 
 # Test for the default time format, %c.  Since the time always varies, it's
 # only possible to check for the general format here.  The names of the
diff -r 7e36e87f7f7f -r a5bdcbcbf391 usr.bin/make/unit-tests/varmod-localtime.exp
--- a/usr.bin/make/unit-tests/varmod-localtime.exp      Mon Dec 21 20:35:17 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-localtime.exp      Mon Dec 21 20:47:29 2020 +0000
@@ -1,27 +1,18 @@
-mod-localtime
-%Y
-2020
-%Y
-gmtime == gmtime
-mod-localtime-indirect:
-make: Invalid time value: ${:U1593536400}}
+make: "varmod-localtime.mk" line 60: Invalid time value: ${:U1593536400}} != "mtime=11593536400}"
 
-ocaltime=1593536400}
-parse-errors:
-make: Invalid time value: -1}.
+make: "varmod-localtime.mk" line 60: Malformed conditional (${%Y:L:localtime=${:U1593536400}} != "mtime=11593536400}")
+make: "varmod-localtime.mk" line 70: Invalid time value: -1} != ""
+
+make: "varmod-localtime.mk" line 70: Malformed conditional (${:L:localtime=-1} != "")
+make: "varmod-localtime.mk" line 79: Invalid time value:  1} != ""
 
-: -1 becomes ocaltime=-1}.
-make: Invalid time value:  1}.
+make: "varmod-localtime.mk" line 79: Malformed conditional (${:L:localtime= 1} != "")
+make: "varmod-localtime.mk" line 118: Invalid time value: 10000000000000000000000000000000} != ""
 
-: space 1 becomes ocaltime= 1}.
-: 0 becomes ok.
-: 1 becomes Thu Jan  1 01:00:01 1970.
-: INT32_MAX becomes Tue Jan 19 04:14:07 2038.
-: INT32_MAX + 1 becomes <normalized>.
-make: Invalid time value: 10000000000000000000000000000000}.
+make: "varmod-localtime.mk" line 118: Malformed conditional (${:L:localtime=10000000000000000000000000000000} != "")
+make: "varmod-localtime.mk" line 129: Invalid time value: error} != ""
 
-: overflow becomes ocaltime=10000000000000000000000000000000}.
-make: Invalid time value: error}.
-
-: letter becomes ocaltime=error}.
-exit status 0
+make: "varmod-localtime.mk" line 129: Malformed conditional (${:L:localtime=error} != "")
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1
diff -r 7e36e87f7f7f -r a5bdcbcbf391 usr.bin/make/unit-tests/varmod-localtime.mk
--- a/usr.bin/make/unit-tests/varmod-localtime.mk       Mon Dec 21 20:35:17 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-localtime.mk       Mon Dec 21 20:47:29 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-localtime.mk,v 1.5 2020/10/31 20:30:06 rillig Exp $
+# $NetBSD: varmod-localtime.mk,v 1.6 2020/12/21 20:47:29 rillig Exp $
 #
 # Tests for the :localtime variable modifier, which formats a timestamp
 # using strftime(3) in local time.
@@ -7,10 +7,6 @@
 .  error
 .endif
 
-all:   mod-localtime
-all:   mod-localtime-indirect
-all:   parse-errors
-
 # Test for the default time format, %c.  Since the time always varies, it's
 # only possible to check for the general format here.  The names of the
 # month and weekday are always in English, independent from the locale.
@@ -19,74 +15,122 @@
 .  error
 .endif
 
-mod-localtime:
-       @echo $@
+
+# modifier name too short, falling back to the SysV modifier.
+.if ${%Y:L:localtim=1593536400} != "%Y"
+.  error
+.endif
 
-       # modifier name too short
-       @echo ${%Y:L:localtim=1593536400}
+
+# 2020-07-01T00:00:00Z
+.if ${%Y:L:localtime=1593536400} != "2020"
+.  error
+.endif
+
 
-       # 2020-07-01T00:00:00Z
-       @echo ${%Y:L:localtime=1593536400}
+# modifier name too long, falling back to the SysV modifier.
+.if ${%Y:L:localtimer=1593536400} != "%Y"
+.  error
+.endif
+
 
-       # modifier name too long
-       @echo ${%Y:L:localtimer=1593536400}
+# If the modifier name is not matched exactly, fall back to the
+# :from=to modifier.
+.if ${gmtime:L:gm%=local%} != "localtime"
+.  error
+.endif
 
-       # If the modifier name is not matched exactly, fall back to the
-       # :from=to modifier.
-       @echo ${localtime:L:local%=gm%} == gmtime
 
-mod-localtime-indirect:
-       @echo $@:
+# As of 2020-08-16, it is not possible to pass the seconds via a
+# variable expression.  This is because parsing of the :localtime
+# modifier stops at the '$' and returns to ApplyModifiers.
+#
+# There, a colon would be skipped but not a dollar.
+# Parsing therefore continues at the '$' of the ${:U159...}, looking
+# for an ordinary variable modifier.
+#
+# At this point, the ${:U} is expanded and interpreted as a variable
+# modifier, which results in the error message "Unknown modifier '1'".
+#
+# If ApplyModifier_Localtime were to pass its argument through
+# ParseModifierPart, this would work.
+#
+# XXX: Where does the empty line 4 in varmod-localtime.exp come from?
+# TODO: Remove the \n from "Invalid time value: %s\n" in var.c.
+.if ${%Y:L:localtime=${:U1593536400}} != "mtime=11593536400}"
+.  error
+.endif
 
-       # As of 2020-08-16, it is not possible to pass the seconds via a
-       # variable expression.  This is because parsing of the :localtime
-       # modifier stops at the '$' and returns to ApplyModifiers.
-       #
-       # There, a colon would be skipped but not a dollar.
-       # Parsing therefore continues at the '$' of the ${:U159...}, looking
-       # for an ordinary variable modifier.
-       #
-       # At this point, the ${:U} is expanded and interpreted as a variable
-       # modifier, which results in the error message "Unknown modifier '1'".
-       #
-       # If ApplyModifier_Localtime were to pass its argument through
-       # ParseModifierPart, this would work.
-       @echo ${%Y:L:localtime=${:U1593536400}}
+
+# Before var.c 1.631 from 2020-10-31 21:40:20, it was possible to pass
+# negative time stamps to the :localtime modifier, resulting in dates before
+# 1970.  Going back 50 years in the past is not a practical use case for
+# make.  Therefore, since var.c 1.631, negative time stamps produce a
+# parse error.
+.if ${:L:localtime=-1} != ""
+.  error
+.else
+.  error
+.endif
+
 
-parse-errors:
-       @echo $@:
+# Spaces were allowed before var.c 1.631, not because it would make sense
+# but just as a side-effect from using strtoul.
+.if ${:L:localtime= 1} != ""
+.  error
+.endif
 
-       # As of 2020-10-31, it is possible to pass negative time stamps
-       # to the :localtime modifier, resulting in dates before 1970.
-       # Going back 50 years in the past is not a practical use case for
-       # make.
-       : -1 becomes ${:L:localtime=-1}.
 
-       # Spaces are allowed, not because it would make sense but just as
-       # a side-effect from using strtoul.
-       : space 1 becomes ${:L:localtime= 1}.
+# 0 means now; this differs from GNode.mtime, where a 0 means nonexistent.
+# Since "now" constantly changes, the strongest possible test is to match the
+# resulting pattern.
+.if !${:L:localtime=0:tW:M??? ??? ?? ??\:??\:?? 20??}
+.  error
+.endif
+
 
-       # 0 means now; to get consistent test results, the actual value has
-       # to be normalized.
-       : 0 becomes ${:L:localtime=0:C,^... ... .. ..:..:.. 20..$,ok,W}.
+.if ${:L:localtime=1} != "Thu Jan  1 01:00:01 1970"
+.  error
+.endif
+
 
-       : 1 becomes ${:L:localtime=1}.
+# INT32_MAX
+.if ${:L:localtime=2147483647} != "Tue Jan 19 04:14:07 2038"
+.  error
+.endif
+
 
-       : INT32_MAX becomes ${:L:localtime=2147483647}.
+.if ${:L:localtime=2147483648} == "Tue Jan 19 04:14:08 2038"
+# All systems that have unsigned time_t or 64-bit time_t.
+.elif ${:L:localtime=2147483648} != "Fri Dec 13 21:45:52 1901"
+# FreeBSD-12.0-i386 still has 32-bit signed time_t.
+.else
+.  error
+.endif
 
-       # This may be different if time_t is still a 32-bit signed integer.
-       : INT32_MAX + 1 becomes ${:L:localtime=2147483648}.
 
-       # Integer overflow.
-       # Because this modifier is implemented using strtoul, the parsed
-       # time is ULONG_MAX, which gets converted to -1.  This results
-       # in a time stamp of the second before 1970 (in UTC) or 3599 seconds
-       # after New Year's Day in Europe/Berlin.
-       : overflow becomes ${:L:localtime=10000000000000000000000000000000}.
+# Integer overflow, at least before var.c 1.631 from 2020-10-31.
+# Because this modifier is implemented using strtoul, the parsed time was
+# ULONG_MAX, which got converted to -1.  This resulted in a time stamp of
+# the second before 1970.
+#
+# Since var.c 1.613, the overflow is detected and produces a parse error.
+.if ${:L:localtime=10000000000000000000000000000000} != ""
+.  error
+.else
+.  error
+.endif
 
-       # As of 2020-10-31, there is no error handling while parsing the
-       # :localtime modifier, thus no error message is printed.  Parsing
-       # stops after the '=', and the remaining string is parsed for
-       # more variable modifiers.  Because of the unknown modifier 'e',
-       # the whole variable value is discarded and thus not printed.
-       : letter becomes ${:L:localtime=error}.
+# Before var.c 1.613 from 2020-10-31, there was no error handling while
+# parsing the :localtime modifier, thus no error message is printed.  Parsing



Home | Main Index | Thread Index | Old Index