test(tools): cover prepare_release_notes truncation and file output #6693

Merged
bappisinsane merged 2 commits from upstream-pr/6693 into main 2026-10-19 08:43:39 +00:00
bappisinsane commented 2026-10-16 05:06:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by bappisinsane on 2026-10-16T05:06:04Z.


What

Adds edge-case tests to ReleaseNotesTests' module tools/tests/test_package_release.py (ctest release_package) for prepare_release_notes:

  • non-string body raises ValueError
  • main() with valid arguments writes both files, and exits on missing arguments
  • parent directories of the outputs are created
  • a body over the limit with no "What's Changed" section is returned unchanged
  • the "Full Changelog" link survives truncation

Tested

python3 -m unittest tools/tests/test_package_release.py: all tests pass.

Checklist

  • Based on current main; no other open PR implements the same tests.
  • No production code change; test-only.
  • No silent stubs, no non-standard extensions, no code comments.
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4883759911 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6693). Originally posted by [bappisinsane](https://github.com/bappisinsane) on 2026-10-16T05:06:04Z. --- ### What Adds edge-case tests to `ReleaseNotesTests`' module `tools/tests/test_package_release.py` (ctest `release_package`) for `prepare_release_notes`: - non-string `body` raises `ValueError` - `main()` with valid arguments writes both files, and exits on missing arguments - parent directories of the outputs are created - a body over the limit with no "What's Changed" section is returned unchanged - the "Full Changelog" link survives truncation ### Tested `python3 -m unittest tools/tests/test_package_release.py`: all tests pass. ### Checklist - [x] Based on current main; no other open PR implements the same tests. - [x] No production code change; test-only. - [x] No silent stubs, no non-standard extensions, no code comments. - [x] Depends on: none - [x] AI-assisted: yes
jotitadev commented 2026-10-16 05:36:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-16T05:36:04Z.

Review: COMMENTED


Ran this on macOS, head f4c449832, base main 5d9dcc42d. Three things:

1. The new file is not registered in CMake, so ctest and CI never run it. Every other file in tools/tests/ (37 of 37) has an add_test in the root CMakeLists.txt; test_prepare_release_notes.py has none, and the PR doesn't touch any CMakeLists.txt.

2. prepare_release_notes.py already has tests. ReleaseNotesTests in tools/tests/test_package_release.py (ctest release_package) covers release_body (unchanged at the limit, including a Unicode body of exactly 125000 characters; only the "What's Changed" section removed, with \n and \r\n, with and without "New Contributors" and "Full Changelog"; an oversized remainder left as is) and prepare_notes (byte-exact full and body files, written into a dist/ subdirectory that doesn't exist yet). What this file adds is the non-string body ValueError and the main() argument parsing; those could go in that class instead.

3. With Python 3.9.6 (Xcode's /usr/bin/python3), 4 of the 12 tests error:

TypeError: write_text() got an unexpected keyword argument 'newline'

in test_writes_full_and_body_files, test_truncated_body_is_written_to_body_file, test_creates_parent_directories and test_main_with_valid_arguments. The cause is not in this PR: prepare_notes calls Path.write_text(..., newline=""), which is Python 3.10+, and it already makes release_package fail on 3.9 (x86_64 build configured with -DPython3_EXECUTABLE=/usr/bin/python3: 170/173, release_package among the 3). With prepare_notes writing full.write_bytes(notes.encode("utf-8")) and body.write_bytes(release_body(notes).encode("utf-8")), which keeps the output byte for byte, this file passes 12/12 on 3.9.6 and on 3.14.7.

Machine: Apple M2 Max, macOS 27.2 (26B5091g). Method: python3 -I tools/tests/test_prepare_release_notes.py with /usr/bin/python3 (3.9.6) and Homebrew python3 (3.14.7), on this head and with the write_bytes change above; relinker-only ctest arm64 and x86_64 under Rosetta.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5543491835 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6693#pullrequestreview-5543491835). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-16T05:36:04Z. **Review:** COMMENTED --- Ran this on macOS, head `f4c449832`, base `main` 5d9dcc42d. Three things: **1. The new file is not registered in CMake, so ctest and CI never run it.** Every other file in `tools/tests/` (37 of 37) has an `add_test` in the root `CMakeLists.txt`; `test_prepare_release_notes.py` has none, and the PR doesn't touch any `CMakeLists.txt`. **2. `prepare_release_notes.py` already has tests.** `ReleaseNotesTests` in `tools/tests/test_package_release.py` (ctest `release_package`) covers `release_body` (unchanged at the limit, including a Unicode body of exactly 125000 characters; only the "What's Changed" section removed, with `\n` and `\r\n`, with and without "New Contributors" and "Full Changelog"; an oversized remainder left as is) and `prepare_notes` (byte-exact full and body files, written into a `dist/` subdirectory that doesn't exist yet). What this file adds is the non-string `body` `ValueError` and the `main()` argument parsing; those could go in that class instead. **3. With Python 3.9.6 (Xcode's `/usr/bin/python3`), 4 of the 12 tests error:** ``` TypeError: write_text() got an unexpected keyword argument 'newline' ``` in `test_writes_full_and_body_files`, `test_truncated_body_is_written_to_body_file`, `test_creates_parent_directories` and `test_main_with_valid_arguments`. The cause is not in this PR: `prepare_notes` calls `Path.write_text(..., newline="")`, which is Python 3.10+, and it already makes `release_package` fail on 3.9 (x86_64 build configured with `-DPython3_EXECUTABLE=/usr/bin/python3`: 170/173, `release_package` among the 3). With `prepare_notes` writing `full.write_bytes(notes.encode("utf-8"))` and `body.write_bytes(release_body(notes).encode("utf-8"))`, which keeps the output byte for byte, this file passes 12/12 on 3.9.6 and on 3.14.7. Machine: Apple M2 Max, macOS 27.2 (26B5091g). Method: `python3 -I tools/tests/test_prepare_release_notes.py` with `/usr/bin/python3` (3.9.6) and Homebrew `python3` (3.14.7), on this head and with the `write_bytes` change above; relinker-only ctest arm64 and x86_64 under Rosetta. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
MarcZX10 commented 2026-10-16 07:30:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T07:30:36Z.


The latest conventions run fails because the PR body leaves two required template fields unanswered: Depends on needs #N or none, and AI-assisted needs yes or no (see the annotations on run 38854018878). The earlier review also identifies that this new test file is not registered with CTest and overlaps existing release_package coverage; worth addressing those alongside the Python 3.9 compatibility report.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6210435374 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6693#issuecomment-6210435374). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T07:30:36Z. --- The latest conventions run fails because the PR body leaves two required template fields unanswered: `Depends on` needs `#N` or `none`, and `AI-assisted` needs `yes` or `no` (see the annotations on run 38854018878). The earlier review also identifies that this new test file is not registered with CTest and overlaps existing `release_package` coverage; worth addressing those alongside the Python 3.9 compatibility report.
MarcZX10 commented 2026-10-16 07:50:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T07:50:35Z.


I opened #6728 with the production fix for the Python 3.9 Path.write_text(newline=...) failure. It uses UTF-8 write_bytes, preserving the byte-exact behavior already covered by release_package tests. The test-registration and overlap points from the review above remain separate.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6210747983 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6693#issuecomment-6210747983). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T07:50:35Z. --- I opened #6728 with the production fix for the Python 3.9 `Path.write_text(newline=...)` failure. It uses UTF-8 `write_bytes`, preserving the byte-exact behavior already covered by `release_package` tests. The test-registration and overlap points from the review above remain separate.
MarcZX10 commented 2026-10-16 12:26:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T12:26:50Z.


The current conventions run fails only because the checklist is missing the required Depends on: #N or Depends on: none and AI-assisted: yes/no entries. The What, Tested and Checklist sections are present; adding those two checklist answers should satisfy the reported template errors.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6215478340 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6693#issuecomment-6215478340). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T12:26:50Z. --- The current conventions run fails only because the checklist is missing the required `Depends on: #N` or `Depends on: none` and `AI-assisted: yes/no` entries. The `What`, `Tested` and `Checklist` sections are present; adding those two checklist answers should satisfy the reported template errors.
MarcZX10 commented 2026-10-16 12:34:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T12:34:53Z.


One remaining review point on the current head: this PR only adds tools/tests/test_prepare_release_notes.py; it does not register the file with CTest, and the existing ReleaseNotesTests in tools/tests/test_package_release.py already cover the release-body truncation and output-writing behavior. Could you move the genuinely new cases (non-string input and CLI argument parsing) into that existing test module, or register the new file and keep only non-overlapping cases? The Python 3.9 write_text(newline=...) production issue is separately covered by #6728.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6215612919 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6693#issuecomment-6215612919). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T12:34:53Z. --- One remaining review point on the current head: this PR only adds `tools/tests/test_prepare_release_notes.py`; it does not register the file with CTest, and the existing `ReleaseNotesTests` in `tools/tests/test_package_release.py` already cover the release-body truncation and output-writing behavior. Could you move the genuinely new cases (non-string input and CLI argument parsing) into that existing test module, or register the new file and keep only non-overlapping cases? The Python 3.9 `write_text(newline=...)` production issue is separately covered by #6728.
github-actions[bot] commented 2026-10-19 05:58:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T05:58:24Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5797 tools/tests/test_package_release.py
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6260724459 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6693#issuecomment-6260724459). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T05:58:24Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 5797](https://www.github.com/boykopovar/AnyPS5/pull/5797) | `tools/tests/test_package_release.py` |
adriadam10 commented 2026-10-19 08:44:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T08:44:34Z.


Checked the tests against tools/prepare_release_notes.py: they now live in the registered release_package module, no duplication with the existing cases, and each pins real behaviour (non-string body error, main() args, parent dir creation, no-op truncation without the section, Full Changelog kept). I also fixed the PR body template (literal \ns made Conventions fail). Merged.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6263284519 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6693#issuecomment-6263284519). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-19T08:44:34Z. --- Checked the tests against `tools/prepare_release_notes.py`: they now live in the registered `release_package` module, no duplication with the existing cases, and each pins real behaviour (non-string body error, `main()` args, parent dir creation, no-op truncation without the section, Full Changelog kept). I also fixed the PR body template (literal `\n`s made Conventions fail). Merged.
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!6693
No description provided.