Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -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)}"
30 changes: 25 additions & 5 deletions tests/test_tmux.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import shutil
import subprocess
import time
import zlib

import pytest

Expand All @@ -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:
Expand Down Expand Up @@ -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(
[
Expand Down Expand Up @@ -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"],
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
10 changes: 5 additions & 5 deletions tests/test_tmux_window_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import subprocess
import sys
import time
import zlib

import pytest

Expand All @@ -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(
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
Loading