test(tools): write the debt-length fixture with LF line endings #11985
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11985"
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 maskym on 2026-10-27T14:47:31Z.
What
conventions_debt_lengthfails on native Windows Python:test_added_long_entry_warns_without_failingwrites its fixture withPath.write_text, which translates\nto the platform newline, so the committedlibSceExample.mdholds CRLF and the checker counts the carriage return in the long entry (1080 charactersinstead of1079). The fixture is now written withnewline="\n", which is what the test asserts against.Tested
Windows 11, python.org Python 3.13.5, WinLibs GCC 15.2.0 build with
BUILD_TESTING=ON.python tools/tests/test_check_conventions_debt_length.pyfails onmainwith1080 characters != 1079 charactersand passes with this change;ctest -R conventions_debt_lengthlikewise.python tools/check_conventions.py --base origin/mainpasses. Not run on Linux, wherewrite_textalready writes LF and the test passed before.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-27T15:00:21Z.
Review: APPROVED
Verified on macOS (Python 3.13), including a reproduction of the Windows failure mode.
Mechism trace (checker side): the debt-length check counts characters of added diff lines from
git diff -U0text (Check.__init__→self.added→debt_entries()→long_debt_entry), not from a re-read of the file — so a CRLF blob keeps its\rinside the counted entry and the fixture's committedLONGgrows by exactly one character.RED reproduced (base
1089f2bbfd): ran the module under a wrapper that givesPath.write_textWindows semantics (translate\n→\r\nwhennewlineis unset, no translation when set — the equivalent of Windows Python withcore.autocrlf=false). Result is byte-for-byte the reported failure:Plain base run passes on macOS (false green —
os.linesepis LF here), which matches "Not run on Linux, where the test passed before".GREEN (head
022b49fe3b): module passes both plain and under the same Windows-simulation wrapper (newline="\n"short-circuits the translation, so the fixture is LF on every platform and independent ofcore.autocrlf). Merged currentmain2ee8e9751ainto the branch: clean, debt-length module still 2/2.Gates:
check_conventions.py --base origin/mainPASS on the branch;pr_overlapreports no overlap with any open PR.Scope check: the exact-character-count assertion is unique to this test among the
write_textfixture writers intools/tests(the others feed JSON/JS to parsers indifferent to a trailing\r), so the one-line fix is the right minimal scope. Non-blocking observation for a future discussion, not this PR: the checker itself counts raw diff text, so a contributor on Windows withcore.autocrlf=falsecommitting a CRLF debt file would see inflated counts on real entries too — normalizing\rat the added-line boundary would be a separate, behaviour-level change.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T15:34:27Z.
Review: CHANGES_REQUESTED
The fixture correction addresses the Windows CRLF failure, but this test now calls
Path.write_text(..., newline="\\n"), whosenewlineparameter was added in Python 3.10. The repository build guide says Python 3.9 or newer enables the Python regression tests (docs/dev/BUILD.md, Python requirements section), so this introduces a failure on a documented supported interpreter before the test can run. Please preserve LF bytes withwrite_bytes(text.encode("utf-8"))or open the file withnewline="\\n"; both avoid platform newline translation without requiring Python 3.10. The current hosted checks are green, but they do not cover the documented Python 3.9 case.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T18:10:52Z.
Review: APPROVED
Thanks for updating the fixture to
write_bytes(text.encode("utf-8")). This avoids the Python 3.10-onlyPath.write_text(newline=...)argument and writes the intended LF bytes across the documented Python 3.9+ range. I applied the updated diff to currentmainand ranpython3 tools/tests/test_check_conventions_debt_length.py(2/2 passed);git diff --checkpassed and the merge preview is clean. The author reports the Windows Python 3.13 reproduction now passes, and the current conventions/labels checks are green. Approved at headcee4a89e3478c5ca8360cc49779af098b4da8f87.Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-28T03:03:03Z.
Review: APPROVED
Re-review of the new head
cee4a89e34(my earlier approval was onca88396896). Tested on macOS 26.2, arm64, merged ontomain09d952f0eb.The only change since my review is the fixture write, which now uses
write_bytes(text.encode("utf-8"))(one line). I rantools/tests/test_check_conventions_debt_length.pyon its own with-I:ca88396896cee4a89e34/usr/bin/python3)newline=is 3.10+)So the new head fixes the 3.9 break that oneandonlydean raised.
I also checked that it still covers the Windows case. I rewrote the fixture to write CRLF bytes, the same effect as text-mode translation on Windows, and the test fails (failures=1). The test does see the line-ending miscount. With the head's byte write it passes on every interpreter above, so the result no longer depends on platform newline translation.
Gates:
check_conventions --base upstream/mainpassed.pr_overlap --branchreports no overlap.git merge-treewith main is clean. On the merged tree I did a fresh relinker-only build (266/266), and ctest passes 366/366, includingconventions_debt_length.Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-28T04:25:13Z.
Review: COMMENTED
Reviewed
cee4a89e3478c5ca8360cc49779af098b4da8f87— comment; validation remains incomplete. The debt-length fixture now writes explicit LF bytes; its Windows regression passes, but Build awaits authorization.Windows/Python 3.11: head 2 passed (2 total); author base 2 passed (2 total). The same two-test module fails one assertion on the author base and passes both on head. This removes host newline translation from a byte-count fixture; it does not change production debt checking. Complete the authorized hosted Build before final approval.