[PATCH v6 4/9] test: add smoke tests for the date/time parser module
authorJani Nikula <jani@nikula.org>
Tue, 30 Oct 2012 20:32:35 +0000 (22:32 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:50:12 +0000 (09:50 -0800)
65/854d9ecd6b8d03b34ffbf31e9b53d5d1f1dab8 [new file with mode: 0644]

diff --git a/65/854d9ecd6b8d03b34ffbf31e9b53d5d1f1dab8 b/65/854d9ecd6b8d03b34ffbf31e9b53d5d1f1dab8
new file mode 100644 (file)
index 0000000..d0d161f
--- /dev/null
@@ -0,0 +1,178 @@
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 2371F431FC3\r
+       for <notmuch@notmuchmail.org>; Tue, 30 Oct 2012 13:33:17 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id gB3P-EDr--jA for <notmuch@notmuchmail.org>;\r
+       Tue, 30 Oct 2012 13:33:15 -0700 (PDT)\r
+Received: from mail-la0-f53.google.com (mail-la0-f53.google.com\r
+       [209.85.215.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 66E74431FDE\r
+       for <notmuch@notmuchmail.org>; Tue, 30 Oct 2012 13:32:59 -0700 (PDT)\r
+Received: by mail-la0-f53.google.com with SMTP id l5so545085lah.26\r
+       for <notmuch@notmuchmail.org>; Tue, 30 Oct 2012 13:32:58 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=google.com; s=20120113;\r
+       h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references\r
+       :in-reply-to:references:x-gm-message-state;\r
+       bh=XcmelTt3kTmHXgY6Qplsja6gZVfbdI2y0zUaDdl0Q9U=;\r
+       b=J6yuUXwbADCOpzDFXAlFxTxUFz6UdGHbxZ8PfHuphSuZMaPLgpzxCra9v+SxvxWvSQ\r
+       Cw3VyRKb0PNziVQ7rz++NOfkBt1f/6FwCfPkSvi3RwQfunGUqM5+iowCE+TJaankTz1Y\r
+       Ihw8aEa0fdNWWfL+RI5EofBh3I947LXYZoYsWeBPURoJ2baTtDIpKFj8iuKs7gGDjQGT\r
+       mNcEdRQY7JIfpYuKRg88vVu0bQj2nl51EEfcsugzVIH7X+oodPlOq6R7hi8TWTHcjqEP\r
+       OfqoBKL9Z747psoJdPKXBSAlulbeNwCKIP9MDpjCEnEUZUbvn7cBFYNj31uGvhEIvMjh\r
+       0Hlw==\r
+Received: by 10.112.43.193 with SMTP id y1mr13246358lbl.68.1351629178812;\r
+       Tue, 30 Oct 2012 13:32:58 -0700 (PDT)\r
+Received: from localhost (dsl-hkibrasgw4-fe51df00-27.dhcp.inet.fi.\r
+       [80.223.81.27])\r
+       by mx.google.com with ESMTPS id e4sm757048lby.12.2012.10.30.13.32.57\r
+       (version=SSLv3 cipher=OTHER); Tue, 30 Oct 2012 13:32:58 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v6 4/9] test: add smoke tests for the date/time parser module\r
+Date: Tue, 30 Oct 2012 22:32:35 +0200\r
+Message-Id:\r
+ <58d543ef500729892df457544f64eaf3e4db9e44.1351626272.git.jani@nikula.org>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <cover.1351626272.git.jani@nikula.org>\r
+References: <cover.1351626272.git.jani@nikula.org>\r
+In-Reply-To: <cover.1351626272.git.jani@nikula.org>\r
+References: <cover.1351626272.git.jani@nikula.org>\r
+X-Gm-Message-State:\r
+ ALoCoQnKoY3cILljUyuPlciVc2sG8ufWn1UcWt6YamxZG/IWQE/dN1NhoiYHxwxmYu2fGobduVdv\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 30 Oct 2012 20:33:17 -0000\r
+\r
+Test the date/time parser module directly, independent of notmuch,\r
+using the parse-time test tool.\r
+\r
+Credits to Michal Sojka <sojkam1@fel.cvut.cz> for writing most of the\r
+tests.\r
+---\r
+ test/notmuch-test      |    1 +\r
+ test/parse-time-string |   78 ++++++++++++++++++++++++++++++++++++++++++++++++\r
+ 2 files changed, 79 insertions(+)\r
+ create mode 100755 test/parse-time-string\r
+\r
+diff --git a/test/notmuch-test b/test/notmuch-test\r
+index cc732c3..7eadfdf 100755\r
+--- a/test/notmuch-test\r
++++ b/test/notmuch-test\r
+@@ -60,6 +60,7 @@ TESTS="\r
+   emacs-hello\r
+   emacs-show\r
+   missing-headers\r
++  parse-time-string\r
+ "\r
+ TESTS=${NOTMUCH_TESTS:=$TESTS}\r
\r
+diff --git a/test/parse-time-string b/test/parse-time-string\r
+new file mode 100755\r
+index 0000000..8ae0b4c\r
+--- /dev/null\r
++++ b/test/parse-time-string\r
+@@ -0,0 +1,78 @@\r
++#!/usr/bin/env bash\r
++test_description="date/time parser module"\r
++. ./test-lib.sh\r
++\r
++# Sanity/smoke tests for the date/time parser independent of notmuch\r
++\r
++_date ()\r
++{\r
++    date -d "$*" +%s\r
++}\r
++\r
++_parse_time ()\r
++{\r
++    ${TEST_DIRECTORY}/parse-time --format=%s "$*"\r
++}\r
++\r
++test_begin_subtest "date(1) default format without TZ code"\r
++test_expect_equal "$(_parse_time Fri Aug 3 23:06:06 2012)" "$(_date Fri Aug 3 23:06:06 2012)"\r
++\r
++test_begin_subtest "date(1) --rfc-2822 format"\r
++test_expect_equal "$(_parse_time Fri, 03 Aug 2012 23:07:46 +0100)" "$(_date Fri, 03 Aug 2012 23:07:46 +0100)"\r
++\r
++test_begin_subtest "date(1) --rfc=3339=seconds format"\r
++test_expect_equal "$(_parse_time 2012-08-03 23:09:37+03:00)" "$(_date 2012-08-03 23:09:37+03:00)"\r
++\r
++test_begin_subtest "Date parser tests"\r
++REFERENCE=$(_date Tue Jan 11 11:11:00 +0000 2011)\r
++cat <<EOF > INPUT\r
++now          ==> Tue Jan 11 11:11:00 +0000 2011\r
++2010-1-1     ==> ERROR: DATEFORMAT\r
++Jan 2        ==> Sun Jan 02 11:11:00 +0000 2011\r
++Mon          ==> Mon Jan 10 11:11:00 +0000 2011\r
++last Friday  ==> ERROR: FORMAT\r
++2 hours ago  ==> Tue Jan 11 09:11:00 +0000 2011\r
++last month   ==> Sat Dec 11 11:11:00 +0000 2010\r
++month ago    ==> Sat Dec 11 11:11:00 +0000 2010\r
++two mo       ==> Thu Nov 11 11:11:00 +0000 2010\r
++3M           ==> Mon Oct 11 11:11:00 +0000 2010\r
++4-mont       ==> Sat Sep 11 11:11:00 +0000 2010\r
++5m           ==> Tue Jan 11 11:06:00 +0000 2011\r
++dozen mi     ==> Tue Jan 11 10:59:00 +0000 2011\r
++8am          ==> Tue Jan 11 08:00:00 +0000 2011\r
++9:15         ==> Tue Jan 11 09:15:00 +0000 2011\r
++12:34        ==> Tue Jan 11 12:34:00 +0000 2011\r
++monday       ==> Mon Jan 10 11:11:00 +0000 2011\r
++yesterday    ==> Mon Jan 10 11:11:00 +0000 2011\r
++tomorrow     ==> ERROR: KEYWORD\r
++             ==> Tue Jan 11 11:11:00 +0000 2011 # empty string is reference time\r
++\r
++Aug 3 23:06:06 2012             ==> Fri Aug 03 23:06:06 +0000 2012 # date(1) default format without TZ code\r
++Fri, 03 Aug 2012 23:07:46 +0100 ==> Fri Aug 03 22:07:46 +0000 2012 # rfc-2822\r
++2012-08-03 23:09:37+03:00       ==> Fri Aug 03 20:09:37 +0000 2012 # rfc-3339 seconds\r
++\r
++10s           ==> Tue Jan 11 11:10:50 +0000 2011\r
++19701223s     ==> Fri May 28 10:37:17 +0000 2010\r
++19701223      ==> Wed Dec 23 11:11:00 +0000 1970\r
++\r
++19701223 +0100 ==> Wed Dec 23 11:11:00 +0000 1970 # Timezone is ignored without an error\r
++\r
++today ==^^> Wed Jan 12 00:00:00 +0000 2011\r
++today ==^> Tue Jan 11 23:59:59 +0000 2011\r
++today ==_> Tue Jan 11 00:00:00 +0000 2011\r
++\r
++this week ==^^> Sun Jan 16 00:00:00 +0000 2011\r
++this week ==^> Sat Jan 15 23:59:59 +0000 2011\r
++this week ==_> Sun Jan 09 00:00:00 +0000 2011\r
++\r
++two months ago ==> Thu Nov 11 11:11:00 +0000 2010\r
++two months ==> Thu Nov 11 11:11:00 +0000 2010\r
++\r
++@1348569850 ==> Tue Sep 25 10:44:10 +0000 2012\r
++@10 ==> Thu Jan 01 00:00:10 +0000 1970\r
++EOF\r
++\r
++${TEST_DIRECTORY}/parse-time --ref=${REFERENCE} < INPUT > OUTPUT\r
++test_expect_equal_file INPUT OUTPUT\r
++\r
++test_done\r
+-- \r
+1.7.10.4\r
+\r