Files
mandy/tests/test_build_runtime_fallback.py
Felix Croasdale f4ee349968 build_runtime.ps1: the cl.exe fallback builds the GPU test harnesses the tools need
Without VS's "C++ CMake tools" component, build_runtime.ps1 compiles
with cl.exe directly, and that list never built vk_compute_test,
vk_store_test or vk_harness (the programs check.py and run_gpu_tests.py
require and valu_fuzz.py/lds_fuzz.py run), nor vk_image_fuzz
(image_fuzz.py's harness). TEST-71 on that path stopped at
"vk_compute_test not found". Build them the way the fallback builds
vk_texture_test. tests/test_build_runtime_fallback.py checks that the
fallback builds every harness those tools name and that each source it
compiles exists.

Found by @derekhearst.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 02:46:54 -06:00

47 lines
1.8 KiB
Python

"""scripts/build_runtime.ps1's cl.exe fallback builds every GPU test harness the Python tools need (no build run).
The fallback is what runs when Visual Studio has no "C++ CMake tools" component. Without these programs,
check.py / run_gpu_tests.py stop with "missing vk_compute_test", and so do the fuzzers.
python -I tests/test_build_runtime_fallback.py
"""
from pathlib import Path
import re
import sys
import unittest
ROOT = Path(__file__).resolve().parents[1]
sys.path[:0] = [str(ROOT / "scripts"), str(ROOT / "runtime" / "test" / "shaders"), str(ROOT / "tools")]
import check # noqa: E402
import image_fuzz # noqa: E402
import run_gpu_tests # noqa: E402
SCRIPT = ROOT / "scripts" / "build_runtime.ps1"
def fallback_body(text: str) -> str:
"""The cl.exe branch: from the line-starting `} else {` after the CMake test to the end of its here-string."""
start = re.search(r"^\} else \{", text, re.M).start()
return text[start:text.index('"@', text.index('$body = @"', start))]
class FallbackBuildsTheHarnesses(unittest.TestCase):
def setUp(self):
self.body = fallback_body(SCRIPT.read_text(encoding="utf-8"))
self.programs = set(re.findall(r"/Fe:([A-Za-z0-9_]+)\.exe", self.body))
def test_the_harnesses_the_gpu_tools_require_are_built(self):
needed = set(run_gpu_tests.REQUIRED_TEST_PROGRAMS) | set(check.TEST_PROGRAMS) | {image_fuzz.HARNESS}
self.assertEqual(needed - self.programs, set(), "missing from build_runtime.ps1's cl.exe fallback")
def test_every_test_source_it_compiles_exists(self):
sources = re.findall(r'"\$src\\test\\([A-Za-z0-9_]+\.cpp)"', self.body)
self.assertTrue(sources)
for name in sources:
with self.subTest(source=name):
self.assertTrue((ROOT / "runtime" / "test" / name).is_file())
if __name__ == "__main__":
unittest.main()