julia
e33b31bc - Improve robustness in Dates/conversions test (#49086)

Commit
2 years ago
Improve robustness in Dates/conversions test (#49086) * Improve robustness in Dates/conversions test In [1], this test was observed to fail, with a 1 second pause between the two Dates.now calls. In general, particularly on high-load CI systems, we cannot make assumptions that calls will complete within any particular amount of time. Instead, we should be asserting properties that should be universally true. This test wants to assert that Dates.now() and Dates.now(UTC) give the same answer if the TZ environment variable is set appropriately, but of course we can't guarantee that these calls run at the same time. Rather than setting an arbitrary limit of 1 second, just run `Dates.now` again. Our semantics guarantee ordering of these calls (in the absence of leap days/seconds at least), so the test is more robust. [1] https://buildkite.com/julialang/julia-master/builds/22064#0186ff11-f07e-4ba4-9b54-21bdf738d35e * now: Consistently truncate DateTime rather than rounding The operating system clock provides the current time in microseconds, but `DateTime` has milisecond precision. The question is what rounding to apply. `now` was using truncation, while `now(UTC)` was using rounding. I think truncation is probably the better default, since you're often interested in whether a particular `DateTime` has passed, so change `now(UTC)` to trucate as well.
Author
Parents
Loading