Skip to content

Parallel live tests can tear down another worker’s tmux server #107

Done

Description

@tony

Summary

Several native tests derive their socket name from a constant string and call kill-server in teardown. Two concurrent test runs for the same case therefore share a server by default.

Reproduction

  1. From the tagged libvt checkout, install the locked development dependencies with uv sync --frozen --python 3.14 --all-groups --all-extras. Use the checkout root as the working directory. Use tmux 3.4. Set TMUX_BIN to its executable if another tmux comes first on your search path.

  2. Save the following as case.py at the checkout root.

import os
from pathlib import Path
import subprocess
import tempfile
import zlib

binary = os.environ.get("TMUX_BIN", "tmux")
name = f"libvt-test-{zlib.crc32(b'tmux-capture')}"
with tempfile.TemporaryDirectory() as tmp:
    for shared in (True, False):
        paths = [Path(tmp) / ("same" if shared else f"worker-{i}") for i in (0, 1)]
        for path in paths:
            path.mkdir(exist_ok=True)

        def tm(index, *args):
            return subprocess.run(
                [binary, "-L", name, "-f", "/dev/null", *args],
                env=dict(os.environ, TMUX_TMPDIR=str(paths[index])),
                capture_output=True, timeout=5, check=False,
            )

        try:
            assert tm(0, "new-session", "-d", "-s", "first", "sleep", "60").returncode == 0
            assert tm(1, "new-session", "-d", "-s", "second", "sleep", "60").returncode == 0
            assert tm(1, "has-session", "-t", "second").returncode == 0
            assert tm(0, "kill-server").returncode == 0
            remaining = tm(1, "has-session", "-t", "second").returncode == 0
            print("shared" if shared else "separate", "second worker still alive", remaining)
            assert remaining is not shared
        finally:
            for index in (0, 1):
                tm(index, "kill-server")
  1. Run the case.
$ uv run --no-sync python case.py

Expected

Each invocation owns its own socket and only tears down its own tmux process.

Actual

Two workers using the live capture test’s socket name can both create sessions. When the first kills its server, the second loses its session. Giving each worker a separate socket directory preserves the second session.

Environment

Tested versions

libvt v0.0.1a4 and trunk 0864aa2, Linux ARM64 on WSL2, tmux 3.4, CPython 3.14.6.

Evidence

Observed output
shared second worker still alive False
separate second worker still alive True

Proposal

Give each test invocation a fixture-owned temporary socket directory or unique absolute socket. Add two overlapping workers and synchronize their teardown in a regression control.

  • Developer experience — Developers can run the same tests from multiple worktrees or interpreters without coordinating socket names.
  • Immediate benefit — Eliminate process interference from tests exercising a single terminal.
  • Longer-term benefit — Make parallel compatibility coverage trustworthy.
  • End-user experience — A locally passing change remains reproducible when tests run in parallel.

References

Activity

  1. added
    bug
    p2
    on Nov 30, 2026
  2. tony commented on Dec 3, 2026

    @tony
    ContributorAuthor

    The fix gives each native pane or window test its own short tmux socket. Two concurrent pane captures on tmux 3.6b both completed with distinct sockets, including when one test stopped its server during the other capture. PR #156

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugp2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions