unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Austin Clements <amdragon@MIT.EDU>
To: Jani Nikula <jani@nikula.org>
Cc: notmuch@notmuchmail.org
Subject: Re: [PATCH v5 4/9] test: add smoke tests for the date/time parser module
Date: Tue, 23 Oct 2012 00:23:26 -0400	[thread overview]
Message-ID: <20121023042326.GP14861@mit.edu> (raw)
In-Reply-To: <606a94d565e6b21abfc59d6ba9676a807d669127.1350854171.git.jani@nikula.org>

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 <sojkam1@fel.cvut.cz> 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 <<EOF > 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.

> +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

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.

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

  reply	other threads:[~2012-10-23  4:23 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-21 21:22 [PATCH v5 0/9] notmuch search date:since..until query support Jani Nikula
2012-10-21 21:22 ` [PATCH v5 1/9] build: drop the -Wswitch-enum warning Jani Nikula
2012-10-21 21:22 ` [PATCH v5 2/9] parse-time-string: add a date/time parser to notmuch Jani Nikula
2012-10-22  8:14   ` Austin Clements
2012-10-25 18:58     ` Austin Clements
2012-10-27 20:38       ` Tomi Ollila
2012-10-28 22:30     ` Jani Nikula
2012-10-28 22:52       ` Austin Clements
2012-10-21 21:22 ` [PATCH v5 3/9] test: add new test tool parse-time for date/time parser Jani Nikula
2012-10-21 21:22 ` [PATCH v5 4/9] test: add smoke tests for the date/time parser module Jani Nikula
2012-10-23  4:23   ` Austin Clements [this message]
2012-10-28 22:34     ` Jani Nikula
2012-10-21 21:22 ` [PATCH v5 5/9] build: build parse-time-string as part of the notmuch lib and static cli Jani Nikula
2012-10-21 21:22 ` [PATCH v5 6/9] lib: add date range query support Jani Nikula
2012-10-23  4:52   ` Austin Clements
2012-10-28 22:39     ` Jani Nikula
2012-10-21 21:22 ` [PATCH v5 7/9] test: add tests for date:since..until range queries Jani Nikula
2012-10-21 21:22 ` [PATCH v5 8/9] man: document the " Jani Nikula
2012-10-24 21:08   ` Austin Clements
2012-10-28 22:41     ` Jani Nikula
2012-10-21 21:22 ` [PATCH v5 9/9] NEWS: date range search support Jani Nikula

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121023042326.GP14861@mit.edu \
    --to=amdragon@mit.edu \
    --cc=jani@nikula.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).