testsAndMisc/docs/superpowers/evidence/diet-guard-test-isolation-fix-2026-06-22.json
Krzysztof kuhy Rudnicki f34c4cc670 Fix non-hermetic diet_guard gate tests depending on a real X display
test_demo_opens_window and test_bare_gate_due_opens_window never mocked
wait_for_display(), so they silently relied on a real, reachable X
display being present. On a dev machine this is always true, so they
passed; on a true headless CI runner (no X server at all) each test
blocked for the real 60s timeout before failing, explaining the CI
run's 131s duration. Mocking it to True (matching the existing
test_gate_due_but_display_not_ready_defers pattern for the False case)
restores hermeticity with no production code change.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A7vbgtFfZmfxJtN5DdtJky
2026-06-22 08:12:02 +02:00

24 lines
1.3 KiB
JSON

{
"intent": "Fix two diet_guard tests that were non-hermetic: they never mocked wait_for_display(), so they silently depended on a real, reachable X display. Discovered when the previous CI-fix commit's first true headless run (no X server) made them block for a real 60s timeout each and then fail.",
"scope": [
"python_pkg/diet_guard/tests/test_cli.py (TestGate.test_demo_opens_window, TestGate.test_bare_gate_due_opens_window)",
"Non-goal: any change to _cli.py's actual gate logic, which is correct as-is"
],
"changes": [
"Added patch.object(_cli, \"wait_for_display\", return_value=True) to both tests, matching the pattern already used in the adjacent test_gate_due_but_display_not_ready_defers test (which mocks it to False for that scenario)"
],
"verification": [
{
"command": "time python -m pytest -q (full repo suite)",
"result": "pass",
"evidence": "949 passed, 100% coverage, 14.25s total -- back to normal from the previous CI run's 131s (which included two real 60s blocking waits for the unmocked tests)"
}
],
"risks": [
"None -- this restores test hermeticity without changing any production code path"
],
"rollback": [
"git revert this commit; the two tests will again depend on a real X display being present, passing on a dev machine but failing/hanging for 60s+ each on headless CI"
]
}