Add .gitignore and initial project files

This commit is contained in:
Developer
2026-09-10 16:15:17 +00:00
commit 78a2043968
17 changed files with 2261 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
from __future__ import annotations
import subprocess
import sys
import time
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
DEMO_TUI = REPO_ROOT / "examples" / "demo_tui.py"
def run_cli(*args: str) -> subprocess.CompletedProcess:
return subprocess.run(
[sys.executable, "-m", "tmux_shot.cli", *args],
capture_output=True,
text=True,
timeout=15,
)
def test_cli_full_lifecycle(session_name: str, out_dir: Path) -> None:
try:
result = run_cli("new", session_name, "--command", f"python3 {DEMO_TUI}", "--width", "80", "--height", "24")
assert result.returncode == 0, result.stderr
assert "ready" in result.stdout
time.sleep(0.3)
text_result = run_cli("text", session_name)
assert text_result.returncode == 0, text_result.stderr
assert "tmux-shot demo TUI" in text_result.stdout
shot_path = out_dir / "cli_shot.png"
shot_result = run_cli("shot", session_name, str(shot_path))
assert shot_result.returncode == 0, shot_result.stderr
assert shot_path.exists()
assert shot_path.stat().st_size > 0
send_result = run_cli("send", session_name, "Down", "--no-enter")
assert send_result.returncode == 0, send_result.stderr
finally:
run_cli("kill", session_name)
def test_cli_gif_command_stitches_frames(out_dir: Path) -> None:
from tmux_shot.render import render_ansi_to_png
frames = [
render_ansi_to_png("frame a", out_dir / "a.png", cols=8, rows=1),
render_ansi_to_png("frame b", out_dir / "b.png", cols=8, rows=1),
]
gif_path = out_dir / "movie.gif"
result = run_cli("gif", *frames, str(gif_path), "--duration-ms", "150")
assert result.returncode == 0, result.stderr
assert gif_path.exists()