Skip to content

mcpx tests: assert the spawn happened in TestEnsureDaemonCancelledWhileWaiting - #362

Merged
dezren39 merged 1 commit into
mainfrom
dedup/361-spawn-marker
Oct 19, 2026
Merged

dezren39 merged 1 commit into
mainfrom
dedup/361-spawn-marker

Conversation

@dezren39

@dezren39 dezren39 commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Problem → solution

The mcpx dedup audit (this repo's pkgs/mcpx vs the vendored copy in dezren39/nix) found all production code behaviorally identical; the one real divergence was test-only: the nix copy's cancel-while-polling test asserts the daemon spawn actually happened, this copy's didn't. This ports that assertion (see #361 for the full evidence), so this repo — about to become the only mcpx source — loses no coverage when the nix copy is deleted.

TestEnsureDaemonCancelledWhileWaiting now keeps the marker from ensureTestClient and, after the existing error/promptness assertions, waits up to 5s for it, failing with "expected the daemon spawn to have happened before cancellation". The bounded wait mirrors the pattern TestEnsureDaemonNeverReadyStillTimesOut already uses (cmd.Start returns before the child runs; the child is Setsid + Released, so the marker can land after the return).

Verification

  • go test ./internal/cli/ -run TestEnsureDaemon -count=1 -v: all 5 pass.
  • Ablation: with cmd.Start/Release temporarily stubbed out of EnsureDaemon, the test fails with exactly that message (5.21s); stub reverted.
  • Full go test ./internal/cli/ -count=1: ok (25.2s).
  • No production code changes — one test file, +26/−1.

Closes #361. Downstream: dezren39/darwin-nix#468 pins this repo (at the merge rev of this PR) as its mcpx source and deletes its vendored copy.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

…leWaiting

The dezren39/nix copy of this test (TestEnsureDaemonCancelWhilePolling)
has always asserted, after the prompt context.Canceled return, that the
daemon spawn actually happened — waiting up to 5s for the fake daemon's
marker, since cmd.Start returns before the child runs and the child is
Setsid + Released. This copy discarded the marker, so it would pass even
if EnsureDaemon returned context.Canceled without spawning at all.

Ported as part of the mcpx dedup (code becomes the single source; the
nix copy is deleted and pinned to this repo). Ablation: with cmd.Start
stubbed out, the test now fails with 'expected the daemon spawn to have
happened before cancellation'; unmodified code passes, as does the full
internal/cli suite.

Closes #361
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.

mcpx tests: port the spawn-marker assertion into TestEnsureDaemonCancelledWhileWaiting (nix copy has it, this copy doesn't)

1 participant