test(tools): add test coverage for check_test_registration #1623

Closed
Amirtheshwaran wants to merge 1 commit from upstream-pr/1623 into main
Amirtheshwaran commented 2026-10-08 15:06:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Amirtheshwaran on 2026-10-08T15:06:14Z.


What

Add unit test coverage for tools/check_test_registration.py, refactor its entrypoint for testability, and register the test suite in CMakeLists.txt.

  • Extract CLI execution block into main(argv=None) returning exit status (0 on success, 1 on error) and invoke via raise SystemExit(main()).
  • Explicitly decode subprocess output from ninja -t targets all and read CTestTestfile.cmake with encoding="utf-8", errors="replace" to prevent decode errors on non-UTF-8 host code pages.
  • Add tools/tests/test_check_test_registration.py covering:
    • built(): parses test executables from Ninja rules, strips .exe, and filters non-test targets.
    • registered(): recursively parses CTestTestfile.cmake across POSIX and Windows paths and handles argument tokens.
    • main(): validates CLI --list mode, failure on unconfigured/empty test directories, clean exit when unrun tests match KNOWN_UNRUN, failure on unregistered fresh executables, and failure on stale entries in KNOWN_UNRUN.
  • Register check_test_registration in root CMakeLists.txt under BUILD_TESTING.

Tested

Windows 11, Python 3.11:

  • python -m unittest discover -s tools/tests -v: 21 tests pass in 1.0s (including all 7 CheckTestRegistrationTests test cases).
  • python tools/check_conventions.py --base origin/main: passed (All conventions checks passed.).

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:4788811468 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1623). Originally posted by [Amirtheshwaran](https://github.com/Amirtheshwaran) on 2026-10-08T15:06:14Z. --- ### What Add unit test coverage for `tools/check_test_registration.py`, refactor its entrypoint for testability, and register the test suite in `CMakeLists.txt`. - Extract CLI execution block into `main(argv=None)` returning exit status (`0` on success, `1` on error) and invoke via `raise SystemExit(main())`. - Explicitly decode subprocess output from `ninja -t targets all` and read `CTestTestfile.cmake` with `encoding="utf-8", errors="replace"` to prevent decode errors on non-UTF-8 host code pages. - Add `tools/tests/test_check_test_registration.py` covering: - `built()`: parses test executables from Ninja rules, strips `.exe`, and filters non-test targets. - `registered()`: recursively parses `CTestTestfile.cmake` across POSIX and Windows paths and handles argument tokens. - `main()`: validates CLI `--list` mode, failure on unconfigured/empty test directories, clean exit when unrun tests match `KNOWN_UNRUN`, failure on unregistered fresh executables, and failure on stale entries in `KNOWN_UNRUN`. - Register `check_test_registration` in root `CMakeLists.txt` under `BUILD_TESTING`. ### Tested Windows 11, Python 3.11: - `python -m unittest discover -s tools/tests -v`: 21 tests pass in 1.0s (including all 7 `CheckTestRegistrationTests` test cases). - `python tools/check_conventions.py --base origin/main`: passed (`All conventions checks passed.`). ### 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
github-actions[bot] commented 2026-10-08 18:17:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-08T18:17:16Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#1741 CMakeLists.txt L43
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6066250638 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1623#issuecomment-6066250638). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-08T18:17:16Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #1741 | `CMakeLists.txt` [L43](https://github.com/boykopovar/AnyPS5/blob/f145139676a48306681d3a4d5fabf83938759daf/CMakeLists.txt#L43) | | |
oneandonlydean commented 2026-10-09 08:53:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T08:53:11Z.


Closing: this refactors check_test_registration.py so it can be unit-tested, but nothing in it is broken on main and the tests pass without the change. If you hit a real failure in the script (the code page case, for example), a PR with that failure and its fix is welcome.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6077682885 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1623#issuecomment-6077682885). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T08:53:11Z. --- Closing: this refactors `check_test_registration.py` so it can be unit-tested, but nothing in it is broken on main and the tests pass without the change. If you hit a real failure in the script (the code page case, for example), a PR with that failure and its fix is welcome.

Pull request closed

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!1623
No description provided.