unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob 862e7016a08b8e6e4fc91919fef4b9668d2f19f3 2462 bytes (raw)
name: test/parse-time-string 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
 
#!/usr/bin/env bash
test_description="date/time parser module"
. ./test-lib.sh

# Sanity/smoke tests for the date/time parser independent of notmuch

_date ()
{
    date -d "$*" +%s
}

_parse_time ()
{
    ${TEST_DIRECTORY}/parse-time --format=%s "$*"
}

test_begin_subtest "date(1) default format without TZ code"
test_expect_equal "$(_parse_time Fri Aug 3 23:06:06 2012)" "$(_date Fri Aug 3 23:06:06 2012)"

test_begin_subtest "date(1) --rfc-2822 format"
test_expect_equal "$(_parse_time Fri, 03 Aug 2012 23:07:46 +0100)" "$(_date Fri, 03 Aug 2012 23:07:46 +0100)"

test_begin_subtest "date(1) --rfc=3339=seconds format"
test_expect_equal "$(_parse_time 2012-08-03 23:09:37+03:00)" "$(_date 2012-08-03 23:09:37+03:00)"

test_begin_subtest "Date parser tests"
REFERENCE=$(_date Tue Jan 11 11:11:00 +0000 2011)
cat <<EOF > INPUT
now          ==> Tue Jan 11 11:11:00 +0000 2011
2010-1-1     ==> ERROR: 5
Jan 2        ==> Sun Jan 02 11:11:00 +0000 2011
Mon          ==> Mon Jan 10 11:11:00 +0000 2011
last Friday  ==> ERROR: 4
2 hours ago  ==> ERROR: 1
last month   ==> Sat Dec 11 11:11:00 +0000 2010
month ago    ==> ERROR: 1
8am          ==> Tue Jan 11 08:00:00 +0000 2011
9:15         ==> Tue Jan 11 09:15:00 +0000 2011
12:34        ==> Tue Jan 11 12:34:00 +0000 2011
monday       ==> Mon Jan 10 11:11:00 +0000 2011
yesterday    ==> Mon Jan 10 11:11:00 +0000 2011
tomorrow     ==> ERROR: 1
             ==> Tue Jan 11 11:11:00 +0000 2011 # empty string is reference time

Aug 3 23:06:06 2012             ==> Fri Aug 03 23:06:06 +0000 2012 # date(1) default format without TZ code
Fri, 03 Aug 2012 23:07:46 +0100 ==> Fri Aug 03 22:07:46 +0000 2012 # rfc-2822
2012-08-03 23:09:37+03:00       ==> Fri Aug 03 20:09:37 +0000 2012 # rfc-3339 seconds

10s           ==> Tue Jan 11 11:10:50 +0000 2011
19701223s     ==> Fri May 28 10:37:17 +0000 2010
19701223      ==> Wed Dec 23 11:11:00 +0000 1970

19701223 +0100 ==> Wed Dec 23 11:11:00 +0000 1970 # Timezone is ignored without an error

today ==^> Tue Jan 11 23:59:59 +0000 2011
today ==_> Tue Jan 11 00:00:00 +0000 2011

thisweek ==^> Sat Jan 15 23:59:59 +0000 2011
thisweek ==_> Sun Jan 09 00:00:00 +0000 2011

two months ago==> ERROR: 1 # "ago" is not supported
two months ==> Thu Nov 11 11:11:00 +0000 2010

@1348569850 ==> Tue Sep 25 10:44:10 +0000 2012
@10 ==> Thu Jan 01 00:00:10 +0000 1970
EOF

${TEST_DIRECTORY}/parse-time --ref=${REFERENCE} < INPUT > OUTPUT
test_expect_equal_file INPUT OUTPUT

test_done

debug log:

solving 862e701 ...
found 862e701 in https://yhetil.org/notmuch/606a94d565e6b21abfc59d6ba9676a807d669127.1350854171.git.jani@nikula.org/ ||
	https://yhetil.org/notmuch/dd436a67ed718e5a29b57a35b951a9f5bb554ebb.1350164594.git.jani@nikula.org/

applying [1/1] https://yhetil.org/notmuch/606a94d565e6b21abfc59d6ba9676a807d669127.1350854171.git.jani@nikula.org/
diff --git a/test/parse-time-string b/test/parse-time-string
new file mode 100755
index 0000000..862e701

Checking patch test/parse-time-string...
Applied patch test/parse-time-string cleanly.

skipping https://yhetil.org/notmuch/dd436a67ed718e5a29b57a35b951a9f5bb554ebb.1350164594.git.jani@nikula.org/ for 862e701
index at:
100755 862e7016a08b8e6e4fc91919fef4b9668d2f19f3	test/parse-time-string

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).