test(e2e): unique tmux socket per test + RAII server disposal#25
Merged
Conversation
Each TestEnv now mints its own uniquely-named -L socket (PID + nanos + process-wide atomic counter) instead of a shared per-run OnceLock, and a Drop guard runs kill-server on that socket so the throwaway tmux server is torn down automatically on pass, fail, or panic. The socket is relocated under the env's temp dir via TMUX_TMPDIR so its socket file is cleaned up with the temp dir too -- nothing leaks into /tmp/tmux-*/. With fully independent per-test servers the suite is parallel-safe, so --test-threads=1 is dropped from docs, README, and the .#e2e flake app. The free helpers (tmux/capture/window_exists) become TestEnv methods on the per-env socket; test_socket() and the now-redundant WindowCleanup guard are removed.
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.
Problem
A prior fix pointed the e2e suite at a throwaway
-Ltmux socket so it never touched the operator's liveyeschefserver. But that socket was minted once per test-binary run (aOnceLock), which left two problems:kill-session/kill-serverin one could disrupt another. That forced--test-threads=1.kill-serveron the throwaway socket, so every run left a live tmux server (and its socket file) orphaned in/tmp/tmux-*/. They accumulated.Change
Each
TestEnvis now fully self-isolating:unique_socket()combines PID + nanosecond timestamp + a process-wideAtomicU64counter, so no two envs ever collide — not two created back-to-back in one thread (the counter breaks any timestamp tie), not two separate binary runs (distinct PIDs), and not a run beside a live yeschef instance (yeschef-test-prefix ≠ productionyeschef). Replaces the shared per-runOnceLock.TestEnv::new()mints the socket,cmd()exports it asYESCHEF_TMUX_SOCKET, and a newDropimpl runskill-serveron that socket — tearing the private server down automatically on pass, fail, or panic. The free helperstmux()/capture()/window_exists()becameTestEnvmethods on the per-env socket;test_socket()and the now-redundantWindowCleanupguard are gone.kill-server(verified on macOS). So each env pointsTMUX_TMPDIRinside its ownTempDir, and the socket file is removed with the temp dir on drop — no fragile socket-path math. The temp dir is rooted at/tmpbecause a unix socket path has a hard ~104-byte limit (sun_path) and macOS's default temp dir (/var/folders/…) is deep enough to overflow it.--test-threads=1is dropped fromDEVELOPMENT.md,README.md, and the.#e2eflake app. The suite is green under cargo's default parallel execution.Verification
No orphaned servers or sockets after the run (before/after, filtering by this suite's config signature so pre-existing orphans from old runs don't muddy it):
The operator's live
yeschefserver is untouched, and running the suite from inside a live yeschef session (as here) leaves it alone.Coordination
A separate line cook is reworking
tests/e2e.rs+ the backend for the tmux-native TUI on another branch — expect a conflict intests/e2e.rs. This change is tightly scoped to the socket/isolation harness. Rebased onto the latestorigin/main(cd8c78c) before opening; that work hasn't landed yet, so no conflict at this time.