Skip to content

Commit a59275d

Browse files
committed
t0006: simplify prerequisites
The system must support 64-bit time and its time_t must be 64-bit wide to pass these tests. Combine these two prerequisites together to simplify the tests. In theory, they could be fulfilled independently and tests could require only one without the other, but in practice, these must come hand-in-hand. Update the "check_parse" test helper to pay attention to the REQUIRE_64BIT_TIME variable, which can be set to the HAVE_64BIT_TIME prerequisite so that a parse test can be skipped on 32-bit systems. This will be used in the next step to skip tests for timestamps near the end of year 2099, as 32-bit systems will not be able to express a timestamp beyond 2038 anyway. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 786a3e4 commit a59275d

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

t/t0006-date.sh

+12-6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ TEST_PASSES_SANITIZE_LEAK=true
88
# arbitrary reference time: 2009-08-30 19:20:00
99
GIT_TEST_DATE_NOW=1251660000; export GIT_TEST_DATE_NOW
1010

11+
if test_have_prereq TIME_IS_64BIT,TIME_T_IS_64BIT
12+
then
13+
test_set_prereq HAVE_64BIT_TIME
14+
fi
15+
1116
check_relative() {
1217
t=$(($GIT_TEST_DATE_NOW - $1))
1318
echo "$t -> $2" >expect
@@ -80,14 +85,15 @@ check_show raw "$TIME" '1466000000 -0200'
8085

8186
# arbitrary time absurdly far in the future
8287
FUTURE="5758122296 -0400"
83-
check_show iso "$FUTURE" "2152-06-19 18:24:56 -0400" TIME_IS_64BIT,TIME_T_IS_64BIT
84-
check_show iso-local "$FUTURE" "2152-06-19 22:24:56 +0000" TIME_IS_64BIT,TIME_T_IS_64BIT
88+
check_show iso "$FUTURE" "2152-06-19 18:24:56 -0400" HAVE_64BIT_TIME
89+
check_show iso-local "$FUTURE" "2152-06-19 22:24:56 +0000" HAVE_64BIT_TIME
8590

86-
check_parse() {
91+
REQUIRE_64BIT_TIME=
92+
check_parse () {
8793
echo "$1 -> $2" >expect
88-
test_expect_${4:-success} "parse date ($1${3:+ TZ=$3})" "
89-
TZ=${3:-$TZ} test-tool date parse '$1' >actual &&
90-
test_cmp expect actual
94+
test_expect_success $REQUIRE_64BIT_TIME "parse date ($1${3:+ TZ=$3}) -> $2" "
95+
TZ=${3:-$TZ} test-tool date parse '$1' >actual &&
96+
test_cmp expect actual
9197
"
9298
}
9399

0 commit comments

Comments
 (0)