Skip to content

Commit 5c7d606

Browse files
committed
Validate release smoke timing environment
1 parent 2d4b55d commit 5c7d606

2 files changed

Lines changed: 38 additions & 3 deletions

File tree

tests/test_release_preflight.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,23 @@ def test_release_preflight_runs_headless_pipewire_runtime_smoke(monkeypatch) ->
8888
]
8989

9090

91+
def test_release_preflight_rejects_invalid_headless_pipewire_runtime_env(monkeypatch) -> None:
92+
def fail_run(_command, **_kwargs) -> None:
93+
raise AssertionError("Headless runtime smoke should not run with invalid environment")
94+
95+
monkeypatch.setenv("MINI_EQ_HEADLESS_PIPEWIRE_CYCLES", "2; touch unexpected")
96+
monkeypatch.setattr(release_preflight, "run", fail_run)
97+
98+
try:
99+
release_preflight.run_headless_pipewire_runtime_smoke(Path("/python"))
100+
except SystemExit as error:
101+
message = str(error)
102+
assert "MINI_EQ_HEADLESS_PIPEWIRE_CYCLES" in message
103+
assert "integer between 1 and 20" in message
104+
else:
105+
raise AssertionError("Expected invalid headless runtime smoke environment to fail")
106+
107+
91108
def test_flatpak_pipewire_gobject_pin_accepts_matching_floor(tmp_path: Path) -> None:
92109
(tmp_path / "pyproject.toml").write_text(
93110
'[project]\ndependencies = ["pipewire-gobject>=0.3.7,<0.4"]\n',

tools/release_preflight.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,19 @@ def require_tools(*tools: str) -> None:
9090
raise SystemExit(f"Missing required release tool(s): {', '.join(missing)}")
9191

9292

93+
def bounded_int_env(name: str, default: int, *, minimum: int, maximum: int) -> str:
94+
value = os.environ.get(name, str(default)).strip()
95+
try:
96+
parsed = int(value)
97+
except ValueError:
98+
raise SystemExit(f"{name} must be an integer between {minimum} and {maximum}") from None
99+
100+
if not minimum <= parsed <= maximum:
101+
raise SystemExit(f"{name} must be an integer between {minimum} and {maximum}")
102+
103+
return str(parsed)
104+
105+
93106
def allowed_leak_match(line: str) -> bool:
94107
return any(allowed in line for allowed in ALLOWED_LEAK_MATCHES)
95108

@@ -424,9 +437,14 @@ def run_build_checks(python: Path) -> None:
424437

425438

426439
def run_headless_pipewire_runtime_smoke(python: Path) -> None:
427-
timeout = os.environ.get("MINI_EQ_HEADLESS_PIPEWIRE_TIMEOUT", "35")
428-
cycles = os.environ.get("MINI_EQ_HEADLESS_PIPEWIRE_CYCLES", "2")
429-
audio_duration = os.environ.get("MINI_EQ_HEADLESS_PIPEWIRE_AUDIO_DURATION", "90")
440+
timeout = bounded_int_env("MINI_EQ_HEADLESS_PIPEWIRE_TIMEOUT", 35, minimum=1, maximum=600)
441+
cycles = bounded_int_env("MINI_EQ_HEADLESS_PIPEWIRE_CYCLES", 2, minimum=1, maximum=20)
442+
audio_duration = bounded_int_env(
443+
"MINI_EQ_HEADLESS_PIPEWIRE_AUDIO_DURATION",
444+
90,
445+
minimum=1,
446+
maximum=3600,
447+
)
430448
run(
431449
[
432450
python,

0 commit comments

Comments
 (0)