Try to fix flaky timestamp tests (#153)
* Try to fix flaky timestamp tests
There seems to be an underlying Dart issue that causes access and
modification times to files to sometimes be 1 second before the
Adjust `package:file`'s access and modification time tests to
tolerate this. Previously they verified that the access and
modification times always were within a 1 second interval, starting
from the current second and ending at the next second. This change
adjusts the interval to start at the previous second and end at the
current time rounded up to the nearest second. This means that the
interval will be 1 second if the current time happens to be an exact
second or will be up to 2 seconds otherwise.
With this change, I've run one of the modification time tests in a
continuous loop for 10s (>300K iterations) without failure.
Bonus: Make some additional changes related to time handling:
* Change `ceil()` to be a mathematical ceiling. Previously if the
current time happened to be an exact second, `ceil()` would return
the next second, which is a bit misleading.
* Change `expect(before, isSameOrBefore(timestamp))` to
`expect(timestamp, isSameOrAfter(before))` since we're verifying
that the timestamp is correct, not that the `before` reference time
is. Otherwise output from a test failure mixes up the notion of
"Actual" and "Expected" values.
* Update CHANGELOG.md
4 files changed