test(tools): compare quoted and resolved paths in the patch advisor test #10667

Merged
roboterspinne merged 1 commit from upstream-pr/10667 into main 2026-10-27 16:55:17 +00:00
roboterspinne commented 2026-10-24 16:09:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by roboterspinne on 2026-10-24T16:09:18Z.


What

patch_advisor_unit (tools/tests/test_suggest_patches.py, added by #8900) builds its fixture under tempfile.TemporaryDirectory() and compares the paths it built with what tools/suggest_patches.py prints and passes on. The tool does two things to those paths: it renders the conversion line through command_line (subprocess.list2cmdline on Windows, shlex.join elsewhere), which wraps a path containing a space in quotes, and it hands the relinker paths that went through Path.resolve() (args.relinker.resolve() and confined). test_uppercase_digest_and_conversion_options asserted the unquoted f"--sce-module-path {self.root}", and test_verified_match_requires_explicit_application and test_additional_executable_is_hashed_and_verified compare run.call_args with the unresolved fixture paths. Neither case shows up on GitHub's runners, so #8900 merged with the test green; on a Windows account whose name contains a space, the first test fails with a long TEMP (--sce-module-path "C:\Users\Vincent Prange neu\...\tmpXXXX") and the other two fail with the account's default 8.3 short name (C:\Users\VINCEN~1\..., which resolve() expands to the long name). A symlinked temporary directory fails the same way.

  • Fix. The fixture directory gets prefix="patch advisor-", so every host takes the quoting branch instead of only the hosts whose temporary path happens to contain a space, and self.root is resolved, as tools/tests/test_check_compile.py already does for its holder directory. The expected --sce-module-path text comes from the tool's own command_line, so the assertion follows the platform rule the tool applies. The tool is unchanged: the quoted line is what a user pastes into a shell, and the resolved paths are what the relinker gets.
  • Other assertions. --patches, --module-dir Media/Modules and --executable picker/picker.bin stay as they are: neither list2cmdline nor shlex.quote changes those values. The integration test core/relinker/relinker/tests/test_patch_advisor.py asserts no path from the advisor's output and is not touched.
  • Overlap. pr_overlap.py --branch test/patch-advisor-quoted-paths reports no shared lines with open pull requests.

Tested

Windows 11, Python 3.13.9 (Anaconda); no build, the test mocks subprocess.run. python tools/tests/test_suggest_patches.py on main (c9b75825f3) and on this branch, each with three temporary roots:

  • TEMP/TMP on a long path with a space (C:\Users\Vincent Prange neu\...): main fails test_uppercase_digest_and_conversion_options ('--sce-module-path C:\...\tmpXXXX' not found in ... --sce-module-path "C:\...\tmpXXXX"); this branch passes all 24 tests.
  • TEMP/TMP on the account's default 8.3 short name (C:\Users\VINCEN~1\...): main fails test_verified_match_requires_explicit_application and test_additional_executable_is_hashed_and_verified (Lists differ: ['C:\Users\Vincent Prange neu\...'] != ['C:\Users\VINCEN~1\...']); this branch passes all 24 tests.
  • TEMP/TMP on a plain path without a space: main and this branch pass all 24 tests.
  • python tools/check_conventions.py --base upstream/main with this title and description passed.
  • Not run on Linux or macOS; the change is host-independent and the relinker-only job runs ctest on Ubuntu, Windows and macOS runners.

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:4996968879 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10667). Originally posted by [roboterspinne](https://github.com/roboterspinne) on 2026-10-24T16:09:18Z. --- ### What `patch_advisor_unit` (`tools/tests/test_suggest_patches.py`, added by #8900) builds its fixture under `tempfile.TemporaryDirectory()` and compares the paths it built with what `tools/suggest_patches.py` prints and passes on. The tool does two things to those paths: it renders the conversion line through `command_line` (`subprocess.list2cmdline` on Windows, `shlex.join` elsewhere), which wraps a path containing a space in quotes, and it hands the relinker paths that went through `Path.resolve()` (`args.relinker.resolve()` and `confined`). `test_uppercase_digest_and_conversion_options` asserted the unquoted `f"--sce-module-path {self.root}"`, and `test_verified_match_requires_explicit_application` and `test_additional_executable_is_hashed_and_verified` compare `run.call_args` with the unresolved fixture paths. Neither case shows up on GitHub's runners, so #8900 merged with the test green; on a Windows account whose name contains a space, the first test fails with a long `TEMP` (`--sce-module-path "C:\Users\Vincent Prange neu\...\tmpXXXX"`) and the other two fail with the account's default 8.3 short name (`C:\Users\VINCEN~1\...`, which `resolve()` expands to the long name). A symlinked temporary directory fails the same way. - **Fix.** The fixture directory gets `prefix="patch advisor-"`, so every host takes the quoting branch instead of only the hosts whose temporary path happens to contain a space, and `self.root` is resolved, as `tools/tests/test_check_compile.py` already does for its holder directory. The expected `--sce-module-path` text comes from the tool's own `command_line`, so the assertion follows the platform rule the tool applies. The tool is unchanged: the quoted line is what a user pastes into a shell, and the resolved paths are what the relinker gets. - **Other assertions.** `--patches`, `--module-dir Media/Modules` and `--executable picker/picker.bin` stay as they are: neither `list2cmdline` nor `shlex.quote` changes those values. The integration test `core/relinker/relinker/tests/test_patch_advisor.py` asserts no path from the advisor's output and is not touched. - **Overlap.** `pr_overlap.py --branch test/patch-advisor-quoted-paths` reports no shared lines with open pull requests. ### 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. --> Windows 11, Python 3.13.9 (Anaconda); no build, the test mocks `subprocess.run`. `python tools/tests/test_suggest_patches.py` on `main` (c9b75825f3) and on this branch, each with three temporary roots: - `TEMP`/`TMP` on a long path with a space (`C:\Users\Vincent Prange neu\...`): `main` fails `test_uppercase_digest_and_conversion_options` (`'--sce-module-path C:\...\tmpXXXX' not found in ... --sce-module-path "C:\...\tmpXXXX"`); this branch passes all 24 tests. - `TEMP`/`TMP` on the account's default 8.3 short name (`C:\Users\VINCEN~1\...`): `main` fails `test_verified_match_requires_explicit_application` and `test_additional_executable_is_hashed_and_verified` (`Lists differ: ['C:\Users\Vincent Prange neu\...'] != ['C:\Users\VINCEN~1\...']`); this branch passes all 24 tests. - `TEMP`/`TMP` on a plain path without a space: `main` and this branch pass all 24 tests. - `python tools/check_conventions.py --base upstream/main` with this title and description passed. - Not run on Linux or macOS; the change is host-independent and the relinker-only job runs `ctest` on Ubuntu, Windows and macOS runners. ### 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 16:14:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T16:14:03Z.

Review: COMMENTED


Reviewed exact head 76008e99b9bf02bcbcbec2ed0d3c5380204cde2b. The test now exercises a path with spaces on every platform, resolves the fixture path to match the tool, and derives the displayed --sce-module-path fragment with the same command_line helper. I ran python3 tools/tests/test_suggest_patches.py locally (24/24 passed), conventions and diff checks pass, and the current-main merge tree is clean. Hosted Ubuntu and ASan relinker checks pass; Windows and macOS relinker jobs are still running, and product jobs are skipped by policy. No blocking issue found in the diff; I’ll recheck the remaining hosted matrix before approval.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638914338 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10667#pullrequestreview-5638914338). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T16:14:03Z. **Review:** COMMENTED --- Reviewed exact head `76008e99b9bf02bcbcbec2ed0d3c5380204cde2b`. The test now exercises a path with spaces on every platform, resolves the fixture path to match the tool, and derives the displayed `--sce-module-path` fragment with the same `command_line` helper. I ran `python3 tools/tests/test_suggest_patches.py` locally (24/24 passed), conventions and diff checks pass, and the current-main merge tree is clean. Hosted Ubuntu and ASan relinker checks pass; Windows and macOS relinker jobs are still running, and product jobs are skipped by policy. No blocking issue found in the diff; I’ll recheck the remaining hosted matrix before approval.
MarcZX10 commented 2026-10-24 16:19:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T16:19:52Z.

Review: APPROVED


Reviewed exact head 76008e99b9. The test exercises a CLI path containing spaces while checking both the quoted argument and its resolved target. Local verification passed: python3 tools/tests/test_suggest_patches.py (24/24), python3 tools/check_conventions.py --base upstream/main, and git diff --check; the merge tree against current main is clean. Hosted eligibility, conventions, intake, labels, and all four relinker platform/sanitizer jobs passed. Product builds were skipped by repository policy.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638931640 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10667#pullrequestreview-5638931640). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T16:19:52Z. **Review:** APPROVED --- Reviewed exact head 76008e99b9bf02bcbcbec2ed0d3c5380204cde2b. The test exercises a CLI path containing spaces while checking both the quoted argument and its resolved target. Local verification passed: python3 tools/tests/test_suggest_patches.py (24/24), python3 tools/check_conventions.py --base upstream/main, and git diff --check; the merge tree against current main is clean. Hosted eligibility, conventions, intake, labels, and all four relinker platform/sanitizer jobs passed. Product builds were skipped by repository policy.
THEMANnt commented 2026-10-24 16:45:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-24T16:45:43Z.

Review: APPROVED


Reviewed 76008e99b9bf against pinned base dca72a82dadd. No actionable findings in this focused review.

Source review

The test fixture now always contains a space and resolves its root before constructing expected paths. This aligns subprocess expectations with the advisor's resolved paths while preserving separate temporary fixtures and cleanup. The conversion-output assertion uses the same platform formatter as production; the remaining option, argument, hash, rejection and exit-code assertions are preserved. Production code is unchanged, and there are no local reviewer amendments. This checks consistent option rendering, without independently proving the formatter's quoting correctness.

Validation

  • Controller-recorded Windows/Python 3.11.9 runs of tools/tests/test_suggest_patches.py: baseline, pristine PR and candidate each had 24 passed, 0 skipped; 24 total.
  • Candidate tests against pinned baseline production code also had 24 passed, 0 skipped; 24 total. This is a compatibility control for the tests-only change.
  • Recorded whitespace and repository conventions checks passed.
  • GitHub reports success for relinker-asan, the named Ubuntu/Windows g++ and both macOS clang++ relinker jobs, plus eligibility, intake, labels and conventions. windows, linux, register-context and write-watch were skipped; those are not passing product tests.

Scope

Local validation executes the Python advisor with the relinker subprocess mocked. POSIX and the author's Python 3.13.9/8.3-path scenarios were not independently reproduced; full application behavior was not tested.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5639014188 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10667#pullrequestreview-5639014188). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-24T16:45:43Z. **Review:** APPROVED --- Reviewed [76008e99b9bf](https://github.com/boykopovar/AnyPS5/commit/76008e99b9bf02bcbcbec2ed0d3c5380204cde2b) against pinned base [dca72a82dadd](https://github.com/boykopovar/AnyPS5/commit/dca72a82daddcf2f506b62905c4c45b21fe5de25). No actionable findings in this focused review. **Source review** The test fixture now always contains a space and resolves its root before constructing expected paths. This aligns subprocess expectations with the advisor's resolved paths while preserving separate temporary fixtures and cleanup. The conversion-output assertion uses the same platform formatter as production; the remaining option, argument, hash, rejection and exit-code assertions are preserved. Production code is unchanged, and there are no local reviewer amendments. This checks consistent option rendering, without independently proving the formatter's quoting correctness. **Validation** - Controller-recorded Windows/Python 3.11.9 runs of `tools/tests/test_suggest_patches.py`: baseline, pristine PR and candidate each had 24 passed, 0 skipped; 24 total. - Candidate tests against pinned baseline production code also had 24 passed, 0 skipped; 24 total. This is a compatibility control for the tests-only change. - Recorded whitespace and repository conventions checks passed. - GitHub reports success for `relinker-asan`, the named Ubuntu/Windows g++ and both macOS clang++ relinker jobs, plus `eligibility`, `intake`, `labels` and `conventions`. `windows`, `linux`, `register-context` and `write-watch` were skipped; those are not passing product tests. **Scope** Local validation executes the Python advisor with the relinker subprocess mocked. POSIX and the author's Python 3.13.9/8.3-path scenarios were not independently reproduced; full application behavior was not tested. <!-- qwen-review-desk:6f073b5205331278f798b158f7e578fc4e2a02bcacdbe0102df5fe7d78662acf -->
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!10667
No description provided.