From dd5c052dc52f4487387c15604eee96ecc5734370 Mon Sep 17 00:00:00 2001 From: Dextroid17 <217507631+Dextroid17@users.noreply.github.com> Date: Wed, 7 Oct 2026 16:02:00 -0400 Subject: [PATCH 1/5] ci: fail when a test executable is built that no test runs A test executable can be declared with add_test_executable and never registered with add_test. It is then built and never run, and ctest reports a full pass over what it knows, so nothing in CI says so. Measured on main, five test executables are in this state: the driver's mesh and recorder tests, the guest formatting tests, the video out flip tests and the BDA device tests. tools/check_test_registration.py compares the test executables CMake builds, read from the build graph, against the add_test calls in the generated CTestTestfile.cmake files, which are written at configure time and so do not depend on the build having finished. It fails on a test executable that nothing runs, and records those five by name so the job stays green until they are dealt with. Both jobs run it right after configure, before anything is built. --- .github/workflows/build.yml | 5 +++ tools/check_test_registration.py | 68 ++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 tools/check_test_registration.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5e2215f19..0bae125d7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,6 +35,8 @@ jobs: - name: Install lavapipe for the GPU execution tests run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libvulkan1 mesa-vulkan-drivers - run: cmake -S . -B build $CONFIGURE -DANYPS5_ENABLE_SPIRV_TOOLS=ON + - name: Check that every test executable is registered with ctest + run: python3 tools/check_test_registration.py build - run: cmake --build build - run: cmake --build build --target libs - run: ctest --test-dir build --output-on-failure --timeout 120 --repeat until-fail:3 @@ -73,6 +75,9 @@ jobs: evict-old-files: job - shell: cmd run: cmake -S . -B build %CONFIGURE% + - name: Check that every test executable is registered with ctest + shell: cmd + run: python tools/check_test_registration.py build - shell: cmd run: cmake --build build - shell: cmd diff --git a/tools/check_test_registration.py b/tools/check_test_registration.py new file mode 100644 index 000000000..4931f8836 --- /dev/null +++ b/tools/check_test_registration.py @@ -0,0 +1,68 @@ +import argparse +import re +import subprocess +from pathlib import Path + +TEST_OUTPUT = "tests/" + +KNOWN_UNRUN = { + "agc_driver_bda_device_tests", + "agc_driver_mesh_tests", + "agc_driver_recorder_tests", + "guest_formatting_tests", + "video_out_flip_tests", +} + + +def built(build): + listed = subprocess.run(["ninja", "-C", str(build), "-t", "targets", "all"], + capture_output=True, text=True, check=True).stdout + names = set() + for line in listed.splitlines(): + found = re.match(rf"^{TEST_OUTPUT}([A-Za-z0-9_]+)(?::|\s|$)", line) + if found: + names.add(found.group(1)) + return names + + +def registered(build): + names = set() + for file in Path(build).rglob("CTestTestfile.cmake"): + for line in file.read_text(errors="replace").splitlines(): + found = re.match(r"\s*add_test\s*\((.*)\)\s*$", line) + if not found: + continue + for token in re.findall(r'"([^"]*)"|(\S+)', found.group(1)): + argument = token[0] or token[1] + base = re.split(r"[\\/]", argument)[-1] + if base.endswith(".exe"): + base = base[:-4] + if base: + names.add(base) + return names + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="fail when a test executable is built that no ctest test runs") + parser.add_argument("build", type=Path, nargs="?", default=Path("build"), help="configured build directory") + parser.add_argument("--list", action="store_true", help="print every test executable and whether ctest runs it") + args = parser.parse_args() + every = sorted(built(args.build)) + run = registered(args.build) + if args.list: + for name in every: + print(f"{'run' if name in run else 'NOT RUN'} {name}") + raise SystemExit + unrun = sorted(set(every) - run) + if not every: + print(f"no test executables found under {args.build}; is it configured with -DBUILD_TESTING=ON?") + raise SystemExit(1) + for name in sorted(set(unrun) & KNOWN_UNRUN): + print(f"note: {name} is built and not run, as recorded") + fresh = sorted(set(unrun) - KNOWN_UNRUN) + for name in fresh: + print(f"error: {name} is built but no ctest test runs it") + if fresh: + print(f"{len(fresh)} test executable(s) would never run: ctest reports a full pass over what it knows, so a test nobody registered is invisible in CI") + raise SystemExit(1) + print(f"{len(every)} test executable(s), {len(unrun)} built and not run as recorded, none new") From 28d9b1a49b5969fe41fc6ec1dfea6ff39a3e9fe0 Mon Sep 17 00:00:00 2001 From: Dextroid17 <217507631+Dextroid17@users.noreply.github.com> Date: Wed, 7 Oct 2026 16:12:57 -0400 Subject: [PATCH 2/5] fix(ci): read the test executable list on Windows as well The Windows job failed on the new step with "no test executables found under build". Ninja prints the target names with the platform separator, so the Windows build graph lists tests\name_tests.exe where Linux lists tests/name_tests, and the reader matched neither the backslash nor the .exe suffix. Accept both separators and a .exe suffix. Verified by driving the function with recorded Ninja output for both platforms, which now return the same names, and by re-running the check against the Linux tree, which still reports 362 test executables and the same five. --- tools/check_test_registration.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/check_test_registration.py b/tools/check_test_registration.py index 4931f8836..8d8011efa 100644 --- a/tools/check_test_registration.py +++ b/tools/check_test_registration.py @@ -3,7 +3,7 @@ import re import subprocess from pathlib import Path -TEST_OUTPUT = "tests/" +TEST_OUTPUT = r"tests[\\/]" KNOWN_UNRUN = { "agc_driver_bda_device_tests", @@ -19,9 +19,14 @@ def built(build): capture_output=True, text=True, check=True).stdout names = set() for line in listed.splitlines(): - found = re.match(rf"^{TEST_OUTPUT}([A-Za-z0-9_]+)(?::|\s|$)", line) - if found: - names.add(found.group(1)) + found = re.match(rf"^{TEST_OUTPUT}([A-Za-z0-9_.]+)", line) + if not found: + continue + name = found.group(1).rstrip(".") + if name.endswith(".exe"): + name = name[:-4] + if name: + names.add(name) return names From 5d6ec8ee1f1df0393c3451e329dfd82729b73ad1 Mon Sep 17 00:00:00 2001 From: Dextroid17 <217507631+Dextroid17@users.noreply.github.com> Date: Wed, 7 Oct 2026 16:20:27 -0400 Subject: [PATCH 3/5] fix(ci): read only linked executables out of the build graph The Windows job failed the check with two names that are not test executables. `libhost_thread_local_test_library` is a support library whose RUNTIME_OUTPUT_DIRECTORY puts it in the test directory; on Linux its output is a library artifact and never lands there, which is why the Linux job stayed green. `windows_exception_tests` is a MINGW-only test executable that no `add_test` registers. Ninja prints the rule beside each target, and CMake links an executable with `CXX_EXECUTABLE_LINKER___` and a shared library with `CXX_SHARED_LIBRARY_LINKER__...`, on every platform. Requiring EXECUTABLE in the rule leaves the library out and keeps the Linux count at 362. `windows_exception_tests` is a real instance of the class this check looks for, so record it beside the other five rather than fail the job that found it. --- tools/check_test_registration.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/check_test_registration.py b/tools/check_test_registration.py index 8d8011efa..d720292e1 100644 --- a/tools/check_test_registration.py +++ b/tools/check_test_registration.py @@ -11,6 +11,7 @@ KNOWN_UNRUN = { "agc_driver_recorder_tests", "guest_formatting_tests", "video_out_flip_tests", + "windows_exception_tests", } @@ -19,7 +20,10 @@ def built(build): capture_output=True, text=True, check=True).stdout names = set() for line in listed.splitlines(): - found = re.match(rf"^{TEST_OUTPUT}([A-Za-z0-9_.]+)", line) + path, _, rule = line.partition(": ") + if "EXECUTABLE" not in rule: + continue + found = re.match(rf"^{TEST_OUTPUT}([A-Za-z0-9_.]+)$", path) if not found: continue name = found.group(1).rstrip(".") From 0208dea491bee7b8258097f45b6818db6b996bfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Franch?= Date: Thu, 8 Oct 2026 11:40:34 +0200 Subject: [PATCH 4/5] ci: fail when a KNOWN_UNRUN test is run by ctest agc_driver_bda_device_tests is registered on main, so its entry hid any future loss of that registration. Co-Authored-By: Claude --- tools/check_test_registration.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/check_test_registration.py b/tools/check_test_registration.py index d720292e1..23b30e37c 100644 --- a/tools/check_test_registration.py +++ b/tools/check_test_registration.py @@ -6,7 +6,6 @@ from pathlib import Path TEST_OUTPUT = r"tests[\\/]" KNOWN_UNRUN = { - "agc_driver_bda_device_tests", "agc_driver_mesh_tests", "agc_driver_recorder_tests", "guest_formatting_tests", @@ -68,10 +67,14 @@ if __name__ == "__main__": raise SystemExit(1) for name in sorted(set(unrun) & KNOWN_UNRUN): print(f"note: {name} is built and not run, as recorded") + stale = sorted(KNOWN_UNRUN & run) + for name in stale: + print(f"error: {name} is run by ctest now; remove it from KNOWN_UNRUN") fresh = sorted(set(unrun) - KNOWN_UNRUN) for name in fresh: print(f"error: {name} is built but no ctest test runs it") if fresh: print(f"{len(fresh)} test executable(s) would never run: ctest reports a full pass over what it knows, so a test nobody registered is invisible in CI") + if stale or fresh: raise SystemExit(1) print(f"{len(every)} test executable(s), {len(unrun)} built and not run as recorded, none new") From 464f6731706da4f7bccef042a8f1794b6b8350e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Franch?= Date: Thu, 8 Oct 2026 12:02:39 +0200 Subject: [PATCH 5/5] ci: keep the not-run list per platform guest_formatting_tests runs only on Windows and windows_exception_tests only exists there, so the stale-entry check failed the Windows job. Co-Authored-By: Claude --- tools/check_test_registration.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/check_test_registration.py b/tools/check_test_registration.py index 23b30e37c..353b73b25 100644 --- a/tools/check_test_registration.py +++ b/tools/check_test_registration.py @@ -1,6 +1,7 @@ import argparse import re import subprocess +import sys from pathlib import Path TEST_OUTPUT = r"tests[\\/]" @@ -8,10 +9,10 @@ TEST_OUTPUT = r"tests[\\/]" KNOWN_UNRUN = { "agc_driver_mesh_tests", "agc_driver_recorder_tests", - "guest_formatting_tests", "video_out_flip_tests", - "windows_exception_tests", } +if sys.platform != "win32": + KNOWN_UNRUN.add("guest_formatting_tests") def built(build):