l3nz / cli-matic

Compact, hands-free [sub]command line parsing library for Clojure.
Eclipse Public License 2.0
365 stars 29 forks source link

Make test-dates test timezone independent #87

Closed lread closed 5 years ago

lread commented 5 years ago

First, thanks so much for this library, I find it very useful! I was about to investigate another issue when I noticed that lein test failed on my development computer.

version

0.3.11

platform

> java -version
openjdk version "11.0.5" 2019-10-15 LTS
OpenJDK Runtime Environment Corretto-11.0.5.10.1 (build 11.0.5+10-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.5.10.1 (build 11.0.5+10-LTS, mixed mode)

on macOS current timezone: Eastern Standard Time

problem

cli-matic.presets-test/test-dates fails on my development computer.

repro

> lein test

lein test cli-matic.core-test

lein test cli-matic.help-gen-test

lein test cli-matic.presets-test

lein test :only cli-matic.presets-test/test-dates

FAIL in (test-dates) (presets_test.cljc:240)
YYYY-MM-DD suck
expected: (= (parse-cmds-simpler ["foo" "--val" "2018-01-01"] (mkDummyCfg {:option "val", :as "x", :type :yyyy-mm-dd})) {:commandline {:_arguments [], :val #inst "2017-12-31T23:00:00.000-00:00"}, :error-text "", :parse-errors :NONE})
  actual: (not (= {:commandline {:val #inst "2018-01-01T05:00:00.000-00:00", :_arguments []}, :parse-errors :NONE, :error-text ""} {:commandline {:_arguments [], :val #inst "2017-12-31T23:00:00.000-00:00"}, :error-text "", :parse-errors :NONE}))

expected behavior

Test should pass in any timezone

actual behavior

Test fails in my timezone, and I assume all timezones other than CEST, given the comment in the code:

      ; this works (CEST)

action

I've looked into using cljc.java-time for a timezone independent test-dates. I will follow up with a PR for your review.