test: isolate cleanup_stale_cowork_socket BATS from host pgrep state#534
Open
sabiut wants to merge 1 commit intoaaddrick:mainfrom
Open
test: isolate cleanup_stale_cowork_socket BATS from host pgrep state#534sabiut wants to merge 1 commit intoaaddrick:mainfrom
sabiut wants to merge 1 commit intoaaddrick:mainfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 stubspgrep.cleanup_stale_cowork_socket(scripts/launcher-common.sh:224) intentionally bails out early if acowork-vm-service.jsdaemon is alive — that's correct behavior. The test, however, was written to exercise the "no daemon → remove stale socket" branch but used realpgrep, so the developer's own running daemon would trip the early-return path and the assertion[[ ! -S "$sock" ]]would fail.This PR stubs
pgrepinside 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 viapgrep -af 'cowork-vm-service\.js')bats tests/*.bats— 186/186 passshellcheck -x tests/launcher-common.bats— no new findings (preexisting SC2053 on line 16 unrelated)