test(tools): write the debt-length fixture with LF line endings #11985

Merged
maskym merged 2 commits from upstream-pr/11985 into main 2026-10-28 14:34:35 +00:00
maskym commented 2026-10-27 14:47:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by maskym on 2026-10-27T14:47:31Z.


What

conventions_debt_length fails on native Windows Python: test_added_long_entry_warns_without_failing writes its fixture with Path.write_text, which translates \n to the platform newline, so the committed libSceExample.md holds CRLF and the checker counts the carriage return in the long entry (1080 characters instead of 1079). The fixture is now written with newline="\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.py fails on main with 1080 characters != 1079 characters and passes with this change; ctest -R conventions_debt_length likewise. python tools/check_conventions.py --base origin/main passes. Not run on Linux, where write_text already writes LF and the test passed before.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5035920142 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11985). Originally posted by [maskym](https://github.com/maskym) on 2026-10-27T14:47:31Z. --- ### What `conventions_debt_length` fails on native Windows Python: `test_added_long_entry_warns_without_failing` writes its fixture with `Path.write_text`, which translates `\n` to the platform newline, so the committed `libSceExample.md` holds CRLF and the checker counts the carriage return in the long entry (`1080 characters` instead of `1079`). The fixture is now written with `newline="\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.py` fails on `main` with `1080 characters != 1079 characters` and passes with this change; `ctest -R conventions_debt_length` likewise. `python tools/check_conventions.py --base origin/main` passes. Not run on Linux, where `write_text` already writes LF and the test passed before. ### 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: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
rooklz commented 2026-10-27 15:00:21 +00:00 (Migrated from github.com)

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 -U0 text (Check.__init__ → self.added → debt_entries() → long_debt_entry), not from a re-read of the file — so a CRLF blob keeps its \r inside the counted entry and the fixture's committed LONG grows by exactly one character.

RED reproduced (base 1089f2bbfd): ran the module under a wrapper that gives Path.write_text Windows semantics (translate \n → \r\n when newline is unset, no translation when set — the equivalent of Windows Python with core.autocrlf=false). Result is byte-for-byte the reported failure:

- [('debt-length', 'docs/dev/debt/libSceExample.md', 8, '1080 characters')]
+ [('debt-length', 'docs/dev/debt/libSceExample.md', 8, '1079 characters')]
FAILED (failures=1)

Plain base run passes on macOS (false green — os.linesep is 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 of core.autocrlf). Merged current main 2ee8e9751a into the branch: clean, debt-length module still 2/2.

Gates: check_conventions.py --base origin/main PASS on the branch; pr_overlap reports no overlap with any open PR.

Scope check: the exact-character-count assertion is unique to this test among the write_text fixture writers in tools/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 with core.autocrlf=false committing a CRLF debt file would see inflated counts on real entries too — normalizing \r at the added-line boundary would be a separate, behaviour-level change.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5669284819 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11985#pullrequestreview-5669284819). Originally posted by [rooklz](https://github.com/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 -U0` text (`Check.__init__` → `self.added` → `debt_entries()` → `long_debt_entry`), not from a re-read of the file — so a CRLF blob keeps its `\r` inside the counted entry and the fixture's committed `LONG` grows by exactly one character. **RED reproduced (base `1089f2bbfd`):** ran the module under a wrapper that gives `Path.write_text` Windows semantics (translate `\n` → `\r\n` when `newline` is unset, no translation when set — the equivalent of Windows Python with `core.autocrlf=false`). Result is byte-for-byte the reported failure: ``` - [('debt-length', 'docs/dev/debt/libSceExample.md', 8, '1080 characters')] + [('debt-length', 'docs/dev/debt/libSceExample.md', 8, '1079 characters')] FAILED (failures=1) ``` Plain base run passes on macOS (false green — `os.linesep` is 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 of `core.autocrlf`). Merged current `main` `2ee8e9751a` into the branch: clean, debt-length module still 2/2. **Gates:** `check_conventions.py --base origin/main` PASS on the branch; `pr_overlap` reports no overlap with any open PR. Scope check: the exact-character-count assertion is unique to this test among the `write_text` fixture writers in `tools/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 with `core.autocrlf=false` committing a CRLF debt file would see inflated counts on real entries too — normalizing `\r` at the added-line boundary would be a separate, behaviour-level change. AI-assisted: yes
MarcZX10 commented 2026-10-27 15:34:27 +00:00 (Migrated from github.com)

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"), whose newline parameter 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 with write_bytes(text.encode("utf-8")) or open the file with newline="\\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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5669862769 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11985#pullrequestreview-5669862769). Originally posted by [MarcZX10](https://github.com/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")`, whose `newline` parameter 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 with `write_bytes(text.encode("utf-8"))` or open the file with `newline="\\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.
MarcZX10 commented 2026-10-27 18:10:52 +00:00 (Migrated from github.com)

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-only Path.write_text(newline=...) argument and writes the intended LF bytes across the documented Python 3.9+ range. I applied the updated diff to current main and ran python3 tools/tests/test_check_conventions_debt_length.py (2/2 passed); git diff --check passed 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 head cee4a89e3478c5ca8360cc49779af098b4da8f87.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5672107885 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11985#pullrequestreview-5672107885). Originally posted by [MarcZX10](https://github.com/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-only `Path.write_text(newline=...)` argument and writes the intended LF bytes across the documented Python 3.9+ range. I applied the updated diff to current `main` and ran `python3 tools/tests/test_check_conventions_debt_length.py` (2/2 passed); `git diff --check` passed 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 head `cee4a89e3478c5ca8360cc49779af098b4da8f87`.
rooklz commented 2026-10-28 03:03:03 +00:00 (Migrated from github.com)

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 on ca88396896). Tested on macOS 26.2, arm64, merged onto main 09d952f0eb.

The only change since my review is the fixture write, which now uses write_bytes(text.encode("utf-8")) (one line). I ran tools/tests/test_check_conventions_debt_length.py on its own with -I:

Python main ca88396896 cee4a89e34
3.9.6 (/usr/bin/python3) OK FAILED (errors=1, newline= is 3.10+) OK
3.12 / 3.13 / 3.14 OK OK OK

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/main passed. pr_overlap --branch reports no overlap. git merge-tree with main is clean. On the merged tree I did a fresh relinker-only build (266/266), and ctest passes 366/366, including conventions_debt_length.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5677262140 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11985#pullrequestreview-5677262140). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-28T03:03:03Z. **Review:** APPROVED --- Re-review of the new head `cee4a89e34` (my earlier approval was on `ca88396896`). Tested on macOS 26.2, arm64, merged onto `main` `09d952f0eb`. The only change since my review is the fixture write, which now uses `write_bytes(text.encode("utf-8"))` (one line). I ran `tools/tests/test_check_conventions_debt_length.py` on its own with `-I`: | Python | main | `ca88396896` | `cee4a89e34` | |---|---|---|---| | 3.9.6 (`/usr/bin/python3`) | OK | **FAILED** (errors=1, `newline=` is 3.10+) | OK | | 3.12 / 3.13 / 3.14 | OK | OK | OK | 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/main` passed. `pr_overlap --branch` reports no overlap. `git merge-tree` with main is clean. On the merged tree I did a fresh relinker-only build (266/266), and ctest passes 366/366, including `conventions_debt_length`.
THEMANnt commented 2026-10-28 04:25:13 +00:00 (Migrated from github.com)

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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5677775793 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11985#pullrequestreview-5677775793). Originally posted by [THEMANnt](https://github.com/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.
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!11985
No description provided.