* [PATCH 1/4] test: improve the time parsing tests @ 2015-03-02 17:47 Jani Nikula 2015-03-02 17:47 ` [PATCH 2/4] test: add some more time tests Jani Nikula ` (3 more replies) 0 siblings, 4 replies; 6+ messages in thread From: Jani Nikula @ 2015-03-02 17:47 UTC (permalink / raw) To: notmuch Set the reference time to 12:13:14 instead of 11:11:00 to ensure hours and minutes are not mixed up, and seconds are really set instead of defaulted to 00. --- test/T490-parse-time-string.sh | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/test/T490-parse-time-string.sh b/test/T490-parse-time-string.sh index 8ae0b4c24e15..08a834eb1a80 100755 --- a/test/T490-parse-time-string.sh +++ b/test/T490-parse-time-string.sh @@ -24,38 +24,38 @@ 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) +REFERENCE=$(_date Tue Jan 11 12:13:14 +0000 2011) cat <<EOF > INPUT -now ==> Tue Jan 11 11:11:00 +0000 2011 +now ==> Tue Jan 11 12:13:14 +0000 2011 2010-1-1 ==> ERROR: DATEFORMAT -Jan 2 ==> Sun Jan 02 11:11:00 +0000 2011 -Mon ==> Mon Jan 10 11:11:00 +0000 2011 +Jan 2 ==> Sun Jan 02 12:13:14 +0000 2011 +Mon ==> Mon Jan 10 12:13:14 +0000 2011 last Friday ==> ERROR: FORMAT -2 hours ago ==> Tue Jan 11 09:11:00 +0000 2011 -last month ==> Sat Dec 11 11:11:00 +0000 2010 -month ago ==> Sat Dec 11 11:11:00 +0000 2010 -two mo ==> Thu Nov 11 11:11:00 +0000 2010 -3M ==> Mon Oct 11 11:11:00 +0000 2010 -4-mont ==> Sat Sep 11 11:11:00 +0000 2010 -5m ==> Tue Jan 11 11:06:00 +0000 2011 -dozen mi ==> Tue Jan 11 10:59:00 +0000 2011 +2 hours ago ==> Tue Jan 11 10:13:14 +0000 2011 +last month ==> Sat Dec 11 12:13:14 +0000 2010 +month ago ==> Sat Dec 11 12:13:14 +0000 2010 +two mo ==> Thu Nov 11 12:13:14 +0000 2010 +3M ==> Mon Oct 11 12:13:14 +0000 2010 +4-mont ==> Sat Sep 11 12:13:14 +0000 2010 +5m ==> Tue Jan 11 12:08:14 +0000 2011 +dozen mi ==> Tue Jan 11 12:01:14 +0000 2011 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 +monday ==> Mon Jan 10 12:13:14 +0000 2011 +yesterday ==> Mon Jan 10 12:13:14 +0000 2011 tomorrow ==> ERROR: KEYWORD - ==> Tue Jan 11 11:11:00 +0000 2011 # empty string is reference time + ==> Tue Jan 11 12:13:14 +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 +10s ==> Tue Jan 11 12:13:04 +0000 2011 +19701223s ==> Fri May 28 11:39:31 +0000 2010 +19701223 ==> Wed Dec 23 12:13:14 +0000 1970 -19701223 +0100 ==> Wed Dec 23 11:11:00 +0000 1970 # Timezone is ignored without an error +19701223 +0100 ==> Wed Dec 23 12:13:14 +0000 1970 # Timezone is ignored without an error today ==^^> Wed Jan 12 00:00:00 +0000 2011 today ==^> Tue Jan 11 23:59:59 +0000 2011 @@ -65,8 +65,8 @@ this week ==^^> Sun Jan 16 00:00:00 +0000 2011 this week ==^> Sat Jan 15 23:59:59 +0000 2011 this week ==_> Sun Jan 09 00:00:00 +0000 2011 -two months ago ==> Thu Nov 11 11:11:00 +0000 2010 -two months ==> Thu Nov 11 11:11:00 +0000 2010 +two months ago ==> Thu Nov 11 12:13:14 +0000 2010 +two months ==> Thu Nov 11 12:13:14 +0000 2010 @1348569850 ==> Tue Sep 25 10:44:10 +0000 2012 @10 ==> Thu Jan 01 00:00:10 +0000 1970 -- 2.1.4 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/4] test: add some more time tests 2015-03-02 17:47 [PATCH 1/4] test: improve the time parsing tests Jani Nikula @ 2015-03-02 17:47 ` Jani Nikula 2015-03-02 17:47 ` [PATCH 3/4] test: extract and flag second rounding tests as broken Jani Nikula ` (2 subsequent siblings) 3 siblings, 0 replies; 6+ messages in thread From: Jani Nikula @ 2015-03-02 17:47 UTC (permalink / raw) To: notmuch Ensure the seconds are set properly. --- test/T490-parse-time-string.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/T490-parse-time-string.sh b/test/T490-parse-time-string.sh index 08a834eb1a80..ca3ecb4036ed 100755 --- a/test/T490-parse-time-string.sh +++ b/test/T490-parse-time-string.sh @@ -51,6 +51,11 @@ Aug 3 23:06:06 2012 ==> Fri Aug 03 23:06:06 +0000 2012 # date(1) def 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 +10:30:40 ==> Tue Jan 11 10:30:40 +0000 2011 +10:30:40 ==^> Tue Jan 11 10:30:40 +0000 2011 +10:30:40 ==^^> Tue Jan 11 10:30:40 +0000 2011 +10:30:40 ==_> Tue Jan 11 10:30:40 +0000 2011 + 10s ==> Tue Jan 11 12:13:04 +0000 2011 19701223s ==> Fri May 28 11:39:31 +0000 2010 19701223 ==> Wed Dec 23 12:13:14 +0000 1970 -- 2.1.4 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/4] test: extract and flag second rounding tests as broken 2015-03-02 17:47 [PATCH 1/4] test: improve the time parsing tests Jani Nikula 2015-03-02 17:47 ` [PATCH 2/4] test: add some more time tests Jani Nikula @ 2015-03-02 17:47 ` Jani Nikula 2015-03-02 17:47 ` [PATCH 4/4] parse-time-string: fix setting and rounding of seconds Jani Nikula 2015-03-07 9:27 ` [PATCH 1/4] test: improve the time parsing tests David Bremner 3 siblings, 0 replies; 6+ messages in thread From: Jani Nikula @ 2015-03-02 17:47 UTC (permalink / raw) To: notmuch Extract and add some more tests relating to rounding seconds into a separate subtest, and flag it as broken. If seconds are not specified, the time is not set or rounded according to the interface defined in parse-time-string/parse-time-string.h. Instead, seconds are always set to 00 in reality, which is broken. --- test/T490-parse-time-string.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/T490-parse-time-string.sh b/test/T490-parse-time-string.sh index ca3ecb4036ed..9247bdf89543 100755 --- a/test/T490-parse-time-string.sh +++ b/test/T490-parse-time-string.sh @@ -40,8 +40,6 @@ two mo ==> Thu Nov 11 12:13:14 +0000 2010 5m ==> Tue Jan 11 12:08:14 +0000 2011 dozen mi ==> Tue Jan 11 12:01:14 +0000 2011 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 12:13:14 +0000 2011 yesterday ==> Mon Jan 10 12:13:14 +0000 2011 tomorrow ==> ERROR: KEYWORD @@ -80,4 +78,18 @@ EOF ${TEST_DIRECTORY}/parse-time --ref=${REFERENCE} < INPUT > OUTPUT test_expect_equal_file INPUT OUTPUT +test_begin_subtest "Second rounding tests" +test_subtest_known_broken +REFERENCE=$(_date Tue Jan 11 12:13:14 +0000 2011) +cat <<EOF > INPUT +9:15 ==> Tue Jan 11 09:15:14 +0000 2011 +12:34 ==> Tue Jan 11 12:34:14 +0000 2011 +10:30 ==> Tue Jan 11 10:30:14 +0000 2011 +10:30 ==^> Tue Jan 11 10:30:59 +0000 2011 +10:30 ==^^> Tue Jan 11 10:31:00 +0000 2011 +10:30 ==_> Tue Jan 11 10:30:00 +0000 2011 +EOF +${TEST_DIRECTORY}/parse-time --ref=${REFERENCE} < INPUT > OUTPUT +test_expect_equal_file INPUT OUTPUT + test_done -- 2.1.4 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/4] parse-time-string: fix setting and rounding of seconds 2015-03-02 17:47 [PATCH 1/4] test: improve the time parsing tests Jani Nikula 2015-03-02 17:47 ` [PATCH 2/4] test: add some more time tests Jani Nikula 2015-03-02 17:47 ` [PATCH 3/4] test: extract and flag second rounding tests as broken Jani Nikula @ 2015-03-02 17:47 ` Jani Nikula 2015-03-02 20:03 ` Tomi Ollila 2015-03-07 9:27 ` [PATCH 1/4] test: improve the time parsing tests David Bremner 3 siblings, 1 reply; 6+ messages in thread From: Jani Nikula @ 2015-03-02 17:47 UTC (permalink / raw) To: notmuch If seconds are not specified in the string to be parsed, they're not set according to the reference time (in the no rounding case) nor rounded properly (in the rounding up cases). Fix this. The bug caused searches such as date:10:30..10:30 to match messages with date exactly 10:30:00 only, and not in range 10:30:00..10:30:59 (inclusive) as documented. Note that date searches referring "noon" or "5pm" will still be interpreted as exact to the second. --- parse-time-string/parse-time-string.c | 4 ++-- test/T490-parse-time-string.sh | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/parse-time-string/parse-time-string.c b/parse-time-string/parse-time-string.c index ccad422b3c8d..1cef47d4b0bd 100644 --- a/parse-time-string/parse-time-string.c +++ b/parse-time-string/parse-time-string.c @@ -1081,10 +1081,10 @@ parse_time (struct state *state, char sep, return set_user_tz (state, state->delim, v1, v2); } - if (!is_valid_time (v1, v2, v3)) + if (!is_valid_time (v1, v2, n3 ? v3 : 0)) return -PARSE_TIME_ERR_INVALIDTIME; - return set_abs_time (state, v1, v2, n3 ? v3 : 0); + return set_abs_time (state, v1, v2, n3 ? (int) v3 : UNSET); } /* strtoul helper that assigns length. */ diff --git a/test/T490-parse-time-string.sh b/test/T490-parse-time-string.sh index 9247bdf89543..6aa9d433bfd4 100755 --- a/test/T490-parse-time-string.sh +++ b/test/T490-parse-time-string.sh @@ -79,7 +79,6 @@ ${TEST_DIRECTORY}/parse-time --ref=${REFERENCE} < INPUT > OUTPUT test_expect_equal_file INPUT OUTPUT test_begin_subtest "Second rounding tests" -test_subtest_known_broken REFERENCE=$(_date Tue Jan 11 12:13:14 +0000 2011) cat <<EOF > INPUT 9:15 ==> Tue Jan 11 09:15:14 +0000 2011 -- 2.1.4 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 4/4] parse-time-string: fix setting and rounding of seconds 2015-03-02 17:47 ` [PATCH 4/4] parse-time-string: fix setting and rounding of seconds Jani Nikula @ 2015-03-02 20:03 ` Tomi Ollila 0 siblings, 0 replies; 6+ messages in thread From: Tomi Ollila @ 2015-03-02 20:03 UTC (permalink / raw) To: Jani Nikula, notmuch On Mon, Mar 02 2015, Jani Nikula <jani@nikula.org> wrote: > If seconds are not specified in the string to be parsed, they're not > set according to the reference time (in the no rounding case) nor > rounded properly (in the rounding up cases). Fix this. > > The bug caused searches such as date:10:30..10:30 to match messages > with date exactly 10:30:00 only, and not in range 10:30:00..10:30:59 > (inclusive) as documented. > > Note that date searches referring "noon" or "5pm" will still be > interpreted as exact to the second. Although I don't fully understands how these changes do the trick (and I only looked the context) the changes *look* good, and presumably fix the problem in question (I could check intermediate output but i am just lazy). Tests pass and I don't see why anything could get broken by this so +1 Tomi > --- > parse-time-string/parse-time-string.c | 4 ++-- > test/T490-parse-time-string.sh | 1 - > 2 files changed, 2 insertions(+), 3 deletions(-) > > diff --git a/parse-time-string/parse-time-string.c b/parse-time-string/parse-time-string.c > index ccad422b3c8d..1cef47d4b0bd 100644 > --- a/parse-time-string/parse-time-string.c > +++ b/parse-time-string/parse-time-string.c > @@ -1081,10 +1081,10 @@ parse_time (struct state *state, char sep, > return set_user_tz (state, state->delim, v1, v2); > } > > - if (!is_valid_time (v1, v2, v3)) > + if (!is_valid_time (v1, v2, n3 ? v3 : 0)) > return -PARSE_TIME_ERR_INVALIDTIME; > > - return set_abs_time (state, v1, v2, n3 ? v3 : 0); > + return set_abs_time (state, v1, v2, n3 ? (int) v3 : UNSET); > } > > /* strtoul helper that assigns length. */ > diff --git a/test/T490-parse-time-string.sh b/test/T490-parse-time-string.sh > index 9247bdf89543..6aa9d433bfd4 100755 > --- a/test/T490-parse-time-string.sh > +++ b/test/T490-parse-time-string.sh > @@ -79,7 +79,6 @@ ${TEST_DIRECTORY}/parse-time --ref=${REFERENCE} < INPUT > OUTPUT > test_expect_equal_file INPUT OUTPUT > > test_begin_subtest "Second rounding tests" > -test_subtest_known_broken > REFERENCE=$(_date Tue Jan 11 12:13:14 +0000 2011) > cat <<EOF > INPUT > 9:15 ==> Tue Jan 11 09:15:14 +0000 2011 > -- > 2.1.4 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/4] test: improve the time parsing tests 2015-03-02 17:47 [PATCH 1/4] test: improve the time parsing tests Jani Nikula ` (2 preceding siblings ...) 2015-03-02 17:47 ` [PATCH 4/4] parse-time-string: fix setting and rounding of seconds Jani Nikula @ 2015-03-07 9:27 ` David Bremner 3 siblings, 0 replies; 6+ messages in thread From: David Bremner @ 2015-03-07 9:27 UTC (permalink / raw) To: Jani Nikula, notmuch Jani Nikula <jani@nikula.org> writes: > Set the reference time to 12:13:14 instead of 11:11:00 to ensure hours > and minutes are not mixed up, and seconds are really set instead of > defaulted to 00. Series pushed to master. d ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-03-07 9:29 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-03-02 17:47 [PATCH 1/4] test: improve the time parsing tests Jani Nikula 2015-03-02 17:47 ` [PATCH 2/4] test: add some more time tests Jani Nikula 2015-03-02 17:47 ` [PATCH 3/4] test: extract and flag second rounding tests as broken Jani Nikula 2015-03-02 17:47 ` [PATCH 4/4] parse-time-string: fix setting and rounding of seconds Jani Nikula 2015-03-02 20:03 ` Tomi Ollila 2015-03-07 9:27 ` [PATCH 1/4] test: improve the time parsing tests David Bremner
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).