Skip to content

Commit fdba2cd

Browse files
peffgitster
authored andcommitted
t0006: rename test-date's "show" to "relative"
The "show" tests are really only checking relative formats; we should make that more clear. This also frees up the "show" name to later check other formats. We could later fold "relative" into a more generic "show" command, but it's not worth it. Relative times are a special case already because we have to munge the concept of "now" in our tests. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 50b4a78 commit fdba2cd

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

t/t0006-date.sh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@ test_description='test date parsing and printing'
66
# arbitrary reference time: 2009-08-30 19:20:00
77
TEST_DATE_NOW=1251660000; export TEST_DATE_NOW
88

9-
check_show() {
9+
check_relative() {
1010
t=$(($TEST_DATE_NOW - $1))
1111
echo "$t -> $2" >expect
1212
test_expect_${3:-success} "relative date ($2)" "
13-
test-date show $t >actual &&
13+
test-date relative $t >actual &&
1414
test_i18ncmp expect actual
1515
"
1616
}
1717

18-
check_show 5 '5 seconds ago'
19-
check_show 300 '5 minutes ago'
20-
check_show 18000 '5 hours ago'
21-
check_show 432000 '5 days ago'
22-
check_show 1728000 '3 weeks ago'
23-
check_show 13000000 '5 months ago'
24-
check_show 37500000 '1 year, 2 months ago'
25-
check_show 55188000 '1 year, 9 months ago'
26-
check_show 630000000 '20 years ago'
27-
check_show 31449600 '12 months ago'
28-
check_show 62985600 '2 years ago'
18+
check_relative 5 '5 seconds ago'
19+
check_relative 300 '5 minutes ago'
20+
check_relative 18000 '5 hours ago'
21+
check_relative 432000 '5 days ago'
22+
check_relative 1728000 '3 weeks ago'
23+
check_relative 13000000 '5 months ago'
24+
check_relative 37500000 '1 year, 2 months ago'
25+
check_relative 55188000 '1 year, 9 months ago'
26+
check_relative 630000000 '20 years ago'
27+
check_relative 31449600 '12 months ago'
28+
check_relative 62985600 '2 years ago'
2929

3030
check_parse() {
3131
echo "$1 -> $2" >expect

test-date.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#include "cache.h"
22

33
static const char *usage_msg = "\n"
4-
" test-date show [time_t]...\n"
4+
" test-date relative [time_t]...\n"
55
" test-date parse [date]...\n"
66
" test-date approxidate [date]...\n";
77

8-
static void show_dates(char **argv, struct timeval *now)
8+
static void show_relative_dates(char **argv, struct timeval *now)
99
{
1010
struct strbuf buf = STRBUF_INIT;
1111

@@ -61,8 +61,8 @@ int main(int argc, char **argv)
6161
argv++;
6262
if (!*argv)
6363
usage(usage_msg);
64-
if (!strcmp(*argv, "show"))
65-
show_dates(argv+1, &now);
64+
if (!strcmp(*argv, "relative"))
65+
show_relative_dates(argv+1, &now);
6666
else if (!strcmp(*argv, "parse"))
6767
parse_dates(argv+1, &now);
6868
else if (!strcmp(*argv, "approxidate"))

0 commit comments

Comments
 (0)