test(tools): run debt_split in process and commit only where tests need it #10596

Merged
roboterspinne merged 1 commit from upstream-pr/10596 into main 2026-10-25 13:40:19 +00:00
roboterspinne commented 2026-10-24 11:54:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by roboterspinne on 2026-10-24T11:54:45Z.


What

tools/tests/test_debt_split.py started debt_split.py as a subprocess for each of the 15 splits made through its split() helper and committed the index in setUp and after every split, although only the rebase paths (rebase() and test_resolve_refuses_an_entry_main_changed_too) and test_resolve_needs_a_conflict depend on a commit. The test is the fourth slowest of the relinker suite on the Windows runner: 34.18 s in the relinker (windows-latest, g++) job of #10390's Build run, where CONTRIBUTING asks each test to finish in 30 s.

  • split() now calls debt_split.main(["split"]) in process: it changes into the fixture directory, hands the tool a sink for stdout and stderr so the tool's stream reconfiguration and output touch nothing of the test process, and restores the directory and both streams in finally. A failing split raises SystemExit, which unittest records as an error.
  • The add/commit pair moved from setUp and split() into a commit() helper. The rebase paths call it before creating the change branch and after the split, so the rebases see the same two commits as before, and test_resolve_needs_a_conflict calls it once so resolve still runs on a committed clean checkout.
  • The test's git wrapper passes -c maintenance.auto=false, so the commits (23 from the wrapper and 5 that rebase --continue makes) skip the git maintenance run --auto child each one spawned (44 per run on main).
  • test_split_again_appends_to_existing_files still runs one split through the command line and checks its stdout, and every resolve stays a subprocess. debt_split.py is unchanged, and the git commands it runs are identical before and after (strace: 24 rev-parse, 21 cat-file, 8 ls-files, 5 add in both).
  • No new imports; the open #10205 adds two imports and two tests at the end of this file and merges cleanly with this change (git merge-tree).

Tested

Ubuntu 24.04 x86_64, Python 3.13, git 2.43; no title or homebrew involved.

  • python3 tools/tests/test_debt_split.py: 16 tests OK. Wall time of three runs, same machine: main 3.07 / 2.90 / 3.02 s, this change 1.76 / 1.63 / 1.53 s. Processes started (successful execve under strace -f): 268 → 177, of which debt_split.py interpreter starts 24 → 9.
  • ctest --test-dir build-relinker -j4 (relinker-only Release build): 241/241 passed; debt_split alone 1.78 s (2.11 s under -j4).
  • Windows 11, same relinker-only build (MinGW-w64 GCC 15.2), ctest --test-dir build-relinker -R "^debt_split$": main 21.36 / 19.79 / 19.86 s (three runs), this change 13.45 s (one run).
  • Eleven mutations of debt_split.py (link rewriting off, index note dropped, title changed, blank lines dropped, BOM handling removed in two places, index not rewritten, CRLF output, continuation blanks dropped, empty debt file kept, nothing moved) fail the same tests with the main test file and with this one; two of them are caught by neither.
  • python3 tools/check_conventions.py --base upstream/main with this title and description passed.

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)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4995163136 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10596). Originally posted by [roboterspinne](https://github.com/roboterspinne) on 2026-10-24T11:54:45Z. --- ### What `tools/tests/test_debt_split.py` started `debt_split.py` as a subprocess for each of the 15 splits made through its `split()` helper and committed the index in `setUp` and after every split, although only the rebase paths (`rebase()` and `test_resolve_refuses_an_entry_main_changed_too`) and `test_resolve_needs_a_conflict` depend on a commit. The test is the fourth slowest of the relinker suite on the Windows runner: 34.18 s in the `relinker (windows-latest, g++)` job of #10390's [Build run](https://github.com/boykopovar/AnyPS5/actions/runs/40021721361), where CONTRIBUTING asks each test to finish in 30 s. - `split()` now calls `debt_split.main(["split"])` in process: it changes into the fixture directory, hands the tool a sink for stdout and stderr so the tool's stream reconfiguration and output touch nothing of the test process, and restores the directory and both streams in `finally`. A failing split raises `SystemExit`, which unittest records as an error. - The `add`/`commit` pair moved from `setUp` and `split()` into a `commit()` helper. The rebase paths call it before creating the change branch and after the split, so the rebases see the same two commits as before, and `test_resolve_needs_a_conflict` calls it once so `resolve` still runs on a committed clean checkout. - The test's `git` wrapper passes `-c maintenance.auto=false`, so the commits (23 from the wrapper and 5 that `rebase --continue` makes) skip the `git maintenance run --auto` child each one spawned (44 per run on `main`). - `test_split_again_appends_to_existing_files` still runs one split through the command line and checks its stdout, and every `resolve` stays a subprocess. `debt_split.py` is unchanged, and the git commands it runs are identical before and after (strace: 24 `rev-parse`, 21 `cat-file`, 8 `ls-files`, 5 `add` in both). - No new imports; the open #10205 adds two imports and two tests at the end of this file and merges cleanly with this change (`git merge-tree`). ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Ubuntu 24.04 x86_64, Python 3.13, git 2.43; no title or homebrew involved. - `python3 tools/tests/test_debt_split.py`: 16 tests OK. Wall time of three runs, same machine: `main` 3.07 / 2.90 / 3.02 s, this change 1.76 / 1.63 / 1.53 s. Processes started (successful `execve` under `strace -f`): 268 → 177, of which `debt_split.py` interpreter starts 24 → 9. - `ctest --test-dir build-relinker -j4` (relinker-only Release build): 241/241 passed; `debt_split` alone 1.78 s (2.11 s under `-j4`). - Windows 11, same relinker-only build (MinGW-w64 GCC 15.2), `ctest --test-dir build-relinker -R "^debt_split$"`: `main` 21.36 / 19.79 / 19.86 s (three runs), this change 13.45 s (one run). - Eleven mutations of `debt_split.py` (link rewriting off, index note dropped, title changed, blank lines dropped, BOM handling removed in two places, index not rewritten, CRLF output, continuation blanks dropped, empty debt file kept, nothing moved) fail the same tests with the `main` test file and with this one; two of them are caught by neither. - `python3 tools/check_conventions.py --base upstream/main` with this title and description passed. ### 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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes (Claude Code)
MarcZX10 commented 2026-10-24 12:02:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T12:02:00Z.

Review: APPROVED


Reviewed the exact head dad627e00c6515f82a33971fe1dc59b21996ad09. The split tests now run in-process with the fixture directory, stdout and stderr restored in finally; the one CLI split case remains a subprocess to cover command output. Commit creation remains only in the rebase/conflict cases that require a committed index, and maintenance.auto=false is scoped to the test's Git wrapper.

I ran the focused test file against an isolated copy of the PR head: 16 tests passed in 1.22 seconds. Hosted conventions, eligibility, intake and labels pass; the relinker CTest matrix passed on Ubuntu, macOS arm64, macOS x86_64 and Windows, and the ASan job passed. The full Linux/Windows product jobs were skipped by the workflow gate. The PR's reported Windows timing and process-count measurements are author-provided; I did not reproduce those benchmarks.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638166555 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10596#pullrequestreview-5638166555). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T12:02:00Z. **Review:** APPROVED --- Reviewed the exact head `dad627e00c6515f82a33971fe1dc59b21996ad09`. The split tests now run in-process with the fixture directory, stdout and stderr restored in `finally`; the one CLI split case remains a subprocess to cover command output. Commit creation remains only in the rebase/conflict cases that require a committed index, and `maintenance.auto=false` is scoped to the test's Git wrapper. I ran the focused test file against an isolated copy of the PR head: 16 tests passed in 1.22 seconds. Hosted conventions, eligibility, intake and labels pass; the relinker CTest matrix passed on Ubuntu, macOS arm64, macOS x86_64 and Windows, and the ASan job passed. The full Linux/Windows product jobs were skipped by the workflow gate. The PR's reported Windows timing and process-count measurements are author-provided; I did not reproduce those benchmarks.
MarcZX10 commented 2026-10-24 12:29:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T12:29:25Z.

Review: APPROVED


Reviewed head dad627e00c. The in-process split helper redirects and restores stdout/stderr and cwd in a finally block, while commit setup now remains only on the rebase/conflict paths that require committed history. The explicit CLI test still exercises the command-line path. Hosted eligibility, conventions, intake, labels, Linux/Windows/macOS relinker matrix, and relinker ASan all pass; product builds are skipped for this tools-only change. The detailed Linux and Windows unit/CTest timing and mutation results in the description are author-reported; I did not reproduce them locally.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638238576 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10596#pullrequestreview-5638238576). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T12:29:25Z. **Review:** APPROVED --- Reviewed head dad627e00c6515f82a33971fe1dc59b21996ad09. The in-process split helper redirects and restores stdout/stderr and cwd in a finally block, while commit setup now remains only on the rebase/conflict paths that require committed history. The explicit CLI test still exercises the command-line path. Hosted eligibility, conventions, intake, labels, Linux/Windows/macOS relinker matrix, and relinker ASan all pass; product builds are skipped for this tools-only change. The detailed Linux and Windows unit/CTest timing and mutation results in the description are author-reported; I did not reproduce them locally.
THEMANnt commented 2026-10-24 14:04:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-24T14:04:47Z.

Review: APPROVED


Reviewed head dad627e00c6515f82a33971fe1dc59b21996ad09 against pinned comparison base a5f13b3fd402749ee3ae57a925c6e1c543977ca9. The verified author scope changes only tools/tests/test_debt_split.py.

The split() helper now executes debt_split.main(["split"]) in process. Its temporary sink absorbs output and stream reconfiguration, while finally restores the working directory and original streams. Split failures still reach unittest as errors. Each test retains a separate temporary repository, and explicit commits preserve the history required by rebase and clean-checkout cases. Content, link, BOM, line-ending, ordering, and conflict assertions remain. One split still checks CLI output, and every resolve invocation remains a subprocess.

The controller-recorded local execution of tools/tests/test_debt_split.py passed 16 tests in each baseline, pristine-author, and candidate run on Windows with Python 3.11.9. Candidate tests also passed against pinned baseline production code, satisfying the tests-only compatibility control; this establishes compatibility, without establishing regression or mutation sensitivity. The recorded whitespace and repository-conventions checks passed.

GitHub-reported effective checks succeeded for relinker (windows-latest, g++), relinker (ubuntu-latest, g++), both listed macOS relinker jobs, relinker-asan, eligibility, intake, labels, and conventions. linux, windows, register-context, and write-watch were skipped. The author's broader benchmarks, traces, mutation experiments, and build results remain author-reported; local verification covered the selected Python suite. No actionable findings in this focused review.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638524783 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10596#pullrequestreview-5638524783). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-24T14:04:47Z. **Review:** APPROVED --- Reviewed head `dad627e00c6515f82a33971fe1dc59b21996ad09` against pinned comparison base `a5f13b3fd402749ee3ae57a925c6e1c543977ca9`. The verified author scope changes only `tools/tests/test_debt_split.py`. The `split()` helper now executes `debt_split.main(["split"])` in process. Its temporary sink absorbs output and stream reconfiguration, while `finally` restores the working directory and original streams. Split failures still reach unittest as errors. Each test retains a separate temporary repository, and explicit commits preserve the history required by rebase and clean-checkout cases. Content, link, BOM, line-ending, ordering, and conflict assertions remain. One split still checks CLI output, and every resolve invocation remains a subprocess. The controller-recorded local execution of `tools/tests/test_debt_split.py` passed 16 tests in each baseline, pristine-author, and candidate run on Windows with Python 3.11.9. Candidate tests also passed against pinned baseline production code, satisfying the tests-only compatibility control; this establishes compatibility, without establishing regression or mutation sensitivity. The recorded whitespace and repository-conventions checks passed. GitHub-reported effective checks succeeded for `relinker (windows-latest, g++)`, `relinker (ubuntu-latest, g++)`, both listed macOS relinker jobs, `relinker-asan`, `eligibility`, `intake`, `labels`, and `conventions`. `linux`, `windows`, `register-context`, and `write-watch` were skipped. The author's broader benchmarks, traces, mutation experiments, and build results remain author-reported; local verification covered the selected Python suite. No actionable findings in this focused review. <!-- qwen-review-desk:31878441dfafbe4e15e72b42e22ef7b746480333b60a5e24e335cc9fe015f09d -->
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!10596
No description provided.