[Toybox] [PATCH] date: more test cleanup.

Rob Landley rob at landley.net
Thu Feb 14 04:53:04 PST 2019


On 2/13/19 12:05 AM, enh via Toybox wrote:
> Add the SKIP_HOST=1 for the POSIX inputs to -d that coreutils doesn't support.
> 
> Fix some comments now Rob's pointed out that the "weird" format was just
> POSIX with implicit CCYY or CC. (I was confused because coreutils rejects
> them [as it rejects all POSIX input to -d], but busybox does accept them,
> but interprets them differently, as explained in the test comments.)
> 
> Also rename the tests to make it clearer that these are all POSIX format.

Poking at date some more, the first test failure:

-Sun Jun  2 12:34:00 UTC 1900
+Thu Jun  2 12:34:00 GMT 2019

June 2 1900 was a Saturday, not a sunday. Sunday is just "0" because all the
fields we haven't set are zeroed. I have to wash it through
localtime(mktime(tm)) to get the weekday right. (Except localtime is
GRATUITOUSLY STUPIDLY DESIGNED so it can't do that, but you know what I mean.)

I can set the year to the current one ala $(date +%Y) but it's racy (could
change between fetch and the real test; unlikely but possible). And even if I do
that, the day of the week moves each year, so I have to fetch _that_ too (%a)
and that's significantly more likely to move out from under you in regression
testing.

And _then_ the problem is:

-Sun Jun  2 12:34:00 UTC 2019
+Sun Jun  2 13:34:00 BST 2019

British Summer Time. Because daylight savings time is a different time zone? Who
designed this garbage?

Ok, US/Arizona timezone, no daylight savings time... and the racy %a fetch is
fetching _today's_ weekday and not the one for June 2. And nontrivial uses of it
are basically just comparing the date output against _itself_ which may not
prove anything...

Grrr. This isn't "testing ps" levels of nailing jello to the wall, but it's up
there.

Rob



More information about the Toybox mailing list