bats-core icon indicating copy to clipboard operation
bats-core copied to clipboard

get_mills_since_epoch() broken on freebsd

Open mmetc opened this issue 3 years ago • 1 comments

Describe the bug

FreeBSD's date command does not support the %N option to get milli-micro-nanoseconds. All timings for tests are rounded to a second.

To Reproduce

Run tests, see times reported as [0] [1000] [2000] instead of [234] [1550] [2349]

Environment (please complete the following information):

Any version of freebsd.

Additional context

By installing the "coreutils" package and using gdate instead of date, the times are reported correctly.

On freebsd, $(date +%N) = "N", and in this case, we may want to call gdate if available.

mmetc avatar Jun 21 '22 21:06 mmetc

I think we should rely on $EPOCHREALTIME when available and fall back to (g)date if necessary.

martin-schulze-vireso avatar Jun 21 '22 21:06 martin-schulze-vireso