Ray's Knowledge Base
Unlock

Never assert an exact relative age like 0s in tests; parse the value's shape

PitfallVerified 13 Oct 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

An integration test asserting an exact relative age (rgit's 0s) fails when run through rvow prove or on a loaded machine but passes right after a local run.

Cause#

The value depends on how long ago the fixture commit was made. The gap between git commit and the assertion crosses a 1-second boundary, so 0s becomes 1s (or 2s).

Fix#

Parse the cells instead of matching a literal: split the row on the field separator and assert the shape (digits + s suffix) rather than the exact value, e.g. cells[2].strip_suffix('s').is_some_and(|n| n.parse::<u64>().is_ok()).

Evidence#

crates/rgit-cli/tests/it/toon_detail.rs misc_blame_has_a_date failed twice inside rvow prove TSK-fc0yam with ,t,0s, expected but the commit already 0s/1s old; fixed by parsing the row cells. Re-ran prove: result: proved.

Also found by searching

  • test fails on 0s but passes locally
  • relative age assertion flaky in prove
  • when field assertion 0s 1s