1 Return-Path: <jani@nikula.org>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 2371F431FC3
\r
6 for <notmuch@notmuchmail.org>; Tue, 30 Oct 2012 13:33:17 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"
\r
12 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
13 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id gB3P-EDr--jA for <notmuch@notmuchmail.org>;
\r
17 Tue, 30 Oct 2012 13:33:15 -0700 (PDT)
\r
18 Received: from mail-la0-f53.google.com (mail-la0-f53.google.com
\r
19 [209.85.215.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 66E74431FDE
\r
22 for <notmuch@notmuchmail.org>; Tue, 30 Oct 2012 13:32:59 -0700 (PDT)
\r
23 Received: by mail-la0-f53.google.com with SMTP id l5so545085lah.26
\r
24 for <notmuch@notmuchmail.org>; Tue, 30 Oct 2012 13:32:58 -0700 (PDT)
\r
25 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
26 d=google.com; s=20120113;
\r
27 h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references
\r
28 :in-reply-to:references:x-gm-message-state;
\r
29 bh=XcmelTt3kTmHXgY6Qplsja6gZVfbdI2y0zUaDdl0Q9U=;
\r
30 b=J6yuUXwbADCOpzDFXAlFxTxUFz6UdGHbxZ8PfHuphSuZMaPLgpzxCra9v+SxvxWvSQ
\r
31 Cw3VyRKb0PNziVQ7rz++NOfkBt1f/6FwCfPkSvi3RwQfunGUqM5+iowCE+TJaankTz1Y
\r
32 Ihw8aEa0fdNWWfL+RI5EofBh3I947LXYZoYsWeBPURoJ2baTtDIpKFj8iuKs7gGDjQGT
\r
33 mNcEdRQY7JIfpYuKRg88vVu0bQj2nl51EEfcsugzVIH7X+oodPlOq6R7hi8TWTHcjqEP
\r
34 OfqoBKL9Z747psoJdPKXBSAlulbeNwCKIP9MDpjCEnEUZUbvn7cBFYNj31uGvhEIvMjh
\r
36 Received: by 10.112.43.193 with SMTP id y1mr13246358lbl.68.1351629178812;
\r
37 Tue, 30 Oct 2012 13:32:58 -0700 (PDT)
\r
38 Received: from localhost (dsl-hkibrasgw4-fe51df00-27.dhcp.inet.fi.
\r
40 by mx.google.com with ESMTPS id e4sm757048lby.12.2012.10.30.13.32.57
\r
41 (version=SSLv3 cipher=OTHER); Tue, 30 Oct 2012 13:32:58 -0700 (PDT)
\r
42 From: Jani Nikula <jani@nikula.org>
\r
43 To: notmuch@notmuchmail.org
\r
44 Subject: [PATCH v6 4/9] test: add smoke tests for the date/time parser module
\r
45 Date: Tue, 30 Oct 2012 22:32:35 +0200
\r
47 <58d543ef500729892df457544f64eaf3e4db9e44.1351626272.git.jani@nikula.org>
\r
48 X-Mailer: git-send-email 1.7.10.4
\r
49 In-Reply-To: <cover.1351626272.git.jani@nikula.org>
\r
50 References: <cover.1351626272.git.jani@nikula.org>
\r
51 In-Reply-To: <cover.1351626272.git.jani@nikula.org>
\r
52 References: <cover.1351626272.git.jani@nikula.org>
\r
54 ALoCoQnKoY3cILljUyuPlciVc2sG8ufWn1UcWt6YamxZG/IWQE/dN1NhoiYHxwxmYu2fGobduVdv
\r
55 X-BeenThere: notmuch@notmuchmail.org
\r
56 X-Mailman-Version: 2.1.13
\r
58 List-Id: "Use and development of the notmuch mail system."
\r
59 <notmuch.notmuchmail.org>
\r
60 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
61 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
62 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
63 List-Post: <mailto:notmuch@notmuchmail.org>
\r
64 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
65 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
66 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
67 X-List-Received-Date: Tue, 30 Oct 2012 20:33:17 -0000
\r
69 Test the date/time parser module directly, independent of notmuch,
\r
70 using the parse-time test tool.
\r
72 Credits to Michal Sojka <sojkam1@fel.cvut.cz> for writing most of the
\r
75 test/notmuch-test | 1 +
\r
76 test/parse-time-string | 78 ++++++++++++++++++++++++++++++++++++++++++++++++
\r
77 2 files changed, 79 insertions(+)
\r
78 create mode 100755 test/parse-time-string
\r
80 diff --git a/test/notmuch-test b/test/notmuch-test
\r
81 index cc732c3..7eadfdf 100755
\r
82 --- a/test/notmuch-test
\r
83 +++ b/test/notmuch-test
\r
84 @@ -60,6 +60,7 @@ TESTS="
\r
90 TESTS=${NOTMUCH_TESTS:=$TESTS}
\r
92 diff --git a/test/parse-time-string b/test/parse-time-string
\r
93 new file mode 100755
\r
94 index 0000000..8ae0b4c
\r
96 +++ b/test/parse-time-string
\r
98 +#!/usr/bin/env bash
\r
99 +test_description="date/time parser module"
\r
102 +# Sanity/smoke tests for the date/time parser independent of notmuch
\r
111 + ${TEST_DIRECTORY}/parse-time --format=%s "$*"
\r
114 +test_begin_subtest "date(1) default format without TZ code"
\r
115 +test_expect_equal "$(_parse_time Fri Aug 3 23:06:06 2012)" "$(_date Fri Aug 3 23:06:06 2012)"
\r
117 +test_begin_subtest "date(1) --rfc-2822 format"
\r
118 +test_expect_equal "$(_parse_time Fri, 03 Aug 2012 23:07:46 +0100)" "$(_date Fri, 03 Aug 2012 23:07:46 +0100)"
\r
120 +test_begin_subtest "date(1) --rfc=3339=seconds format"
\r
121 +test_expect_equal "$(_parse_time 2012-08-03 23:09:37+03:00)" "$(_date 2012-08-03 23:09:37+03:00)"
\r
123 +test_begin_subtest "Date parser tests"
\r
124 +REFERENCE=$(_date Tue Jan 11 11:11:00 +0000 2011)
\r
126 +now ==> Tue Jan 11 11:11:00 +0000 2011
\r
127 +2010-1-1 ==> ERROR: DATEFORMAT
\r
128 +Jan 2 ==> Sun Jan 02 11:11:00 +0000 2011
\r
129 +Mon ==> Mon Jan 10 11:11:00 +0000 2011
\r
130 +last Friday ==> ERROR: FORMAT
\r
131 +2 hours ago ==> Tue Jan 11 09:11:00 +0000 2011
\r
132 +last month ==> Sat Dec 11 11:11:00 +0000 2010
\r
133 +month ago ==> Sat Dec 11 11:11:00 +0000 2010
\r
134 +two mo ==> Thu Nov 11 11:11:00 +0000 2010
\r
135 +3M ==> Mon Oct 11 11:11:00 +0000 2010
\r
136 +4-mont ==> Sat Sep 11 11:11:00 +0000 2010
\r
137 +5m ==> Tue Jan 11 11:06:00 +0000 2011
\r
138 +dozen mi ==> Tue Jan 11 10:59:00 +0000 2011
\r
139 +8am ==> Tue Jan 11 08:00:00 +0000 2011
\r
140 +9:15 ==> Tue Jan 11 09:15:00 +0000 2011
\r
141 +12:34 ==> Tue Jan 11 12:34:00 +0000 2011
\r
142 +monday ==> Mon Jan 10 11:11:00 +0000 2011
\r
143 +yesterday ==> Mon Jan 10 11:11:00 +0000 2011
\r
144 +tomorrow ==> ERROR: KEYWORD
\r
145 + ==> Tue Jan 11 11:11:00 +0000 2011 # empty string is reference time
\r
147 +Aug 3 23:06:06 2012 ==> Fri Aug 03 23:06:06 +0000 2012 # date(1) default format without TZ code
\r
148 +Fri, 03 Aug 2012 23:07:46 +0100 ==> Fri Aug 03 22:07:46 +0000 2012 # rfc-2822
\r
149 +2012-08-03 23:09:37+03:00 ==> Fri Aug 03 20:09:37 +0000 2012 # rfc-3339 seconds
\r
151 +10s ==> Tue Jan 11 11:10:50 +0000 2011
\r
152 +19701223s ==> Fri May 28 10:37:17 +0000 2010
\r
153 +19701223 ==> Wed Dec 23 11:11:00 +0000 1970
\r
155 +19701223 +0100 ==> Wed Dec 23 11:11:00 +0000 1970 # Timezone is ignored without an error
\r
157 +today ==^^> Wed Jan 12 00:00:00 +0000 2011
\r
158 +today ==^> Tue Jan 11 23:59:59 +0000 2011
\r
159 +today ==_> Tue Jan 11 00:00:00 +0000 2011
\r
161 +this week ==^^> Sun Jan 16 00:00:00 +0000 2011
\r
162 +this week ==^> Sat Jan 15 23:59:59 +0000 2011
\r
163 +this week ==_> Sun Jan 09 00:00:00 +0000 2011
\r
165 +two months ago ==> Thu Nov 11 11:11:00 +0000 2010
\r
166 +two months ==> Thu Nov 11 11:11:00 +0000 2010
\r
168 +@1348569850 ==> Tue Sep 25 10:44:10 +0000 2012
\r
169 +@10 ==> Thu Jan 01 00:00:10 +0000 1970
\r
172 +${TEST_DIRECTORY}/parse-time --ref=${REFERENCE} < INPUT > OUTPUT
\r
173 +test_expect_equal_file INPUT OUTPUT
\r