fix(tools): end the CTest index file with a newline so the Windows pull request job runs the last selected guest test #14413

Merged
roboterspinne merged 1 commit from upstream-pr/14413 into main 2026-11-02 19:50:16 +00:00
roboterspinne commented 2026-11-01 11:52:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by roboterspinne on 2026-11-01T11:52:06Z.


What

The Windows pull request job runs the changed guest tests through tools/build_changed_guest_tests.py (.github/workflows/build.yml:710), which writes the selected CTest indices to a file and passes it as ctest -I <file>. run() writes that file as "0,0,0," + indices without a line terminator (tools/build_changed_guest_tests.py:122 on 26fa1212b8). CTest reads an -I file with fin.getline(buff.get(), filelen) in cmCTestTestHandler::SetTestsToRunInformation (Source/CTest/cmCTestTestHandler.cxx:2256), where filelen is the file size; istream::getline(s, n) stores at most n - 1 characters, so without a terminator the last character of the file is lost. The last selected index is then dropped, or loses its last digit and selects an unrelated test, and a selection of one single-digit index runs nothing, which --no-tests=error turns into a failed job. Windows job 124800901029 (run 41290189739, feat/libc-numpunct-vtable) built guest_locale_tests.exe, then ran only Test #72: select_tests_SelectGraphStateTests and reported 0 tests failed out of 1. The repository's other CTest index file already ends with a newline: tools/select_tests.py:389 writes select.tests as "0,0,0," + ... + "\n".

  • Rule. run() ends the index file with "\n", so getline stops at the terminator and keeps every index. On Windows write_text writes it as \r\n; CTest 4.3.1 selects the same tests for \n and \r\n. The selection logic, the ctest command and its flags are unchanged.
  • Tests. test_ctest_index_file_runs_only_resolved_tests checked only the file content, so it passed on main although only one of its two selected tests ran. It is replaced by test_ctest_index_file_runs_every_resolved_test, which registers one unrelated test (cmake -E touch unrelated) and 11 selected tests named selected [N].+, each writing a ran-N marker with sys.executable, so the last index (12) has two digits; it drives the real ctest through run() and asserts that all 11 markers exist and that unrelated did not run. The expected index files of test_mixed_argument_bearing_and_argumentless_tests_all_run and test_selected_target_with_a_renamed_executable_runs_its_ctest gain the "\n".
  • Overlap. pr_overlap.py --branch finds no shared lines with the open pull requests and none it cannot compare; #14317 and #14315 also change tools/build_changed_guest_tests.py and its tests, but in other lines, and both merge cleanly with this branch. My pull request "ci(build): write ctest.log on the Windows pull request path so tests over 30 s are reported" changes the same file and its tests in other lines; a trial merge of the two branches is clean.

Tested

Windows 11, WinLibs GCC 15.2.0 (CTest 4.3.1 from the same WinLibs package), Python 3.13.9; synthetic CTest files only, no title or homebrew. No C++ build is needed.

  • python tools/tests/test_build_changed_guest_tests.py -v (registered as the build_changed_guest_tests CTest test, CMakeLists.txt:196): Ran 19 tests in 2.836s, OK (skipped=1) (the symbolic link test skips without the Windows symlink privilege, as on main).
  • Counter-check: the new test file against the untouched tools/build_changed_guest_tests.py of 26fa1212b8 fails 3 tests: test_ctest_index_file_runs_every_resolved_test with ran-10 missing from the markers, and the two "\n" expectations (['0,0,0,1,2,3'] != ['0,0,0,1,2,3\n'], ['0,0,0,1'] != ['0,0,0,1\n']). With the one-line change all pass.
  • ctest -N -I <file> against a 12-test CTestTestfile.cmake: 0,0,0,1 lists 0 tests and 0,0,0,1\n lists #1; 0,0,0,2,12 lists #1 and #2, while 0,0,0,2,12\n and 0,0,0,2,12\r\n both list #2 and #12.
  • python tools/check_conventions.py --base 26fa1212b8 --head HEAD with this title and description passed.
  • Not tested on Linux or macOS; the new test uses only sys.executable and cmake -E, and CI runs it on all three hosts.

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 under Silent stubs in their library's technical debt file
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5107062438 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14413). Originally posted by [roboterspinne](https://github.com/roboterspinne) on 2026-11-01T11:52:06Z. --- ### What The Windows pull request job runs the changed guest tests through `tools/build_changed_guest_tests.py` (`.github/workflows/build.yml:710`), which writes the selected CTest indices to a file and passes it as `ctest -I <file>`. `run()` writes that file as `"0,0,0," + indices` without a line terminator (`tools/build_changed_guest_tests.py:122` on 26fa1212b8). CTest reads an `-I` file with `fin.getline(buff.get(), filelen)` in `cmCTestTestHandler::SetTestsToRunInformation` ([Source/CTest/cmCTestTestHandler.cxx:2256](https://github.com/Kitware/CMake/blob/8e91f7aa9bdf7eb8f8b009acda1576049881bc4f/Source/CTest/cmCTestTestHandler.cxx#L2252-L2258)), where `filelen` is the file size; `istream::getline(s, n)` stores at most `n - 1` characters, so without a terminator the last character of the file is lost. The last selected index is then dropped, or loses its last digit and selects an unrelated test, and a selection of one single-digit index runs nothing, which `--no-tests=error` turns into a failed job. Windows job 124800901029 (run 41290189739, `feat/libc-numpunct-vtable`) built `guest_locale_tests.exe`, then ran only `Test #72: select_tests_SelectGraphStateTests` and reported `0 tests failed out of 1`. The repository's other CTest index file already ends with a newline: `tools/select_tests.py:389` writes `select.tests` as `"0,0,0," + ... + "\n"`. - **Rule.** `run()` ends the index file with `"\n"`, so `getline` stops at the terminator and keeps every index. On Windows `write_text` writes it as `\r\n`; CTest 4.3.1 selects the same tests for `\n` and `\r\n`. The selection logic, the `ctest` command and its flags are unchanged. - **Tests.** `test_ctest_index_file_runs_only_resolved_tests` checked only the file content, so it passed on `main` although only one of its two selected tests ran. It is replaced by `test_ctest_index_file_runs_every_resolved_test`, which registers one `unrelated` test (`cmake -E touch unrelated`) and 11 selected tests named `selected [N].+`, each writing a `ran-N` marker with `sys.executable`, so the last index (12) has two digits; it drives the real `ctest` through `run()` and asserts that all 11 markers exist and that `unrelated` did not run. The expected index files of `test_mixed_argument_bearing_and_argumentless_tests_all_run` and `test_selected_target_with_a_renamed_executable_runs_its_ctest` gain the `"\n"`. - **Overlap.** `pr_overlap.py --branch` finds no shared lines with the open pull requests and none it cannot compare; #14317 and #14315 also change `tools/build_changed_guest_tests.py` and its tests, but in other lines, and both merge cleanly with this branch. My pull request "ci(build): write ctest.log on the Windows pull request path so tests over 30 s are reported" changes the same file and its tests in other lines; a trial merge of the two branches is clean. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11, WinLibs GCC 15.2.0 (CTest 4.3.1 from the same WinLibs package), Python 3.13.9; synthetic CTest files only, no title or homebrew. No C++ build is needed. - `python tools/tests/test_build_changed_guest_tests.py -v` (registered as the `build_changed_guest_tests` CTest test, `CMakeLists.txt:196`): `Ran 19 tests in 2.836s`, `OK (skipped=1)` (the symbolic link test skips without the Windows symlink privilege, as on `main`). - Counter-check: the new test file against the untouched `tools/build_changed_guest_tests.py` of 26fa1212b8 fails 3 tests: `test_ctest_index_file_runs_every_resolved_test` with `ran-10` missing from the markers, and the two `"\n"` expectations (`['0,0,0,1,2,3'] != ['0,0,0,1,2,3\n']`, `['0,0,0,1'] != ['0,0,0,1\n']`). With the one-line change all pass. - `ctest -N -I <file>` against a 12-test `CTestTestfile.cmake`: `0,0,0,1` lists 0 tests and `0,0,0,1\n` lists #1; `0,0,0,2,12` lists #1 and #2, while `0,0,0,2,12\n` and `0,0,0,2,12\r\n` both list #2 and #12. - `python tools/check_conventions.py --base 26fa1212b8 --head HEAD` with this title and description passed. - Not tested on Linux or macOS; the new test uses only `sys.executable` and `cmake -E`, and CI runs it on all three hosts. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes (Claude Code)
MarcZX10 commented 2026-11-01 13:44:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T13:44:01Z.

Review: COMMENTED


Reviewed — no blocking findings

The fix is correct: CTest reads the -I file with a getline sized to the file length, so the last index is dropped unless the file ends in a newline, and the change adds that newline with no other behaviour change.

What I ran

  • Exact head 1047f3d0e5673d01ff07ea2e7eb7241c47e25daf, base ba627802e2210187d417deb64c8f2fed8e33011f.
  • Environment: Linux, /usr/bin/python3 3.11.2, ctest 3.25.1 (/usr/bin/ctest), no build.
  • Precheck: python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14413 --output-dir /dev/shm/reviewer-run/precheck/14413
  • CTest behaviour, on a 12-test CTestTestfile with no build: a -I file with the index list and no terminator, one with \n, and one with \r\n:
none: 100% tests passed, 0 tests failed out of 11
lf: 100% tests passed, 0 tests failed out of 12
crlf: 100% tests passed, 0 tests failed out of 12
  • CTest source at Kitware commit 8e91f7aa9bdf7eb8f8b009acda1576049881bc4f, Source/CTest/cmCTestTestHandler.cxx lines 2254-2256 (FileLength, getline(buff.get(), filelen)), read with gh api.

Results

Precheck report, checks table, unedited (/dev/shm/reviewer-run/precheck/14413/report.md):

Check Status Command / reason
build_and_compile not_applicable The precheck deliberately does not configure, build, or compile AnyPS5.
diff_check passed git diff --check ba627802e2210187d417deb64c8f2fed8e33011f...1047f3d0e5673d01ff07ea2e7eb7241c47e25daf
conventions_and_pr_template passed /usr/bin/python3 tools/check_conventions.py --base ba627802e2210187d417deb64c8f2fed8e33011f --head 1047f3d0e5673d01ff07ea2e7eb7241c47e25daf --title fix(tools): end the CTest index file with a newline so the Windows pull request job runs the last selected guest test --body /dev/shm/reviewer-run/precheck/14413/pr-body.md
changed_export_abi_audit not_applicable No changed source or public header under core/libs/prx.
python_syntax passed /usr/bin/python3 -m py_compile tools/build_changed_guest_tests.py
unit:tools/tests/test_build_changed_guest_tests.py passed /usr/bin/python3 -m unittest tools.tests.test_build_changed_guest_tests
python_test_registration passed /usr/bin/python3 tools/check_test_registration.py --scripts
live_dependency_and_mergeability_check passed /usr/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 14413 --repo boykopovar/AnyPS5 --output-dir /dev/shm/reviewer-run/precheck/14413/stack
build_dependent_cpp_tests not_applicable No C/C++ implementation or test files changed.
test_quality_heuristics failed /usr/bin/python3 /dev/shm/reviewer-run/precheck/14413/head-1047f3d0e567-f72de141/tools/pr_test_quality.py --root /dev/shm/reviewer-run/precheck/14413/head-1047f3d0e567-f72de141 --json tools/build_changed_guest_tests.py tools/tests/test_build_changed_guest_tests.py
negative_controls passed A pass means every candidate failed by assertion on base; a failure means at least one did not discriminate or could not run. See per-test results.

Hosted at review time: windows in progress; macOS clang jobs queued; relinker, conventions and labels passed.

Negative control

The precheck's negative control for test_build_changed_guest_tests.py failed on base by assertion (rc 1), so the updated tests discriminate the change.

Findings

Blocking: none.

Non-blocking:

  • The PR says CTest 4.3.1 selects the same tests for \n and \r\n. I checked only ctest 3.25.1 on Linux. The Windows write_text path, which emits \r\n, was not run.
  • The new test runs the real ctest from the host PATH, so it needs ctest available wherever the unit tests run.

Sources

Not verified

  • ctest 4.3.1 and the Windows \r\n path were not run.
  • The Windows CI job was not complete at review time.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5728345639 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14413#pullrequestreview-5728345639). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-01T13:44:01Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The fix is correct: CTest reads the `-I` file with a `getline` sized to the file length, so the last index is dropped unless the file ends in a newline, and the change adds that newline with no other behaviour change. ## What I ran - Exact head `1047f3d0e5673d01ff07ea2e7eb7241c47e25daf`, base `ba627802e2210187d417deb64c8f2fed8e33011f`. - Environment: Linux, `/usr/bin/python3` 3.11.2, ctest 3.25.1 (`/usr/bin/ctest`), no build. - Precheck: `python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14413 --output-dir /dev/shm/reviewer-run/precheck/14413` - CTest behaviour, on a 12-test CTestTestfile with no build: a `-I` file with the index list and no terminator, one with `\n`, and one with `\r\n`: ``` none: 100% tests passed, 0 tests failed out of 11 lf: 100% tests passed, 0 tests failed out of 12 crlf: 100% tests passed, 0 tests failed out of 12 ``` - CTest source at Kitware commit `8e91f7aa9bdf7eb8f8b009acda1576049881bc4f`, `Source/CTest/cmCTestTestHandler.cxx` lines 2254-2256 (`FileLength`, `getline(buff.get(), filelen)`), read with `gh api`. ## Results Precheck report, checks table, unedited (`/dev/shm/reviewer-run/precheck/14413/report.md`): | Check | Status | Command / reason | |---|---|---| | build_and_compile | not_applicable | `The precheck deliberately does not configure, build, or compile AnyPS5.` | | diff_check | passed | `git diff --check ba627802e2210187d417deb64c8f2fed8e33011f...1047f3d0e5673d01ff07ea2e7eb7241c47e25daf` | | conventions_and_pr_template | passed | `/usr/bin/python3 tools/check_conventions.py --base ba627802e2210187d417deb64c8f2fed8e33011f --head 1047f3d0e5673d01ff07ea2e7eb7241c47e25daf --title fix(tools): end the CTest index file with a newline so the Windows pull request job runs the last selected guest test --body /dev/shm/reviewer-run/precheck/14413/pr-body.md` | | changed_export_abi_audit | not_applicable | `No changed source or public header under core/libs/prx.` | | python_syntax | passed | `/usr/bin/python3 -m py_compile tools/build_changed_guest_tests.py` | | unit:tools/tests/test_build_changed_guest_tests.py | passed | `/usr/bin/python3 -m unittest tools.tests.test_build_changed_guest_tests` | | python_test_registration | passed | `/usr/bin/python3 tools/check_test_registration.py --scripts` | | live_dependency_and_mergeability_check | passed | `/usr/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 14413 --repo boykopovar/AnyPS5 --output-dir /dev/shm/reviewer-run/precheck/14413/stack` | | build_dependent_cpp_tests | not_applicable | `No C/C++ implementation or test files changed.` | | test_quality_heuristics | failed | `/usr/bin/python3 /dev/shm/reviewer-run/precheck/14413/head-1047f3d0e567-f72de141/tools/pr_test_quality.py --root /dev/shm/reviewer-run/precheck/14413/head-1047f3d0e567-f72de141 --json tools/build_changed_guest_tests.py tools/tests/test_build_changed_guest_tests.py` | | negative_controls | passed | `A pass means every candidate failed by assertion on base; a failure means at least one did not discriminate or could not run. See per-test results.` | Hosted at review time: `windows` in progress; macOS clang jobs queued; relinker, conventions and labels passed. ## Negative control The precheck's negative control for `test_build_changed_guest_tests.py` failed on base by assertion (rc 1), so the updated tests discriminate the change. ## Findings **Blocking:** none. **Non-blocking:** - The PR says CTest 4.3.1 selects the same tests for `\n` and `\r\n`. I checked only ctest 3.25.1 on Linux. The Windows `write_text` path, which emits `\r\n`, was not run. - The new test runs the real `ctest` from the host PATH, so it needs ctest available wherever the unit tests run. ## Sources - CTest `-I` read, Kitware commit: https://github.com/Kitware/CMake/blob/8e91f7aa9bdf7eb8f8b009acda1576049881bc4f/Source/CTest/cmCTestTestHandler.cxx#L2252-L2258 ## Not verified - ctest 4.3.1 and the Windows `\r\n` path were not run. - The Windows CI job was not complete at review time.
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!14413
No description provided.