mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-30 11:52:04 +00:00
fix(test): pin monotonic clock in spinner-elapsed test to fix CI flake (#54203)
test_spinner_elapsed_format_is_fixed_width_to_reduce_wrap_jitter derived
_tool_start_time from the live time.monotonic() clock (now - 65.2 / now - 9.2).
monotonic()'s epoch is arbitrary — on a host where monotonic() < 65.2 (fresh
subprocess on a freshly-booted CI runner) the start time went negative, the
(t0 > 0) guard in _render_spinner_text() dropped the '(elapsed)' suffix, and
short.split('(',1)[1] raised IndexError: list index out of range. Deterministic
given a small clock, so it would keep flaking, not clear on rerun.
Pin time.monotonic to a fixed 1000.0 and offset _tool_start_time from it so both
the <60s and >=60s paths always render the elapsed suffix regardless of the
runner's monotonic epoch.
Pre-existing main flake (surfaced in CI test slice 1/8).
This commit is contained in:
parent
8e356eccea
commit
52a853f5c3
1 changed files with 13 additions and 6 deletions
|
|
@ -400,13 +400,20 @@ class TestCLIStatusBar:
|
|||
cli_obj = _make_cli()
|
||||
cli_obj._spinner_text = "running tool"
|
||||
|
||||
# <60s path
|
||||
cli_obj._tool_start_time = time.monotonic() - 9.2
|
||||
short = cli_obj._render_spinner_text()
|
||||
# Pin the clock: time.monotonic()'s epoch is arbitrary (often near
|
||||
# boot), so deriving _tool_start_time from the real monotonic clock
|
||||
# made the test fail on hosts where monotonic() < 65.2 — the start
|
||||
# time went negative, the (t0 > 0) guard in _render_spinner_text
|
||||
# dropped the "(elapsed)" suffix entirely, and the split below hit an
|
||||
# IndexError. A fixed clock keeps both elapsed paths deterministic.
|
||||
with patch.object(cli_mod.time, "monotonic", return_value=1000.0):
|
||||
# <60s path
|
||||
cli_obj._tool_start_time = 1000.0 - 9.2
|
||||
short = cli_obj._render_spinner_text()
|
||||
|
||||
# >=60s path
|
||||
cli_obj._tool_start_time = time.monotonic() - 65.2
|
||||
long = cli_obj._render_spinner_text()
|
||||
# >=60s path
|
||||
cli_obj._tool_start_time = 1000.0 - 65.2
|
||||
long = cli_obj._render_spinner_text()
|
||||
|
||||
short_elapsed = short.split("(", 1)[1].rstrip(")")
|
||||
long_elapsed = long.split("(", 1)[1].rstrip(")")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue