Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 0EA76431FBC for ; Sun, 28 Oct 2012 15:34:59 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bR1QhupAFDpB for ; Sun, 28 Oct 2012 15:34:57 -0700 (PDT) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com [209.85.217.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 1E19C431FAF for ; Sun, 28 Oct 2012 15:34:56 -0700 (PDT) Received: by mail-lb0-f181.google.com with SMTP id gg6so3131151lbb.26 for ; Sun, 28 Oct 2012 15:34:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-type:x-gm-message-state; bh=BVgN90h2ni5HkjZWbOm1nxgUx+V/A16IJ4bDY97knYk=; b=pvGfpC35iSU2xWrw0hGlYmEJTpxCgyGnXpGB+V/av83xTzm7m0VJmV4yoZt7nOHvtY 1OI8rsD6Q+U6/xYOOV+Tx91wUhf8EhMjUtBWJ4CmCDY5s6ta5sG3bvH3N2z22IdLzKkD 81TUWelWwvHa58U9H/RB/2o6d3KkiooupBGOv0QBkBQAI87r31n8MTp9XAuzAjTz6VGJ Zu3RJsa3zthwBz/uUc3d7jQdJZkW8eDbpVp9LUzv3Vc1hV/OhmJmkGMgeyYk92W5HlJ3 Qf6xPVPbpQ8GEQKnQz9d1aZkX1YZte0hp6gZYIcKvB6NY4WQcHmjNkdzKK3B2rCJqXTo qvAA== Received: by 10.112.36.42 with SMTP id n10mr11261456lbj.42.1351463695575; Sun, 28 Oct 2012 15:34:55 -0700 (PDT) Received: from localhost (dsl-hkibrasgw4-fe51df00-27.dhcp.inet.fi. [80.223.81.27]) by mx.google.com with ESMTPS id g5sm2558418lbk.7.2012.10.28.15.34.52 (version=SSLv3 cipher=OTHER); Sun, 28 Oct 2012 15:34:53 -0700 (PDT) From: Jani Nikula To: Austin Clements Subject: Re: [PATCH v5 4/9] test: add smoke tests for the date/time parser module In-Reply-To: <20121023042326.GP14861@mit.edu> References: <606a94d565e6b21abfc59d6ba9676a807d669127.1350854171.git.jani@nikula.org> <20121023042326.GP14861@mit.edu> User-Agent: Notmuch/0.14+46~g272a1f1 (http://notmuchmail.org) Emacs/23.4.1 (i686-pc-linux-gnu) Date: Mon, 29 Oct 2012 00:34:51 +0200 Message-ID: <87ip9ukyyc.fsf@nikula.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Gm-Message-State: ALoCoQn6DL5ZexPSiH/LuUEYcbvgJD3ct3SI88UPEoaIBtqCPEzPzfbMZXWQq9PRHJzUBYNO3Rk7 Cc: notmuch@notmuchmail.org X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Oct 2012 22:34:59 -0000 On Tue, 23 Oct 2012, Austin Clements wrote: > Quoth Jani Nikula on Oct 22 at 12:22 am: >> Test the date/time parser module directly, independent of notmuch, >> using the parse-time test tool. >> >> Credits to Michal Sojka for writing most of the >> tests. >> --- >> test/notmuch-test | 1 + >> test/parse-time-string | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ >> 2 files changed, 72 insertions(+) >> create mode 100755 test/parse-time-string >> >> diff --git a/test/notmuch-test b/test/notmuch-test >> index cc732c3..7eadfdf 100755 >> --- a/test/notmuch-test >> +++ b/test/notmuch-test >> @@ -60,6 +60,7 @@ TESTS=" >> emacs-hello >> emacs-show >> missing-headers >> + parse-time-string >> " >> TESTS=${NOTMUCH_TESTS:=$TESTS} >> >> diff --git a/test/parse-time-string b/test/parse-time-string >> new file mode 100755 >> index 0000000..862e701 >> --- /dev/null >> +++ b/test/parse-time-string >> @@ -0,0 +1,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 < INPUT >> +now ==> Tue Jan 11 11:11:00 +0000 2011 >> +2010-1-1 ==> ERROR: 5 > > It would be nice if these errors were strings. I have no idea if "5" > is the right error for this. Good idea. Will fix. >> +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 I'll silently eat away "ago" too. >> +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 > > Very nice. The only thing that jumps out at me is that there are no > ==^^> tests, though it would be interesting to run a code coverage > tool to see how thorough these tests are. Again, most of the credit here goes to Michal Sojka. Will add some ==^^> tests too. BR, Jani. > >> +EOF >> + >> +${TEST_DIRECTORY}/parse-time --ref=${REFERENCE} < INPUT > OUTPUT >> +test_expect_equal_file INPUT OUTPUT >> + >> +test_done