peek-travel / cocktail

Elixir date recurrence library based on iCalendar events
https://hexdocs.pm/cocktail
MIT License
222 stars 30 forks source link

Tests fail on a main for Elixir 1.14.3 / OTP 25 #297

Closed davydog187 closed 11 months ago

davydog187 commented 1 year ago

Elixir Version

elixir -v
Erlang/OTP 25 [erts-13.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

Elixir 1.14.3 (compiled with Erlang/OTP 25)

Problem

64 test failures that seem to be causes by Timex.shift/2 adding microsecond precision to each Timex.DateTime

 62) test Every 6 hours on Mondays and Fridays (Cocktail.HourlyTest)
     test/cocktail/hourly_test.exs:90
     Assertion with == failed
     code:  assert times == [
              ~Y"2017-01-02 00:00:00 America/Los_Angeles",
              ~Y"2017-01-02 06:00:00 America/Los_Angeles",
              ~Y"2017-01-02 12:00:00 America/Los_Angeles",
              ~Y"2017-01-02 18:00:00 America/Los_Angeles",
              ~Y"2017-01-06 00:00:00 America/Los_Angeles",
              ~Y"2017-01-06 06:00:00 America/Los_Angeles",
              ~Y"2017-01-06 12:00:00 America/Los_Angeles",
              ~Y"2017-01-06 18:00:00 America/Los_Angeles",
              ~Y"2017-01-09 00:00:00 America/Los_Angeles"
            ]
     left:  [
              #DateTime<2017-01-02 00:00:00-08:00 PST America/Los_Angeles>,
              #DateTime<2017-01-02 06:00:00.000000-08:00 PST America/Los_Angeles>,
              #DateTime<2017-01-02 12:00:00.000000-08:00 PST America/Los_Angeles>,
              #DateTime<2017-01-02 18:00:00.000000-08:00 PST America/Los_Angeles>,
              #DateTime<2017-01-06 00:00:00.000000-08:00 PST America/Los_Angeles>,
              #DateTime<2017-01-06 06:00:00.000000-08:00 PST America/Los_Angeles>,
              #DateTime<2017-01-06 12:00:00.000000-08:00 PST America/Los_Angeles>,
              #DateTime<2017-01-06 18:00:00.000000-08:00 PST America/Los_Angeles>,
              #DateTime<2017-01-09 00:00:00.000000-08:00 PST America/Los_Angeles>
            ]
     right: [
              #DateTime<2017-01-02 00:00:00-08:00 PST America/Los_Angeles>,
              #DateTime<2017-01-02 06:00:00-08:00 PST America/Los_Angeles>,
              #DateTime<2017-01-02 12:00:00-08:00 PST America/Los_Angeles>,
              #DateTime<2017-01-02 18:00:00-08:00 PST America/Los_Angeles>,
              #DateTime<2017-01-06 00:00:00-08:00 PST America/Los_Angeles>,
              #DateTime<2017-01-06 06:00:00-08:00 PST America/Los_Angeles>,
              #DateTime<2017-01-06 12:00:00-08:00 PST America/Los_Angeles>,
              #DateTime<2017-01-06 18:00:00-08:00 PST America/Los_Angeles>,
              #DateTime<2017-01-09 00:00:00-08:00 PST America/Los_Angeles>
            ]
     stacktrace:
       test/cocktail/hourly_test.exs:98: (test)
brianberlin commented 1 year ago

Hey Dave, Thanks for reporting. I took a look this morning and was able to get tests passing on a branch. The issue was related to a change in DateTime in v1.14.3.

From the changelog...

[DateTime] Consistently merge precision of subsecond operations (the bug was that subsecond precision was lost in functions like DateTime.add/3)

I'm hoping to get a pull request up later today.