upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 15:16:51 -0500
committerItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 15:16:51 -0500
commitea508e6839e34a347327b7e64fb0d152fe7686fd (patch)
treec48c5e65383e240701edbe1b2c205537ecf8f0b6
parentc2e575649b25e87b4699c5db3f7f3ad065a885dc (diff)
parent95e2aff60cc6f8759fcf20f5c1096c56ce16c27b (diff)
Merge pull request #3307 from Vonsek
-rw-r--r--tests/test_first_light_harness_paths.py54
-rw-r--r--tools/first_light.py15
2 files changed, 65 insertions, 4 deletions
diff --git a/tests/test_first_light_harness_paths.py b/tests/test_first_light_harness_paths.py
new file mode 100644
index 000000000..58ab34800
--- /dev/null
+++ b/tests/test_first_light_harness_paths.py
@@ -0,0 +1,54 @@
1"""CPU-only checks for the first-light harness lookup."""
2
3import os
4from pathlib import Path
5import sys
6import tempfile
7import unittest
8from unittest.mock import patch
9
10sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "tools"))
11import first_light
12
13
14class FirstLightHarnessPathsTests(unittest.TestCase):
15 def setUp(self) -> None:
16 self.root = Path(self.enterContext(tempfile.TemporaryDirectory()))
17 self.enterContext(patch.object(first_light, "ROOT", str(self.root)))
18 self.enterContext(patch.dict(os.environ))
19 os.environ.pop("LEONIDA_VK_HARNESS", None)
20 self.executable = "vk_harness.exe" if os.name == "nt" else "vk_harness"
21
22 def put_harness(self, *parts: str) -> Path:
23 path = self.root.joinpath(*parts, self.executable)
24 path.parent.mkdir(parents=True, exist_ok=True)
25 path.touch()
26 return path
27
28 def test_finds_windows_release_configuration(self) -> None:
29 release = self.put_harness("runtime", "build", "windows", "Release")
30 self.assertEqual(first_light.find_harness(None), str(release))
31
32 def test_finds_relwithdebinfo_in_the_standard_build_tree(self) -> None:
33 self.put_harness("runtime", "build", "Release")
34 optimized = self.put_harness("runtime", "build", "RelWithDebInfo")
35 self.assertEqual(first_light.find_harness(None), str(optimized))
36
37 def test_standalone_harness_keeps_priority_over_configured_harness(self) -> None:
38 self.put_harness("runtime", "build", "windows", "Release")
39 standalone = self.put_harness("runtime", "build")
40 self.assertEqual(first_light.find_harness(None), str(standalone))
41
42 def test_explicit_and_environment_paths_keep_priority(self) -> None:
43 configured = self.put_harness("runtime", "build", "windows", "Release")
44 explicit = self.put_harness("explicit")
45 environment = self.put_harness("environment")
46 os.environ["LEONIDA_VK_HARNESS"] = str(environment)
47 self.assertEqual(first_light.find_harness(str(explicit)), str(explicit))
48 self.assertEqual(first_light.find_harness(str(explicit) + ".missing"), str(environment))
49 environment.unlink()
50 self.assertEqual(first_light.find_harness(None), str(configured))
51
52
53if __name__ == "__main__":
54 unittest.main()
diff --git a/tools/first_light.py b/tools/first_light.py
index cce6b412e..4fca31e0d 100644
--- a/tools/first_light.py
+++ b/tools/first_light.py
@@ -40,6 +40,9 @@ import sys
40 40
41TOOLS = os.path.dirname(os.path.abspath(__file__)) 41TOOLS = os.path.dirname(os.path.abspath(__file__))
42ROOT = os.path.dirname(TOOLS) 42ROOT = os.path.dirname(TOOLS)
43sys.path.insert(0, os.path.join(ROOT, "runtime", "test", "shaders"))
44from compute_fixture import find_test_program # noqa: E402
45
43DEFAULT_VS = "VS_main_170e32e6_Wrapped" 46DEFAULT_VS = "VS_main_170e32e6_Wrapped"
44DEFAULT_PS = "$PS_Rage_Untextured_14f8529b_Wrapped" 47DEFAULT_PS = "$PS_Rage_Untextured_14f8529b_Wrapped"
45DEFAULT_TEXTURED_PS = "PS_Copy_3ea4b38a_Wrapped" 48DEFAULT_TEXTURED_PS = "PS_Copy_3ea4b38a_Wrapped"
@@ -383,16 +386,20 @@ def uv_probes(vertices, indices, width: int, height: int, limit: int = 4) -> lis
383 386
384 387
385def find_harness(explicit: str | None) -> str: 388def find_harness(explicit: str | None) -> str:
386 exe = ".exe" if os.name == "nt" else "" 389 executable = "vk_harness.exe" if os.name == "nt" else "vk_harness"
390 build = os.path.join(ROOT, "runtime", "build")
391 build_dirs = (os.path.join(build, "linux"), os.path.join(build, "windows"), build)
387 for candidate in ( 392 for candidate in (
388 explicit, 393 explicit,
389 os.environ.get("LEONIDA_VK_HARNESS"), 394 os.environ.get("LEONIDA_VK_HARNESS"),
390 os.path.join(ROOT, "runtime", "build", "linux", f"vk_harness{exe}"), 395 *(os.path.join(folder, executable) for folder in build_dirs),
391 os.path.join(ROOT, "runtime", "build", "windows", f"vk_harness{exe}"),
392 os.path.join(ROOT, "runtime", "build", f"vk_harness{exe}"),
393 ): 396 ):
394 if candidate and os.path.isfile(candidate): 397 if candidate and os.path.isfile(candidate):
395 return candidate 398 return candidate
399 for folder in build_dirs:
400 configured = find_test_program(folder, "vk_harness")
401 if configured:
402 return os.path.join(configured, executable)
396 raise SystemExit( 403 raise SystemExit(
397 "vk_harness not found: build runtime/build/linux or runtime/build/windows (target vk_harness), " 404 "vk_harness not found: build runtime/build/linux or runtime/build/windows (target vk_harness), "
398 "or set --harness/LEONIDA_VK_HARNESS" 405 "or set --harness/LEONIDA_VK_HARNESS"