fix(tools): end the CTest index file with a newline so the Windows pull request job runs the last selected guest test #14413
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14413"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 asctest -I <file>.run()writes that file as"0,0,0," + indiceswithout a line terminator (tools/build_changed_guest_tests.py:122on26fa1212b8). CTest reads an-Ifile withfin.getline(buff.get(), filelen)incmCTestTestHandler::SetTestsToRunInformation(Source/CTest/cmCTestTestHandler.cxx:2256), wherefilelenis the file size;istream::getline(s, n)stores at mostn - 1characters, 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=errorturns into a failed job. Windows job 124800901029 (run 41290189739,feat/libc-numpunct-vtable) builtguest_locale_tests.exe, then ran onlyTest #72: select_tests_SelectGraphStateTestsand reported0 tests failed out of 1. The repository's other CTest index file already ends with a newline:tools/select_tests.py:389writesselect.testsas"0,0,0," + ... + "\n".run()ends the index file with"\n", sogetlinestops at the terminator and keeps every index. On Windowswrite_textwrites it as\r\n; CTest 4.3.1 selects the same tests for\nand\r\n. The selection logic, thectestcommand and its flags are unchanged.test_ctest_index_file_runs_only_resolved_testschecked only the file content, so it passed onmainalthough only one of its two selected tests ran. It is replaced bytest_ctest_index_file_runs_every_resolved_test, which registers oneunrelatedtest (cmake -E touch unrelated) and 11 selected tests namedselected [N].+, each writing aran-Nmarker withsys.executable, so the last index (12) has two digits; it drives the realctestthroughrun()and asserts that all 11 markers exist and thatunrelateddid not run. The expected index files oftest_mixed_argument_bearing_and_argumentless_tests_all_runandtest_selected_target_with_a_renamed_executable_runs_its_ctestgain the"\n".pr_overlap.py --branchfinds no shared lines with the open pull requests and none it cannot compare; #14317 and #14315 also changetools/build_changed_guest_tests.pyand 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 thebuild_changed_guest_testsCTest test,CMakeLists.txt:196):Ran 19 tests in 2.836s,OK (skipped=1)(the symbolic link test skips without the Windows symlink privilege, as onmain).tools/build_changed_guest_tests.pyof26fa1212b8fails 3 tests:test_ctest_index_file_runs_every_resolved_testwithran-10missing 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-testCTestTestfile.cmake:0,0,0,1lists 0 tests and0,0,0,1\nlists #1;0,0,0,2,12lists #1 and #2, while0,0,0,2,12\nand0,0,0,2,12\r\nboth list #2 and #12.python tools/check_conventions.py --base 26fa1212b8 --head HEADwith this title and description passed.sys.executableandcmake -E, and CI runs it on all three hosts.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)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
-Ifile with agetlinesized 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
1047f3d0e5673d01ff07ea2e7eb7241c47e25daf, baseba627802e2210187d417deb64c8f2fed8e33011f./usr/bin/python33.11.2, ctest 3.25.1 (/usr/bin/ctest), no build.python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14413 --output-dir /dev/shm/reviewer-run/precheck/14413-Ifile with the index list and no terminator, one with\n, and one with\r\n:8e91f7aa9bdf7eb8f8b009acda1576049881bc4f,Source/CTest/cmCTestTestHandler.cxxlines 2254-2256 (FileLength,getline(buff.get(), filelen)), read withgh api.Results
Precheck report, checks table, unedited (
/dev/shm/reviewer-run/precheck/14413/report.md):The precheck deliberately does not configure, build, or compile AnyPS5.git diff --check ba627802e2210187d417deb64c8f2fed8e33011f...1047f3d0e5673d01ff07ea2e7eb7241c47e25daf/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.mdNo changed source or public header under core/libs/prx./usr/bin/python3 -m py_compile tools/build_changed_guest_tests.py/usr/bin/python3 -m unittest tools.tests.test_build_changed_guest_tests/usr/bin/python3 tools/check_test_registration.py --scripts/usr/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 14413 --repo boykopovar/AnyPS5 --output-dir /dev/shm/reviewer-run/precheck/14413/stackNo C/C++ implementation or test files changed./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.pyA 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:
windowsin progress; macOS clang jobs queued; relinker, conventions and labels passed.Negative control
The precheck's negative control for
test_build_changed_guest_tests.pyfailed on base by assertion (rc 1), so the updated tests discriminate the change.Findings
Blocking: none.
Non-blocking:
\nand\r\n. I checked only ctest 3.25.1 on Linux. The Windowswrite_textpath, which emits\r\n, was not run.ctestfrom the host PATH, so it needs ctest available wherever the unit tests run.Sources
-Iread, Kitware commit:github.com/Kitware/CMake@8e91f7aa9b/Source/CTest/cmCTestTestHandler.cxx (L2252-L2258)Not verified
\r\npath were not run.