Skip to content

test: isolate cleanup_stale_cowork_socket BATS from host pgrep state#534

Open
sabiut wants to merge 1 commit intoaaddrick:mainfrom
sabiut:fix/533-bats-cleanup-stale-cowork-socket-isolation
Open

test: isolate cleanup_stale_cowork_socket BATS from host pgrep state#534
sabiut wants to merge 1 commit intoaaddrick:mainfrom
sabiut:fix/533-bats-cleanup-stale-cowork-socket-isolation

Conversation

@sabiut
Copy link
Copy Markdown
Collaborator

@sabiut sabiut commented Apr 28, 2026

Summary

Fixes #533. The BATS test cleanup_stale_cowork_socket: removes stale socket file (tests/launcher-common.bats:341) fails on any developer machine running Claude Desktop because it never stubs pgrep.

cleanup_stale_cowork_socket (scripts/launcher-common.sh:224) intentionally bails out early if a cowork-vm-service.js daemon is alive — that's correct behavior. The test, however, was written to exercise the "no daemon → remove stale socket" branch but used real pgrep, so the developer's own running daemon would trip the early-return path and the assertion [[ ! -S "$sock" ]] would fail.

This PR stubs pgrep inside the test to always return nonzero, isolating the test from host process state.

Test plan

  • bats tests/launcher-common.bats --filter cleanup_stale_cowork_socket — 2/2 pass with Claude Desktop running on the host (PID confirmed via pgrep -af 'cowork-vm-service\.js')
  • bats tests/*.bats — 186/186 pass
  • shellcheck -x tests/launcher-common.bats — no new findings (preexisting SC2053 on line 16 unrelated)

Stub `pgrep` inside the `cleanup_stale_cowork_socket: removes stale
socket file` test so it returns nonzero. Without this, the test fails
on any developer machine running Claude Desktop because the real
`pgrep -f cowork-vm-service\.js` finds the live daemon and the
function correctly bails out before removing the socket — the
function's "daemon alive, leave socket alone" branch was leaking into
a test that was supposed to exercise the "no daemon, remove stale
socket" branch.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BATS: cleanup_stale_cowork_socket test fails when a cowork-vm-service daemon is running on the host

1 participant