Skip to content

test: fix stale-socket e2e tests to exercise scan-based discovery - #27

Merged
Cannon07 merged 1 commit into
Cannon07:mainfrom
kam-hak:fix/stale-socket-test-coverage
Apr 6, 2026
Merged

test: fix stale-socket e2e tests to exercise scan-based discovery#27
Cannon07 merged 1 commit into
Cannon07:mainfrom
kam-hak:fix/stale-socket-test-coverage

Conversation

@kam-hak

@kam-hak kam-hak commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #26.

Two structural bugs in the e2e stale-socket tests prevented them from exercising what they claimed. See issue #26 for details.

Changes (tests only, no bin/ or lua/ changes):

  1. test_stale_socket_recovery now genuinely exercises scan-based socket discovery. Starts nvim on --listen "/tmp/nvim.$$/0" (a path bin/nvim-socket.sh recognizes via its /tmp/nvim.*/0 glob), crashes it with kill -9 leaving a stale socket, starts a second nvim, verifies the hook rediscovers via the scan.
  2. Adds opt-in scan mode to run_pretool_hook/run_posttool_hook that explicitly clears NVIM_LISTEN_ADDRESS= to force the slow path.
  3. Renames test_no_nvim_graceful to test_no_matching_project_nvim_graceful and rewrites it to assert only what the body proves (clean exit + proposed file generation). Genuine isolation from ambient nvim instances would require invasive environment changes, so the test is scoped to honest claims.
  4. Small corrections: assert_file_exists changed from [[ ! -f ]] to [[ ! -e ]] because unix domain sockets fail -f. setup_test_project now canonicalizes TEST_PROJECT_DIR with pwd -P to handle macOS's /tmp/private/tmp symlink, which otherwise breaks the CWD-preference matching in find_nvim_socket.

Verified locally: 14/14 tests pass on macOS (nvim 0.11).

CI portability: /tmp/nvim.<pid>/0 is in the production scanner's glob set and works cross-platform. The pwd -P fix is macOS-specific and a no-op on Linux.

@Cannon07

Cannon07 commented Apr 6, 2026

Copy link
Copy Markdown
Owner

Thanks for the thorough analysis and fix!

LGTM, Merging!

@Cannon07
Cannon07 merged commit 866dc4b into Cannon07:main Apr 6, 2026
2 checks passed
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.

E2E stale-socket tests don't actually exercise stale-socket discovery

2 participants