c7ab3e0957
NixOS doesn't populate /bin (no /bin/sleep), so the gateway-init end-to-end tests that spawn a real `sleep` errored with FileNotFoundError. Add tests/_bin.py with a PATH-resolved SLEEP constant (falling back to /bin/sleep on FHS hosts) and import it in test_gateway_init.py instead of hardcoding the path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A9qa3xoavjQScufDfZaXKR
24 lines
856 B
Python
24 lines
856 B
Python
"""Resolved paths to system binaries used by subprocess-based tests.
|
|
|
|
NixOS and other non-FHS hosts don't populate ``/bin`` (there is no
|
|
``/bin/sleep``), so tests that spawn real short-lived helper processes
|
|
must resolve the binary from ``PATH`` rather than hardcoding an FHS path.
|
|
Import the resolved constant (e.g. ``SLEEP``) instead of writing
|
|
``/bin/sleep`` inline.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import shutil
|
|
|
|
|
|
def resolve(name: str, fallback: str) -> str:
|
|
"""Absolute path to ``name`` from ``PATH``; ``fallback`` on FHS hosts
|
|
where the binary isn't on ``PATH`` but lives at a known ``/bin`` path."""
|
|
return shutil.which(name) or fallback
|
|
|
|
|
|
# Real ``sleep`` binary. ``/bin/sleep`` is absent on NixOS; resolve from
|
|
# PATH so subprocess tests run instead of erroring with FileNotFoundError.
|
|
SLEEP = resolve("sleep", "/bin/sleep")
|