Sat Oct 31 19:55:26 2020 UTC ()
make(1): add test for :gmtime with space before the number of seconds


(rillig)
diff -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-gmtime.exp
diff -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-gmtime.mk

cvs diff -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-gmtime.exp (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/varmod-gmtime.exp 2020/10/31 19:48:23 1.3
+++ src/usr.bin/make/unit-tests/varmod-gmtime.exp 2020/10/31 19:55:26 1.4
@@ -1,18 +1,19 @@ @@ -1,18 +1,19 @@
1mod-gmtime: 1mod-gmtime:
2%Y 2%Y
32020 32020
4%Y 4%Y
5%Y 5%Y
6mod-gmtime-indirect: 6mod-gmtime-indirect:
7make: Unknown modifier '1' 7make: Unknown modifier '1'
8 8
9parse-errors: 9parse-errors:
10: -1 becomes Wed Dec 31 23:59:59 1969. 10: -1 becomes Wed Dec 31 23:59:59 1969.
 11: space 1 becomes Thu Jan 1 00:00:01 1970.
11: 0 becomes ok. 12: 0 becomes ok.
12: 1 becomes Thu Jan 1 00:00:01 1970. 13: 1 becomes Thu Jan 1 00:00:01 1970.
13: INT32_MAX becomes Tue Jan 19 03:14:07 2038. 14: INT32_MAX becomes Tue Jan 19 03:14:07 2038.
14: INT32_MAX + 1 becomes Tue Jan 19 03:14:08 2038. 15: INT32_MAX + 1 becomes Tue Jan 19 03:14:08 2038.
15: overflow becomes Wed Dec 31 23:59:59 1969. 16: overflow becomes Wed Dec 31 23:59:59 1969.
16make: Unknown modifier 'e' 17make: Unknown modifier 'e'
17: letter becomes . 18: letter becomes .
18exit status 0 19exit status 0

cvs diff -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-gmtime.mk (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/varmod-gmtime.mk 2020/10/31 19:48:23 1.4
+++ src/usr.bin/make/unit-tests/varmod-gmtime.mk 2020/10/31 19:55:26 1.5
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: varmod-gmtime.mk,v 1.4 2020/10/31 19:48:23 rillig Exp $ 1# $NetBSD: varmod-gmtime.mk,v 1.5 2020/10/31 19:55:26 rillig Exp $
2# 2#
3# Tests for the :gmtime variable modifier, which formats a timestamp 3# Tests for the :gmtime variable modifier, which formats a timestamp
4# using strftime(3). 4# using strftime(3).
5 5
6all: mod-gmtime 6all: mod-gmtime
7all: mod-gmtime-indirect 7all: mod-gmtime-indirect
8all: parse-errors 8all: parse-errors
9 9
10# Test for the default time format, %c. Since the time always varies, it's 10# Test for the default time format, %c. Since the time always varies, it's
11# only possible to check for the general format here. The names of the 11# only possible to check for the general format here. The names of the
12# month and weekday are always in English, independent from the locale. 12# month and weekday are always in English, independent from the locale.
13# Example: Thu Oct 29 18:56:41 2020 13# Example: Thu Oct 29 18:56:41 2020
14.if ${:U:gmtime:tW:M??? ??? ?? ??\:??\:?? ????} == "" 14.if ${:U:gmtime:tW:M??? ??? ?? ??\:??\:?? ????} == ""
@@ -39,26 +39,30 @@ mod-gmtime-indirect: @@ -39,26 +39,30 @@ mod-gmtime-indirect:
39 # If ApplyModifier_Gmtime were to pass its argument through 39 # If ApplyModifier_Gmtime were to pass its argument through
40 # ParseModifierPart, this would work. 40 # ParseModifierPart, this would work.
41 @echo ${%Y:L:gmtime=${:U1593536400}} 41 @echo ${%Y:L:gmtime=${:U1593536400}}
42 42
43parse-errors: 43parse-errors:
44 @echo $@: 44 @echo $@:
45 45
46 # As of 2020-10-31, it is possible to pass negative time stamps 46 # As of 2020-10-31, it is possible to pass negative time stamps
47 # to the :gmtime modifier, resulting in dates before 1970. 47 # to the :gmtime modifier, resulting in dates before 1970.
48 # Going back 50 years in the past is not a practical use case for 48 # Going back 50 years in the past is not a practical use case for
49 # make. 49 # make.
50 : -1 becomes ${:L:gmtime=-1}. 50 : -1 becomes ${:L:gmtime=-1}.
51 51
 52 # Spaces are allowed, not because it would make sense but just as
 53 # a side-effect from using strtoul.
 54 : space 1 becomes ${:L:gmtime= 1}.
 55
52 # 0 means now; to get consistent test results, the actual value has 56 # 0 means now; to get consistent test results, the actual value has
53 # to be normalized. 57 # to be normalized.
54 : 0 becomes ${:L:gmtime=0:C,^... ... .. ..:..:.. 20..$,ok,W}. 58 : 0 becomes ${:L:gmtime=0:C,^... ... .. ..:..:.. 20..$,ok,W}.
55 59
56 : 1 becomes ${:L:gmtime=1}. 60 : 1 becomes ${:L:gmtime=1}.
57 61
58 : INT32_MAX becomes ${:L:gmtime=2147483647}. 62 : INT32_MAX becomes ${:L:gmtime=2147483647}.
59 63
60 # This may be different if time_t is still a 32-bit signed integer. 64 # This may be different if time_t is still a 32-bit signed integer.
61 : INT32_MAX + 1 becomes ${:L:gmtime=2147483648}. 65 : INT32_MAX + 1 becomes ${:L:gmtime=2147483648}.
62 66
63 # Integer overflow. 67 # Integer overflow.
64 # Because this modifier is implemented using strtoul, the parsed 68 # Because this modifier is implemented using strtoul, the parsed