Skip to content

Flaky CI test: test_run_git_timeout races the timeout against a fast git command #695

Description

@agentforce314

What fails

tests/test_git_utilities.py::TestRunGit::test_run_git_timeout

assert rc != 0 or stdout == ""
AssertionError: assert (0 != 0 or 'commit 41bc6...' == '')

Why it's flaky

The test runs a real git command under a small timeout and asserts the timeout won: either a non-zero rc or empty stdout. On a fast/cold-cache CI runner the git command completes before the timeout fires, returning rc=0 with a full commit log — so the assertion fails without any code being wrong. It's a race between a wall-clock timeout and command latency.

Evidence it's environmental, not code

  • Failed on fix/tui-agent-urls-clickable (PR fix(ui-tui): render agent URLs as visible, clickable text #694, run 29178945090) — a diff containing zero Python changes.
  • Failed identically on dependabot/pip/rich-gte-13.9.4 (run 28982750863, 2026-07-08), then passed on re-run of the same branch the next day.
  • Passes locally 3/3 consecutive runs (macOS, Python 3.11.15).

Suggested fix

Make the command deterministically outlast the timeout instead of racing a real git log, e.g. run git hash-object --stdin with stdin held open (blocks forever, timeout always triggers), or monkeypatch the subprocess to sleep. That converts the probabilistic assertion into a deterministic one.

Found by gstack /ship while landing PR #694.

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions