[Toybox] date test failures

Rob Landley rob at landley.net
Fri Apr 29 18:34:51 PDT 2016


On 03/19/2016 02:44 AM, Andy Chu wrote:
> On the master branch, I'm getting these failures.  The difference is
> "Wed" vs "Sat" in the error message.

So this is still there, but the tests are nonsense:

> # Accidentally given a Unix time, we should trivially reject that.
> testing "Unix time missing @" "TZ=UTC date 1438053157 2>&1" \
>   "date: bad date '1438053157'; Wed February 38 05:31:00 UTC 2057 != Sun Mar 10 05:31:00 UTC 2058\n" "" ""
> # But some invalid dates are more subtle, like Febuary 29th in a non-leap year.
> testing "Feb 29th" "TZ=UTC date 022900001975 2>&1" \
>   "date: bad date '022900001975'; Wed Feb 29 00:00:00 UTC 1975 != Sat Mar  1 00:00:00 UTC 1975\n" "" ""

This is why I don't usually check for specific error messages. For one
thing, none of our date tests work with TEST_HOST. At least SOME of our
tests should, the rest should be marked as such, ala:

  SKIP_HOST=1 testing "test test test"

Here we're checking for too-specific error messages and failing because
various libcs don't agree what day of the week an impossible date would
fall on. The 5th of snozberries is a tuesday, not a thursday. Right.

> I don't really understand what it's trying to tell me though... FYI
> GNU coreutils gives:
> 
> $ date 1438053157
> date: invalid date ‘1438053157’

Would be fine. Ours would be "date: bad date '1438053157'"

And it looks like our error checking logic can be simplified? (Just
mktime, localtime_r, and then strftime it back and do a sting compare.
We've already got that code for the error reporting case, it might be
slightly slower but it's not going to be bigger.)

And while we're at it, bracket if (flag) setenv() and if (flag) clearenv
around the caller lets us collapse to only one caller so we can inline it...

Rob



More information about the Toybox mailing list