From b367f8e5ccd5374c9d825d16b590fb5c462248e4 Mon Sep 17 00:00:00 2001 From: Sum Abiut Date: Sun, 3 May 2026 09:45:30 +1100 Subject: [PATCH] test: isolate cleanup_stale_cowork_socket BATS from host pgrep state (#534) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * test: isolate cleanup_stale_cowork_socket BATS from host pgrep state 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 #533 * test: address PR #534 review — drop no-op export and stale comment Per aaddrick's review: - export -f pgrep is a no-op since cleanup_stale_cowork_socket runs in the same shell and bash function lookup beats PATH - the "socat connection should fail" comment predates the move to pgrep checks and is now misleading --- tests/launcher-common.bats | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/launcher-common.bats b/tests/launcher-common.bats index 0634412..4c7a03f 100644 --- a/tests/launcher-common.bats +++ b/tests/launcher-common.bats @@ -455,8 +455,12 @@ s.bind(sys.argv[1]) s.close() " "$sock" 2>/dev/null || skip "Cannot create test unix socket" + # Stub pgrep so the test is isolated from host process state: + # a real cowork-vm-service daemon on the developer machine would + # trip the function's "daemon alive, leave socket alone" branch. + pgrep() { return 1; } + setup_logging - # socat connection should fail since nothing is listening cleanup_stale_cowork_socket [[ ! -S "$sock" ]] }