A test helper that calls date -j -f works only with BSD date
PitfallVerified 1 Oct 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.
Symptom#
A test passes on macOS and fails on Linux. The helper that turns a timestamp into epoch seconds prints nothing, and the parse of its output then fails.
Cause#
The helper shells out to date -j -f .... Only BSD date on macOS has these flags. GNU date on Linux does not accept them.
Fix#
Do not shell out to date for a constant. Use a fixed constant such as 1_609_459_200, or compute the value in the test language.
Evidence#
Seen in the rgit test suite on 2026-10-01, on an Ubuntu CI runner. The fix is the commit "test: stop shelling out to BSD date for a constant timestamp".