Skip to content

Commit efac8ac

Browse files
dschogitster
authored andcommitted
t0006 & t5000: skip "far in the future" test when time_t is too limited
Git's source code refers to timestamps as unsigned long, which is ill-defined, as there is no guarantee about the number of bits that data type has. In preparation of switching to another data type that is large enough to hold "far in the future" dates, we need to prepare the t0006-date.sh script for the case where we *still* cannot format those dates if the system library uses 32-bit time_t. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a07fb05 commit efac8ac

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

t/helper/test-date.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ static const char *usage_msg = "\n"
55
" test-date show:<format> [time_t]...\n"
66
" test-date parse [date]...\n"
77
" test-date approxidate [date]...\n"
8-
" test-date is64bit\n";
8+
" test-date is64bit\n"
9+
" test-date time_t-is64bit\n";
910

1011
static void show_relative_dates(const char **argv, struct timeval *now)
1112
{
@@ -96,6 +97,8 @@ int cmd_main(int argc, const char **argv)
9697
parse_approxidate(argv+1, &now);
9798
else if (!strcmp(*argv, "is64bit"))
9899
return sizeof(unsigned long) == 8 ? 0 : 1;
100+
else if (!strcmp(*argv, "time_t-is64bit"))
101+
return sizeof(time_t) == 8 ? 0 : 1;
99102
else
100103
usage(usage_msg);
101104
return 0;

t/t0006-date.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ check_show unix-local "$TIME" '1466000000'
5353

5454
# arbitrary time absurdly far in the future
5555
FUTURE="5758122296 -0400"
56-
check_show iso "$FUTURE" "2152-06-19 18:24:56 -0400" TIME_IS_64BIT
57-
check_show iso-local "$FUTURE" "2152-06-19 22:24:56 +0000" TIME_IS_64BIT
56+
check_show iso "$FUTURE" "2152-06-19 18:24:56 -0400" TIME_IS_64BIT,TIME_T_IS_64BIT
57+
check_show iso-local "$FUTURE" "2152-06-19 22:24:56 +0000" TIME_IS_64BIT,TIME_T_IS_64BIT
5858

5959
check_parse() {
6060
echo "$1 -> $2" >expect

t/t5000-tar-tree.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ test_expect_success TIME_IS_64BIT 'generate tar with future mtime' '
402402
git archive HEAD >future.tar
403403
'
404404

405-
test_expect_success TAR_HUGE,TIME_IS_64BIT 'system tar can read our future mtime' '
405+
test_expect_success TAR_HUGE,TIME_IS_64BIT,TIME_T_IS_64BIT 'system tar can read our future mtime' '
406406
echo 4147 >expect &&
407407
tar_info future.tar | cut -d" " -f2 >actual &&
408408
test_cmp expect actual

t/test-lib.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,3 +1166,4 @@ test_lazy_prereq LONG_IS_64BIT '
11661166
'
11671167

11681168
test_lazy_prereq TIME_IS_64BIT 'test-date is64bit'
1169+
test_lazy_prereq TIME_T_IS_64BIT 'test-date time_t-is64bit'

0 commit comments

Comments
 (0)