Fail closed when Rayforge runtime is missing

This commit is contained in:
Codex 2026-10-19 19:55:02 +02:00
parent 583540a90c
commit 5945bb0b61
2 changed files with 28 additions and 15 deletions

View file

@ -11,21 +11,25 @@ from pathlib import Path
def inspect(rayforge: Path, python_env: Path) -> dict[str, object]:
msys2_shell = Path("C:/msys64/msys2_shell.cmd")
msys2_env = rayforge / ".msys2_env"
gi_probe = subprocess.run(
[str(python_env), "-c", "import gi"],
capture_output=True,
text=True,
check=False,
)
gi_available = gi_probe.returncode == 0
gi_error = next(
(
line.strip()
for line in reversed(gi_probe.stderr.splitlines())
if line.strip()
),
"unable to import gi",
)
if python_env.is_file():
gi_probe = subprocess.run(
[str(python_env), "-c", "import gi"],
capture_output=True,
text=True,
check=False,
)
gi_available = gi_probe.returncode == 0
gi_error = next(
(
line.strip()
for line in reversed(gi_probe.stderr.splitlines())
if line.strip()
),
"unable to import gi",
)
else:
gi_available = False
gi_error = "python runtime not found"
app_entry = rayforge / "rayforge" / "__main__.py"
addon_manifest = (
Path(__file__).parents[1]

View file

@ -1,6 +1,9 @@
import json
import unittest
from pathlib import Path
import tempfile
from scripts.check_rayforge_windows_gui import inspect
ROOT = Path(__file__).parents[1]
@ -30,6 +33,12 @@ class RayforgeWindowsGuiPreflightTests(unittest.TestCase):
def test_result_records_the_requested_runtime_probe(self):
self.assertIn("No module named 'gi'", self.result["observed_launch_error"])
def test_missing_runtime_path_fails_closed(self):
with tempfile.TemporaryDirectory() as temporary:
result = inspect(Path(temporary), Path(temporary) / "missing-python.exe")
self.assertFalse(result["ready_for_manual_gui_test"])
self.assertEqual("python runtime not found", result["observed_launch_error"])
if __name__ == "__main__":
unittest.main()