[PATCH] test: Improve tests for the date/time parser module

Michal Sojka sojkam1 at fel.cvut.cz
Thu Oct 4 04:02:28 PDT 2012


On Wed, Oct 03 2012, Jani Nikula wrote:
> On Tue, 25 Sep 2012, Michal Sojka <sojkam1 at fel.cvut.cz> wrote:
>> This patch reworks date/time parser library test program to make it
>> easier to to write the actual tests. It also modifies the notmuch test
>> script and adds several new tests to it.
>

[...]

>>  	case 'n':
>> -	    /* specify now in seconds since epoch */
>> -	    now = (time_t) strtol (optarg, NULL, 10);
>> +	    memset (&tm, 0, sizeof (tm));
>> +	    char *parsed = strptime (optarg, format, &tm);
>
> One of the problems with strptime is that it doesn't support time zones,
> which is why I chose not to use it here. (You can specify %z in the
> format to ignore it, but it looks like it's ignored no matter
> what. *shrug*) Combined with mktime below, you introduce possible TZ and
> DST variations in the tests, which can be problematic. So perhaps we
> should keep the reference time as a timestamp here.

I didn't pay much attention to time zone issues when writing this little
program, so you might be true. But note that test-lib.sh sets TZ=UTC and
I hope that this should eliminate the problems. I think that it is
better to have human understandable values in test scripts.

-Michal


More information about the notmuch mailing list