diff options
| author | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-22 15:16:51 -0500 |
|---|---|---|
| committer | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-22 15:16:51 -0500 |
| commit | ea508e6839e34a347327b7e64fb0d152fe7686fd (patch) | |
| tree | c48c5e65383e240701edbe1b2c205537ecf8f0b6 | |
| parent | c2e575649b25e87b4699c5db3f7f3ad065a885dc (diff) | |
| parent | 95e2aff60cc6f8759fcf20f5c1096c56ce16c27b (diff) | |
Merge pull request #3307 from Vonsek
| -rw-r--r-- | tests/test_first_light_harness_paths.py | 54 | ||||
| -rw-r--r-- | tools/first_light.py | 15 |
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 | |||
| 3 | import os | ||
| 4 | from pathlib import Path | ||
| 5 | import sys | ||
| 6 | import tempfile | ||
| 7 | import unittest | ||
| 8 | from unittest.mock import patch | ||
| 9 | |||
| 10 | sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "tools")) | ||
| 11 | import first_light | ||
| 12 | |||
| 13 | |||
| 14 | class 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 | |||
| 53 | if __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 | ||
| 41 | TOOLS = os.path.dirname(os.path.abspath(__file__)) | 41 | TOOLS = os.path.dirname(os.path.abspath(__file__)) |
| 42 | ROOT = os.path.dirname(TOOLS) | 42 | ROOT = os.path.dirname(TOOLS) |
| 43 | sys.path.insert(0, os.path.join(ROOT, "runtime", "test", "shaders")) | ||
| 44 | from compute_fixture import find_test_program # noqa: E402 | ||
| 45 | |||
| 43 | DEFAULT_VS = "VS_main_170e32e6_Wrapped" | 46 | DEFAULT_VS = "VS_main_170e32e6_Wrapped" |
| 44 | DEFAULT_PS = "$PS_Rage_Untextured_14f8529b_Wrapped" | 47 | DEFAULT_PS = "$PS_Rage_Untextured_14f8529b_Wrapped" |
| 45 | DEFAULT_TEXTURED_PS = "PS_Copy_3ea4b38a_Wrapped" | 48 | DEFAULT_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 | ||
| 385 | def find_harness(explicit: str | None) -> str: | 388 | def 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" |