ci: fail when a test executable is built that no test runs #1257

Merged
Dextroid17 merged 5 commits from upstream-pr/1257 into main 2026-10-08 10:03:24 +00:00
Dextroid17 commented 2026-10-07 20:02:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-07T20:02:20Z.


What

A test executable can be declared with add_test_executable and never registered with add_test. It is then built and never run, and because ctest reports a full pass over the tests it knows about, nothing in CI says so. This is the same class as #1040 and the agc_command_tests mode that #1006 registered.

Measured on main, these are built and never run:

test executable
agc_driver_mesh_tests
agc_driver_recorder_tests
guest_formatting_tests
video_out_flip_tests reported in #1040
agc_driver_bda_device_tests the subject of #1044

That is 5 of 362. Whether each is deliberate I cannot tell from the tree — add_test is called inside if() blocks in several libraries, so some of these may be registered only under an option that is off. The check records them by name, so the job stays green and only a new one fails.

The Windows job has a sixth: windows_exception_tests, a MINGW-only test executable that no add_test registers. It is the same class as the five above and is recorded beside them.

The Windows job also builds one thing under the test output directory that is not a test executable: libhost_thread_local_test_library, a support library whose RUNTIME_OUTPUT_DIRECTORY is set to the test directory. On Linux its output is a library artifact (core/libs/libhost_thread_local_test_library.so) and never lands there, which is why only the Windows run listed it. The check now reads the rule Ninja prints beside each target and takes only CXX_EXECUTABLE_LINKER__…, which is what CMake links an executable with on both platforms; a shared library is linked with CXX_SHARED_LIBRARY_LINKER__….

tools/check_test_registration.py compares what CMake builds (the test executables in the build graph, filtered to the test output directory that add_test_executable sets) against what ctest runs (the add_test calls in the generated CTestTestfile.cmake files). Those files are written at configure time, so the check does not depend on the build having finished and cannot confuse "never registered" with "not built yet".

That distinction is the whole point: my first version read ctest --show-only=json-v1, and ctest only reports a test's command when its executable already exists on disk — so on a freshly configured tree every test looked unregistered, and on a built tree the answer changed as artifacts appeared and disappeared. The generated CTestTestfile.cmake count is 399 in both a built and a freshly configured tree, which is what the check relies on instead.

Both jobs run it immediately after configure, before anything is built, so it costs a second rather than another build. No source, no library behaviour and no test content changes.

Tested

Not tested with a title; nothing here changes library behaviour. tools/check_test_registration.py on Linux (CachyOS, GCC 16.2.1, Ninja):

  • a Release build directory and a freshly configured one produce identical output: 362 test executable(s), 5 built and not run as recorded, none new, exit 0;
  • deleting one add_test line from a generated CTestTestfile.cmake makes it fail with error: guest_scan_count_tests is built but no ctest test runs it and exit 1; restoring the line passes again;
  • the Windows job's failure is reproduced from a replay of Ninja's -t targets all for Windows (tests\libhost_thread_local_test_library.dll, tests\windows_exception_tests.exe) against the same parser: it reports both names and exits 1 before the rule filter, and reports windows_exception_tests as recorded and exits 0 after it. The real Windows listing is what the job itself produces;
  • the rule filter leaves the Linux result untouched: 362 test executable(s), 5 built and not run as recorded, none new;
  • both jobs configure with -G Ninja, which is what the build-graph read needs.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4777809521 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1257). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-07T20:02:20Z. --- ### What A test executable can be declared with `add_test_executable` and never registered with `add_test`. It is then built and never run, and because `ctest` reports a full pass over the tests it knows about, nothing in CI says so. This is the same class as #1040 and the `agc_command_tests` mode that #1006 registered. Measured on `main`, these are built and never run: | test executable | | | --- | --- | | `agc_driver_mesh_tests` | | | `agc_driver_recorder_tests` | | | `guest_formatting_tests` | | | `video_out_flip_tests` | reported in #1040 | | `agc_driver_bda_device_tests` | the subject of #1044 | That is 5 of 362. Whether each is deliberate I cannot tell from the tree — `add_test` is called inside `if()` blocks in several libraries, so some of these may be registered only under an option that is off. The check records them by name, so the job stays green and only a **new** one fails. The Windows job has a sixth: `windows_exception_tests`, a MINGW-only test executable that no `add_test` registers. It is the same class as the five above and is recorded beside them. The Windows job also builds one thing under the test output directory that is **not** a test executable: `libhost_thread_local_test_library`, a support library whose `RUNTIME_OUTPUT_DIRECTORY` is set to the test directory. On Linux its output is a library artifact (`core/libs/libhost_thread_local_test_library.so`) and never lands there, which is why only the Windows run listed it. The check now reads the rule Ninja prints beside each target and takes only `CXX_EXECUTABLE_LINKER__…`, which is what CMake links an executable with on both platforms; a shared library is linked with `CXX_SHARED_LIBRARY_LINKER__…`. `tools/check_test_registration.py` compares what CMake builds (the test executables in the build graph, filtered to the test output directory that `add_test_executable` sets) against what ctest runs (the `add_test` calls in the generated `CTestTestfile.cmake` files). Those files are written at configure time, so the check does not depend on the build having finished and cannot confuse "never registered" with "not built yet". That distinction is the whole point: my first version read `ctest --show-only=json-v1`, and ctest only reports a test's command when its executable already exists on disk — so on a freshly configured tree every test looked unregistered, and on a built tree the answer changed as artifacts appeared and disappeared. The generated `CTestTestfile.cmake` count is `399` in both a built and a freshly configured tree, which is what the check relies on instead. Both jobs run it immediately after configure, before anything is built, so it costs a second rather than another build. No source, no library behaviour and no test content changes. ### Tested Not tested with a title; nothing here changes library behaviour. `tools/check_test_registration.py` on Linux (CachyOS, GCC 16.2.1, Ninja): - a Release build directory and a freshly configured one produce identical output: `362 test executable(s), 5 built and not run as recorded, none new`, exit 0; - deleting one `add_test` line from a generated `CTestTestfile.cmake` makes it fail with `error: guest_scan_count_tests is built but no ctest test runs it` and exit 1; restoring the line passes again; - the Windows job's failure is reproduced from a replay of Ninja's `-t targets all` for Windows (`tests\libhost_thread_local_test_library.dll`, `tests\windows_exception_tests.exe`) against the same parser: it reports both names and exits 1 before the rule filter, and reports `windows_exception_tests` as recorded and exits 0 after it. The real Windows listing is what the job itself produces; - the rule filter leaves the Linux result untouched: `362 test executable(s), 5 built and not run as recorded, none new`; - both jobs configure with `-G Ninja`, which is what the build-graph read needs. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
Dextroid17 commented 2026-10-07 20:13:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-07T20:13:11Z.


The Windows job failed on this step's first run, so it is fixed here rather than left for you:

no test executables found under build; is it configured with -DBUILD_TESTING=ON?

Ninja prints target names with the platform separator, so the Windows build graph lists tests\name_tests.exe where Linux lists tests/name_tests — the reader matched neither the backslash nor the .exe suffix, found no test executables, and failed. Both are accepted now.

Verified by driving the reader with recorded Ninja output for both platforms, which return the same names, and by re-running the check on the Linux tree, which still reports 362 test executable(s), 5 built and not run as recorded, none new.

Linux was green because Linux is the shape I developed against. That asymmetry is worth saying plainly, since it is the failure the check exists to catch.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6045984934 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1257#issuecomment-6045984934). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-07T20:13:11Z. --- The Windows job failed on this step's first run, so it is fixed here rather than left for you: ``` no test executables found under build; is it configured with -DBUILD_TESTING=ON? ``` Ninja prints target names with the platform separator, so the Windows build graph lists `tests\name_tests.exe` where Linux lists `tests/name_tests` — the reader matched neither the backslash nor the `.exe` suffix, found no test executables, and failed. Both are accepted now. Verified by driving the reader with recorded Ninja output for both platforms, which return the same names, and by re-running the check on the Linux tree, which still reports `362 test executable(s), 5 built and not run as recorded, none new`. Linux was green because Linux is the shape I developed against. That asymmetry is worth saying plainly, since it is the failure the check exists to catch.
Dextroid17 commented 2026-10-07 20:23:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-07T20:23:21Z.


Two follow-ups after that Windows failure, both already pushed:

  1. tests\name_tests.exe — accept the platform separator and the .exe suffix.
  2. Read only linked executables out of the build graph: Ninja prints the rule beside each target, and CMake links an executable with CXX_EXECUTABLE_LINKER__<target>_<config> and a shared library with CXX_SHARED_LIBRARY_LINKER__, on both platforms. That leaves out libhost_thread_local_test_library, a support library whose RUNTIME_OUTPUT_DIRECTORY puts its artifact in the test directory — on Linux that artifact is a .so and never lands there, which is why only the Windows job saw it.

That second fix also surfaced a real instance of the class, Windows-only:

test executable
windows_exception_tests MINGW-only; no add_test registers it, so it is built and never run, and the Linux job cannot see it at all

It is recorded beside the other five, so the job stays green and only a new one fails.

Re-verified after both: the Linux tree still reads 362 test executable(s), 5 built and not run as recorded, none new, and driving the reader with recorded Ninja output for each platform now returns only the executables from each.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6046154600 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1257#issuecomment-6046154600). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-07T20:23:21Z. --- Two follow-ups after that Windows failure, both already pushed: 1. `tests\name_tests.exe` — accept the platform separator and the `.exe` suffix. 2. Read only **linked executables** out of the build graph: Ninja prints the rule beside each target, and CMake links an executable with `CXX_EXECUTABLE_LINKER__<target>_<config>` and a shared library with `CXX_SHARED_LIBRARY_LINKER__`, on both platforms. That leaves out `libhost_thread_local_test_library`, a support library whose `RUNTIME_OUTPUT_DIRECTORY` puts its artifact in the test directory — on Linux that artifact is a `.so` and never lands there, which is why only the Windows job saw it. That second fix also surfaced a real instance of the class, **Windows-only**: | test executable | | | --- | --- | | `windows_exception_tests` | MINGW-only; no `add_test` registers it, so it is built and never run, and the Linux job cannot see it at all | It is recorded beside the other five, so the job stays green and only a new one fails. Re-verified after both: the Linux tree still reads `362 test executable(s), 5 built and not run as recorded, none new`, and driving the reader with recorded Ninja output for each platform now returns only the executables from each.
Dextroid17 commented 2026-10-08 03:10:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-08T03:10:36Z.


@oneandonlydean ready for eyes — a CI guard that fails when a test executable is built but no test runs it. The earlier linux=CANCELLED was a superseded run; current checks are green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6051380424 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1257#issuecomment-6051380424). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-08T03:10:36Z. --- @oneandonlydean ready for eyes — a CI guard that fails when a test executable is built but no test runs it. The earlier linux=CANCELLED was a superseded run; current checks are green.
adriadam10 commented 2026-10-08 09:42:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T09:42:12Z.


Checked on a fresh Release/Ninja configure of the branch rebased onto current main: 388 test executable(s), 4 built and not run as recorded, none new (exit 0) in 0.4 s, before the build starts; removing guest_scan_count_tests from the generated CTestTestfile.cmake makes it fail with exit 1. Linux and Windows jobs were green on the previous head.

Added on top of your commits (rebased on main; the only conflict was the configure line in build.yml, now with -DANYPS5_ENABLE_SPIRV_TOOLS=ON, both kept):

  • agc_driver_bda_device_tests is registered on main now, so its KNOWN_UNRUN entry would hide a future loss of that registration. Removed it, and the script now also fails when a KNOWN_UNRUN entry is run by ctest, so the list can't go stale (checked: exit 1 with a registered test added to the list).

Merging once CI is green on the rebased head.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6057106486 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1257#issuecomment-6057106486). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-08T09:42:12Z. --- Checked on a fresh Release/Ninja configure of the branch rebased onto current `main`: `388 test executable(s), 4 built and not run as recorded, none new` (exit 0) in 0.4 s, before the build starts; removing `guest_scan_count_tests` from the generated `CTestTestfile.cmake` makes it fail with exit 1. Linux and Windows jobs were green on the previous head. Added on top of your commits (rebased on `main`; the only conflict was the configure line in `build.yml`, now with `-DANYPS5_ENABLE_SPIRV_TOOLS=ON`, both kept): - `agc_driver_bda_device_tests` is registered on `main` now, so its `KNOWN_UNRUN` entry would hide a future loss of that registration. Removed it, and the script now also fails when a `KNOWN_UNRUN` entry is run by ctest, so the list can't go stale (checked: exit 1 with a registered test added to the list). Merging once CI is green on the rebased head.
adriadam10 commented 2026-10-08 10:03:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T10:03:01Z.


My stale-entry check broke the Windows job: guest_formatting_tests is only registered on Windows and windows_exception_tests only exists there, so both are run by ctest on Windows and were reported as stale. Pushed 464f673: the not-run list is now per platform (guest_formatting_tests only off Windows, windows_exception_tests dropped). Linux passes locally; the Windows log of the last run shows exactly the three remaining entries as not run. Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6057450590 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1257#issuecomment-6057450590). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-08T10:03:01Z. --- My stale-entry check broke the Windows job: `guest_formatting_tests` is only registered on Windows and `windows_exception_tests` only exists there, so both are run by ctest on Windows and were reported as stale. Pushed 464f673: the not-run list is now per platform (`guest_formatting_tests` only off Windows, `windows_exception_tests` dropped). Linux passes locally; the Windows log of the last run shows exactly the three remaining entries as not run. Merging once CI is green.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!1257
No description provided.