testsAndMisc/python_pkg/phone_lease/tests/test_alive.py
Krzysztof kuhy Rudnicki 24503e9197
Some checks are pending
md-naming / markdown naming convention (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (mypy, mypy) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (pylint, pylint) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (rest, ) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (shellcheck, shellcheck) (push) Waiting to run
Python tests / test (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / lib-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run
phone_lease: fair FIFO queue; drop fix_waifu2x
Finish the queue left uncommitted on 2026-11-17: callers that find a
scope taken get a ticket and are granted in arrival order, dead
sessions are reaped at once. The CLI keeps exit 3 for a held scope.
fix_waifu2x.sh patched the CUDA waifu2x build, now uninstalled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWV2U9cEtTMTf7iQWin
2026-11-21 11:50:32 +01:00

38 lines
1.0 KiB
Python

"""Which lease owners count as dead: only sessions whose process is gone."""
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from python_pkg.phone_lease.owner import owner_alive
if TYPE_CHECKING:
from pathlib import Path
@pytest.fixture
def proc(tmp_path: Path) -> Path:
for pid, comm in ((10, "claude"), (11, "zsh"), (12, "bash")):
(tmp_path / str(pid)).mkdir()
(tmp_path / str(pid) / "comm").write_text(f"{comm}\n")
return tmp_path
@pytest.mark.parametrize(
("owner", "alive"),
[
("claude:10", True),
("claude:11", False), # pid reused by another program
("claude:99", False), # gone
("phone_deploy:12", True),
("phone_deploy:99", False),
("pid:99", True), # the CLI's own pid: dead right after acquire
("ci-run-7", True),
("claude:abc", True),
],
)
def test_owner_alive(proc: Path, owner: str, *, alive: bool) -> None:
assert owner_alive(owner, proc_root=proc) is alive