Files
summit/engine/tests/test_clip_folder.py
alex fc838b95e9 run: a signal to summit stops the game and the engine and puts the display mode back; clips go to Videos/Summit/<game>
- summit-core::signals catches SIGTERM, SIGINT and SIGHUP (only an atomic store in the handler). supervise() and the
  new wait_or_stop() poll it, stop the engine and the game, and summit run leaves through its normal path, so the
  display mode is restored. Exits 128+signal. A try_wait error in supervise() now stops both before returning.
- Output in the Run arm can no longer panic on a closed terminal (after SIGHUP).
- summit run --title (the launcher passes the library title) is given to the engine as SUMMIT_GAME; clips are saved
  in Videos/Summit/<game>/ named '<game> <date>.mp4'. The toast shows the path with this system's separator, and
  before & after videos say 'Summit' instead of 'SmoovPlay'.

Checked: kill -TERM / -HUP / -INT to summit alone stopped a game script and its child (exit 143/129/130); with
--enhance and a stand-in engine, both stopped and the engine saw SUMMIT_GAME. Display restore after a signal was not
run (no X display here).
2026-11-24 15:51:20 +00:00

43 lines
1.5 KiB
Python

"""Clips go to Videos/Summit/<game>, the game named by `summit run` (SUMMIT_GAME)."""
import sys
sys.path.insert(0, str(__import__("pathlib").Path(__file__).resolve().parents[1]))
from pathlib import Path
from framegen import oslayer, replay
def _folder(monkeypatch, game=None):
monkeypatch.delenv("SMOOVPLAY_REPLAY_DIR", raising=False)
monkeypatch.setattr(oslayer, "videos_dir", lambda: Path("/v"))
if game is None:
monkeypatch.delenv("SUMMIT_GAME", raising=False)
else:
monkeypatch.setenv("SUMMIT_GAME", game)
return replay.videos_folder()
def test_a_folder_per_game(monkeypatch):
assert _folder(monkeypatch, "Portal 2") == Path("/v/Summit/Portal 2")
def test_no_game_saves_in_summit(monkeypatch):
assert _folder(monkeypatch) == Path("/v/Summit")
assert _folder(monkeypatch, " ") == Path("/v/Summit")
def test_names_are_made_safe(monkeypatch):
assert _folder(monkeypatch, 'Half-Life: "Alyx"/VR?') == Path("/v/Summit/Half-Life Alyx VR")
assert _folder(monkeypatch, "../..") == Path("/v/Summit")
def test_override_still_wins(monkeypatch, tmp_path):
monkeypatch.setenv("SMOOVPLAY_REPLAY_DIR", str(tmp_path))
monkeypatch.setenv("SUMMIT_GAME", "Portal 2")
assert replay.videos_folder() == tmp_path
def test_toast_path_uses_this_systems_separator():
import os
p = Path("/home/u/Videos/Summit/Portal 2/Portal 2 2026-11-24 09-27-53.mp4")
assert replay._short(p) == os.sep.join(("Summit", "Portal 2", "Portal 2 2026-11-24 09-27-53.mp4"))