Skip to content

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

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
roboterspinne:fix/tools-ctest-index-newline
Nov 2, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
roboterspinne:fix/tools-ctest-index-newline

Conversation

@roboterspinne

Copy link
Copy Markdown
Contributor

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 26fa121). 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; fix(ci): select the tests build-wide inputs reach on the Windows pull request path #14317 and fix(ci): run every guest test when a CMake fragment under core/libs changes #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 26fa121 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 macOS support #1; 0,0,0,2,12 lists macOS support #1 and fix(build): register relinker tests with CTest #2, while 0,0,0,2,12\n and 0,0,0,2,12\r\n both list fix(build): register relinker tests with CTest #2 and WIP: The Smurfs Dreams on Linux, first frames (stacked on #5) #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)

…ll request job runs the last selected guest test

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@zaryabzip

Copy link
Copy Markdown
Contributor

A live case of what this fixes, from #14636's hosted Windows runs at 38fc459 and 5ab18d0:

Local checks at the same configure:

AI-assisted: yes (Claude Code)

@oneandonlydean oneandonlydean self-assigned this Nov 2, 2026
@oneandonlydean
oneandonlydean merged commit 784ab09 into boykopovar:main Nov 2, 2026
13 checks passed
@roboterspinne
roboterspinne deleted the fix/tools-ctest-index-newline branch November 2, 2026 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants