test(e2e): CLI, config, MCP robustness, daemon state, and agent-sidecar coverage - #177
Merged
Conversation
…gent sidecar Regression tests for this week's fixes, verified to fail against the pre-fix behavior: - TestVersionFlag_Works — `ccmux --version` exits 0 and prints a version line (#169: rootCmd.Version assigned in init() before Execute set it, so the flag was never registered). Includes an unknown-flag control so the pass proves registration, not blanket flag acceptance. - TestHostAdd_RejectsDuplicateName — duplicate `host add` fails, names the conflict, and leaves exactly one entry with the original address (#172). - TestConfigFile_Mode0600AndRewriteKeepsBothChanges — config.toml is written 0600 and survives back-to-back CLI rewrites with both changes plus pre-existing content intact (#169: 0644 + non-atomic). - TestDoctor_HonorsConfiguredSSHPort — doctor's per-host probe names the configured ssh_port, not hardcoded 22 (#169). Offline-safe: closed loopback port, instant ECONNREFUSED. New coverage gaps: - TestMCPServer_SurvivesOversizedFrame — a >4 MiB stdin line gets a JSON-RPC -32700 with literal-null id and the next request is still served (#172: bufio.Scanner ErrTooLong used to kill the transport). - TestMCPServer_ProtocolVersionNegotiation — supported revisions are echoed back; unsupported/garbage get the server's latest (#172). - TestDaemonIPC_SessionStateObserved — a `ccmux shell` session running the stub agent settles into a plausible state over the daemon socket and via `ccmux list --json`, polled with timeouts. - TestSessionKill_NonexistentFailsCleanly — non-zero exit, clear stderr, no panic, other sessions unharmed. - TestProjectAgentSidecar_NewWritesAttachHonors — `ccmux new --agent codex` writes .ccmux/agent and launches codex; after kill, a bare `ccmux attach` re-creates the session from the sidecar alone. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Nine new hermetic e2e tests in
internal/e2e/. No production changes.Regression tests for bugs fixed this week (fail-before verified by reverting the fix and observing the exact failure):
TestVersionFlag_Works—ccmux --version(broken until fix: usage over-count, settings-key loss, config data-loss paths, sleep-blocker leaks, CLI correctness #169; reverting givesunknown flag: --version). Includes a control assertion that an unknown flag still errors, so the pass proves flag registration rather than blanket acceptance.TestHostAdd_RejectsDuplicateName— duplicate rejection from fix(cli,mcp): update timeouts, MCP protocol hardening, host-add dedup, honest exit codes #172; reverting givesduplicate host add boxdup unexpectedly succeeded.TestConfigFile_Mode0600AndRewriteKeepsBothChanges— the 0600 + atomic-write fix from fix: usage over-count, settings-key loss, config data-loss paths, sleep-blocker leaks, CLI correctness #169, including that a second mutation doesn't truncate the first.TestDoctor_HonorsConfiguredSSHPort— the hardcoded-port-22 fix from fix: usage over-count, settings-key loss, config data-loss paths, sleep-blocker leaks, CLI correctness #169, using a reserved-then-closed loopback port so it's offline-safe and ~2s.New coverage:
TestMCPServer_SurvivesOversizedFrame— a 4MiB+ frame gets a-32700error with a literal"id": null, and the next request still succeeds (the server didn't die).TestMCPServer_ProtocolVersionNegotiation— supported version echoed; garbage falls back to the server's latest.TestDaemonIPC_SessionStateObserved— a stub-agent session is observed through the daemon socket and cross-checked againstccmux list --json, polled with a timeout rather than sleeping.TestSessionKill_NonexistentFailsCleanly— non-zero exit, clear stderr, no panic, and a bystander session survives.TestProjectAgentSidecar_NewWritesAttachHonors—.ccmux/agentis written on create and honored by a later flaglessattach(extends the existing default/flag agent tests rather than duplicating them).Verification
All 9 pass individually; full
make test-e2egreen (e2e 45s, ccmuxd 11s);go test ./...green; gofmt + vet clean.One observation, not a bug: doctor's timeout branch (
subcommands.go:472) omits the port number, so a timing-out custom-port host doesn't show which port was probed. The refused/OK branches do name it.🤖 Generated with Claude Code