t/helper: merge test-date into test-tool
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
e499894443
commit
a801a7cfc7
2
Makefile
2
Makefile
@ -655,10 +655,10 @@ PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))
|
|||||||
TEST_BUILTINS_OBJS += test-chmtime.o
|
TEST_BUILTINS_OBJS += test-chmtime.o
|
||||||
TEST_BUILTINS_OBJS += test-config.o
|
TEST_BUILTINS_OBJS += test-config.o
|
||||||
TEST_BUILTINS_OBJS += test-ctype.o
|
TEST_BUILTINS_OBJS += test-ctype.o
|
||||||
|
TEST_BUILTINS_OBJS += test-date.o
|
||||||
TEST_BUILTINS_OBJS += test-lazy-init-name-hash.o
|
TEST_BUILTINS_OBJS += test-lazy-init-name-hash.o
|
||||||
TEST_BUILTINS_OBJS += test-sha1.o
|
TEST_BUILTINS_OBJS += test-sha1.o
|
||||||
|
|
||||||
TEST_PROGRAMS_NEED_X += test-date
|
|
||||||
TEST_PROGRAMS_NEED_X += test-delta
|
TEST_PROGRAMS_NEED_X += test-delta
|
||||||
TEST_PROGRAMS_NEED_X += test-drop-caches
|
TEST_PROGRAMS_NEED_X += test-drop-caches
|
||||||
TEST_PROGRAMS_NEED_X += test-dump-cache-tree
|
TEST_PROGRAMS_NEED_X += test-dump-cache-tree
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
|
#include "test-tool.h"
|
||||||
#include "cache.h"
|
#include "cache.h"
|
||||||
|
|
||||||
static const char *usage_msg = "\n"
|
static const char *usage_msg = "\n"
|
||||||
" test-date relative [time_t]...\n"
|
" test-tool date relative [time_t]...\n"
|
||||||
" test-date show:<format> [time_t]...\n"
|
" test-tool date show:<format> [time_t]...\n"
|
||||||
" test-date parse [date]...\n"
|
" test-tool date parse [date]...\n"
|
||||||
" test-date approxidate [date]...\n"
|
" test-tool date approxidate [date]...\n"
|
||||||
" test-date timestamp [date]...\n"
|
" test-tool date timestamp [date]...\n"
|
||||||
" test-date is64bit\n"
|
" test-tool date is64bit\n"
|
||||||
" test-date time_t-is64bit\n";
|
" test-tool date time_t-is64bit\n";
|
||||||
|
|
||||||
static void show_relative_dates(const char **argv, struct timeval *now)
|
static void show_relative_dates(const char **argv, struct timeval *now)
|
||||||
{
|
{
|
||||||
@ -81,7 +82,7 @@ static void parse_approx_timestamp(const char **argv, struct timeval *now)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int cmd_main(int argc, const char **argv)
|
int cmd__date(int argc, const char **argv)
|
||||||
{
|
{
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
const char *x;
|
const char *x;
|
||||||
|
@ -10,6 +10,7 @@ static struct test_cmd cmds[] = {
|
|||||||
{ "chmtime", cmd__chmtime },
|
{ "chmtime", cmd__chmtime },
|
||||||
{ "config", cmd__config },
|
{ "config", cmd__config },
|
||||||
{ "ctype", cmd__ctype },
|
{ "ctype", cmd__ctype },
|
||||||
|
{ "date", cmd__date },
|
||||||
{ "lazy-init-name-hash", cmd__lazy_init_name_hash },
|
{ "lazy-init-name-hash", cmd__lazy_init_name_hash },
|
||||||
{ "sha1", cmd__sha1 },
|
{ "sha1", cmd__sha1 },
|
||||||
};
|
};
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
int cmd__chmtime(int argc, const char **argv);
|
int cmd__chmtime(int argc, const char **argv);
|
||||||
int cmd__config(int argc, const char **argv);
|
int cmd__config(int argc, const char **argv);
|
||||||
int cmd__ctype(int argc, const char **argv);
|
int cmd__ctype(int argc, const char **argv);
|
||||||
|
int cmd__date(int argc, const char **argv);
|
||||||
int cmd__lazy_init_name_hash(int argc, const char **argv);
|
int cmd__lazy_init_name_hash(int argc, const char **argv);
|
||||||
int cmd__sha1(int argc, const char **argv);
|
int cmd__sha1(int argc, const char **argv);
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ check_relative() {
|
|||||||
t=$(($TEST_DATE_NOW - $1))
|
t=$(($TEST_DATE_NOW - $1))
|
||||||
echo "$t -> $2" >expect
|
echo "$t -> $2" >expect
|
||||||
test_expect_${3:-success} "relative date ($2)" "
|
test_expect_${3:-success} "relative date ($2)" "
|
||||||
test-date relative $t >actual &&
|
test-tool date relative $t >actual &&
|
||||||
test_i18ncmp expect actual
|
test_i18ncmp expect actual
|
||||||
"
|
"
|
||||||
}
|
}
|
||||||
@ -35,7 +35,7 @@ check_show () {
|
|||||||
zone=$5
|
zone=$5
|
||||||
test_expect_success $prereqs "show date ($format:$time)" '
|
test_expect_success $prereqs "show date ($format:$time)" '
|
||||||
echo "$time -> $expect" >expect &&
|
echo "$time -> $expect" >expect &&
|
||||||
TZ=${zone:-$TZ} test-date show:"$format" "$time" >actual &&
|
TZ=${zone:-$TZ} test-tool date show:"$format" "$time" >actual &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ check_show iso-local "$FUTURE" "2152-06-19 22:24:56 +0000" TIME_IS_64BIT,TIME_T_
|
|||||||
check_parse() {
|
check_parse() {
|
||||||
echo "$1 -> $2" >expect
|
echo "$1 -> $2" >expect
|
||||||
test_expect_${4:-success} "parse date ($1${3:+ TZ=$3})" "
|
test_expect_${4:-success} "parse date ($1${3:+ TZ=$3})" "
|
||||||
TZ=${3:-$TZ} test-date parse '$1' >actual &&
|
TZ=${3:-$TZ} test-tool date parse '$1' >actual &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
"
|
"
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ check_parse '2008-02-14 20:30:45' '2008-02-14 20:30:45 -0500' EST5
|
|||||||
check_approxidate() {
|
check_approxidate() {
|
||||||
echo "$1 -> $2 +0000" >expect
|
echo "$1 -> $2 +0000" >expect
|
||||||
test_expect_${3:-success} "parse approxidate ($1)" "
|
test_expect_${3:-success} "parse approxidate ($1)" "
|
||||||
test-date approxidate '$1' >actual &&
|
test-tool date approxidate '$1' >actual &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
"
|
"
|
||||||
}
|
}
|
||||||
|
@ -914,7 +914,7 @@ test_expect_success 'get --expiry-date' '
|
|||||||
invalid1 = "abc"
|
invalid1 = "abc"
|
||||||
EOF
|
EOF
|
||||||
cat >expect <<-EOF &&
|
cat >expect <<-EOF &&
|
||||||
$(test-date timestamp $rel)
|
$(test-tool date timestamp $rel)
|
||||||
1275666415
|
1275666415
|
||||||
1510441871
|
1510441871
|
||||||
1510348087
|
1510348087
|
||||||
|
@ -1206,5 +1206,5 @@ test_lazy_prereq LONG_IS_64BIT '
|
|||||||
test 8 -le "$(build_option sizeof-long)"
|
test 8 -le "$(build_option sizeof-long)"
|
||||||
'
|
'
|
||||||
|
|
||||||
test_lazy_prereq TIME_IS_64BIT 'test-date is64bit'
|
test_lazy_prereq TIME_IS_64BIT 'test-tool date is64bit'
|
||||||
test_lazy_prereq TIME_T_IS_64BIT 'test-date time_t-is64bit'
|
test_lazy_prereq TIME_T_IS_64BIT 'test-tool date time_t-is64bit'
|
||||||
|
Loading…
Reference in New Issue
Block a user