Skip to content

flake: test_codex_monitor.bats teardown intermittently fails with "Directory not empty" #662

Description

@fujibee

tests/test_codex_monitor.bats's shared teardown (teardown_test_env in tests/test_helper.bash:38, called from teardown at tests/test_codex_monitor.bats:76) intermittently fails with rm: ... Directory not empty when tearing down $TEST_SKILL_DIR.

Observed instances

When (UTC) Branch Run / Job Platform / shard Failing test
2026-08-07 09:49 main run 31166966046 / job 92829964324 macos-latest 3/4 not ok 191 codex-monitor: recreates a stale app-server left by a different codex version
2026-08-07 19:22 main run 31210935059 / job 92973377008 ubuntu-latest 3/4 not ok 194 codex-monitor: never kills a non-codex process recorded under a reused pid
2026-08-07 21:57 PR #660 run 31221828109 / job 93007897833 ubuntu-latest 1/4 not ok 202 codex-monitor: reuses a live app-server when tasklist cannot see it (#567)

All three show the identical signature:

# (from function `teardown_test_env' in file tests/test_helper.bash, line 38,
#  from function `teardown' in test file tests/test_codex_monitor.bats, line 76)
#   `teardown_test_env' failed
# rm: ...: Directory not empty

Why this points at the file's own teardown, not shard/test interference

The three instances span two different platforms (macOS, Linux), two different shard positions (3/4, 1/4), and three different specific @test names within the file. The only constant across all three is tests/test_codex_monitor.bats and its shared teardown failing the same way. That rules out shard composition or a specific adjacent test as the cause of any one instance -- whatever is causing the "Directory not empty" race is intrinsic to this file's teardown itself.

(Unconfirmed hypothesis, not verified: each of this file's tests spawns a real codex-monitor.sh app-server background process, which could still hold a file open under $TEST_SKILL_DIR when teardown_test_env's rm -rf runs. Not investigated further here.)

Root cause not investigated -- this file's tests are tied to the still-open #567 work. Filing this as its own tracking issue since the flake itself is orthogonal to that.

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