From 9d2e4400a1936f8666e3673e306ef847493dd3c8 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Wed, 2 Dec 2026 19:16:57 -0600 Subject: [PATCH 1/2] tests(fix[tmux]): Isolate native test sockets why: Concurrent test workers could terminate each other's tmux server. what: - Use a unique tmux socket name for each native pane or window test. - Check that stopping one server leaves the other running. --- tests/__init__.py | 7 +++++++ tests/test_tmux.py | 30 +++++++++++++++++++++++++----- tests/test_tmux_window_capture.py | 10 +++++----- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/tests/__init__.py b/tests/__init__.py index f5c0c22b..08ec1804 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,3 +1,10 @@ """Tests for libvt.""" from __future__ import annotations + +import secrets + + +def new_tmux_socket_name() -> str: + """Return a short, private name for one live test's ``tmux -L`` server.""" + return f"libvt-{secrets.token_hex(8)}" diff --git a/tests/test_tmux.py b/tests/test_tmux.py index 8194e7d4..4e581402 100644 --- a/tests/test_tmux.py +++ b/tests/test_tmux.py @@ -5,7 +5,6 @@ import shutil import subprocess import time -import zlib import pytest @@ -22,6 +21,7 @@ ) from libvt.modes import Mode from libvt.style import AnsiColor, IndexedColor +from tests import new_tmux_socket_name def test_control_mode_unescape_and_metadata_format_parsing() -> None: @@ -198,11 +198,31 @@ def test_capture_decoder_acs_tabs_joined_wraps_and_prompt_zones() -> None: assert res.terminal[2].text == "!l" +@pytest.mark.integration +@pytest.mark.skipif(shutil.which("tmux") is None, reason="tmux binary not installed") +def test_live_tmux_teardown_leaves_other_server_running() -> None: + """One test can tear down its server while another still owns a live session.""" + first = ["tmux", "-L", new_tmux_socket_name(), "-f", "/dev/null"] + other = ["tmux", "-L", new_tmux_socket_name(), "-f", "/dev/null"] + try: + subprocess.run( + [*first, "new-session", "-d", "-s", "first", "sleep 30"], check=True + ) + subprocess.run( + [*other, "new-session", "-d", "-s", "other", "sleep 30"], check=True + ) + subprocess.run([*first, "kill-server"], check=True) + subprocess.run([*other, "has-session", "-t", "other"], check=True) + finally: + for server in (first, other): + subprocess.run([*server, "kill-server"], capture_output=True, check=False) + + @pytest.mark.integration @pytest.mark.skipif(shutil.which("tmux") is None, reason="tmux binary not installed") def test_live_tmux_capture_pane_roundtrip() -> None: """Live ``tmux capture-pane`` reconstructs ACS, wraps, tabs, and modes.""" - sock = f"libvt-test-{zlib.crc32(b'tmux-capture')}" + sock = new_tmux_socket_name() try: subprocess.run( [ @@ -534,7 +554,7 @@ def test_capture_overline_scoping_ntf_wraps_and_command_bundle() -> None: @pytest.mark.skipif(shutil.which("tmux") is None, reason="tmux binary not installed") def test_live_tmux_chained_bundle_overline_wraps_and_alt_screen() -> None: """Live ``tmux`` chained command bundle preserves wraps, ``5:3``, and ``-a``.""" - sock = f"libvt-test-{zlib.crc32(b'tmux-bundle')}" + sock = new_tmux_socket_name() try: ver_out = subprocess.run( ["tmux", "-V"], @@ -710,7 +730,7 @@ def test_tmux_control_live_pane_sync_with_pending_escape() -> None: TmuxPaneSync, ) - sock = f"libvt-test-{zlib.crc32(b'tmux-cc-sync')}" + sock = new_tmux_socket_name() proc: subprocess.Popen[bytes] | None = None try: ver_out = subprocess.run( @@ -957,7 +977,7 @@ def test_live_tmux_capture_and_control_checkpoint_agreement() -> None: TmuxPaneSync, ) - sock = f"libvt-test-{zlib.crc32(b'tmux-checkpoints')}" + sock = new_tmux_socket_name() proc: subprocess.Popen[bytes] | None = None try: ver_out = subprocess.run( diff --git a/tests/test_tmux_window_capture.py b/tests/test_tmux_window_capture.py index c58d3ffe..c9809c93 100644 --- a/tests/test_tmux_window_capture.py +++ b/tests/test_tmux_window_capture.py @@ -8,7 +8,6 @@ import subprocess import sys import time -import zlib import pytest @@ -35,6 +34,7 @@ Style, ) from libvt.testing import format_screen_box, serialize_vt_snapshot +from tests import new_tmux_socket_name def _assert_screen_cell_invariants( @@ -452,7 +452,7 @@ def _assert_window_matches_pty(win_snap: Snapshot, pty_snap: Snapshot) -> None: @_SKIP_LIVE_TMUX async def test_live_tmux_pty_parity_three_pane_across_client_depths() -> None: """3-pane ``T``-junction matches unmodified ``tmux`` across 16/256/RGB clients.""" - sock = f"libvt-win-t3-{os.getpid()}-{zlib.crc32(b't-junction')}" + sock = new_tmux_socket_name() w_cols, w_rows = 34, 10 try: ver_out = _tmux_version() @@ -609,7 +609,7 @@ async def test_live_tmux_pty_parity_three_pane_across_client_depths() -> None: @_SKIP_LIVE_TMUX async def test_live_tmux_pty_parity_two_pane_splits_and_full_width_wrap() -> None: """2-pane half-colors, ``pending_wrap`` cursor, and full-width ``│W`` wrap.""" - sock = f"libvt-win-2p-{os.getpid()}-{zlib.crc32(b'two-pane')}" + sock = new_tmux_socket_name() w_cols, w_rows = 25, 8 try: ver_out = _tmux_version() @@ -712,7 +712,7 @@ async def test_live_tmux_pty_parity_two_pane_splits_and_full_width_wrap() -> Non @_SKIP_LIVE_TMUX async def test_live_tmux_pty_parity_zoomed_off_and_border_status_top() -> None: """Zoomed pane matches live ``tmux`` both with status ``off`` and ``top``.""" - sock = f"libvt-win-zoom-{os.getpid()}-{zlib.crc32(b'zoomed')}" + sock = new_tmux_socket_name() w_cols, w_rows = 26, 7 try: ver_out = _tmux_version() @@ -773,7 +773,7 @@ async def test_live_tmux_pty_parity_zoomed_off_and_border_status_top() -> None: @_SKIP_LIVE_TMUX async def test_live_tmux_pty_parity_border_lines_and_border_status_top() -> None: """``pane-border-lines`` and ``pane-border-status top`` match live ``tmux``.""" - sock = f"libvt-win-bdr-{os.getpid()}-{zlib.crc32(b'borders')}" + sock = new_tmux_socket_name() w_cols, w_rows = 36, 9 try: ver_out = _tmux_version() From 24cc065d176e37da4f5eb744eb78a0252a622a29 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Wed, 2 Dec 2026 19:22:37 -0600 Subject: [PATCH 2/2] CHANGES(docs): Document private tmux test sockets why: A worker that stops a shared tmux server can interrupt another worker's capture. what: - Document the private server socket for each native integration test. --- CHANGES | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES b/CHANGES index a944b550..0a99345a 100644 --- a/CHANGES +++ b/CHANGES @@ -14,6 +14,11 @@ Use `REVIEW.md` to check API ownership, terminal behavior, and regression tests. The `libvt-study-issue` and `libvt-fix-issue` skills follow that policy for issue investigation and fixes from a checkout. +#### Run native tmux captures concurrently (#156) + +Each pane or window integration test opens its own tmux socket. One +worker can finish and stop its server while another is still capturing. + ## libvt 0.0.1a5 (2026-11-30) `libvt` 0.0.1a5 adds rectangular grid blitting, display-column text writes, and