fix(tools): check environment references from a subdirectory #9660
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9660"
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 jotitadev on 2026-10-22T07:04:45Z.
What
tools/check_conventions.pyskips theenv-referencerule when it runs from a subdirectory, for examplecd tools && python3 check_conventions.pyorpython3 ../tools/check_conventions.pyfrom a build folder. It prints "All conventions checks passed." and gives no warning.#4368 fixed this for the rest of the checker (
ls-tree --full-tree,git grep --full-name … :(top)core/libs/prx).env_reference()came later with #6078, and three of its git calls still take their paths from the current directory:git diff -U0 <base> <head> -- core docs/dev/ENVIRONMENT.md: fromtools/the pathspecs meantools/coreandtools/docs/dev/ENVIRONMENT.md, so the diff is empty. No added read, removed read or removed row is seen.git grep … <head> -- core: same pathspec problem, so the set of names the code still reads is empty.git ls-tree --name-only <base> -- docs/dev/ENVIRONMENT.md: from a subdirectory it does not list the base branch's document, so rows that only the base branch has are not counted as documented.The pathspecs now use
:(top)(the grep also gets--full-name, as inunknown_nids()), andls-treegets--full-tree. CI runs from the repository root, where the output does not change.Tested
macOS 27.2 arm64 (M2 Max), git 2.55,
/usr/bin/python33.9.6 and Python 3.14.7, main6ef5a1c4c, then rebased ontod6eafa54dwith the new tests andcheck_conventions.pyrun again:test_a_check_from_a_subdirectory_reports_the_same_findingsintest_check_conventions_env_reference.py. One branch adds an undocumented read, adds a read whose row only the base branch has, drops one of two reads of a documented name, and removes the row of a name nothing reads. It expects the same single finding from the root,core,core/libs/prx/libSceExampleanddocs/dev. With main's checker the three subdirectory runs report nothing. Putting back any one of the three old git calls fails the test again. The whole file passes on 3.9 and 3.14 (13 tests).std::getenv("ANYPS5_TOOLS_PROBE")to a library gets oneenv-referenceerror from the root. Fromtools/, main's checker passes it. With this change it reports the same error from the root,tools/,core/anddocs/.--base <c>^1 --head <c>: the last 25 that add agetenv("A…read undercore/and the last 15 that touchdocs/dev/ENVIRONMENT.md):tools/, this change matches the root for all 40.tools/, main's checker misses the root'senv-referenceerror on 3 of them:a07ad3057(APS5_NO_HW_F32_PRESERVE),a55dc4c53(APS5_NO_WGI) andb8607f4ce(APS5_VIDEOOUT_TELEMETRY_DIR).test_check_conventions_*.pyfiles andtest_env_reference.pypass on 3.9.check_conventions.pyandenv_reference.py. With both merged on top,test_check_conventions_env_reference.py,test_check_conventions_comments.pyandtest_env_reference.pypass on 3.9.python3 tools/check_conventions.py --base origin/mainpasses.python3 tools/pr_overlap.py --branch fix/conventions-env-reference-from-subdirectory: no overlap.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 fogydes on 2026-10-22T08:43:30Z.
Reviewed; verified the diff and (via the tool's own test suite) both the fix and its failure mode. The three switched calls are exactly the ones
env_reference()makes that were cwd-dependent: the diff pathspec now pinned with:(top)core/:(top)docs/..., thegit grepwith--full-name+:(top)core, and thels-treewith--full-tree. The othergit diffcalls in the checker (--name-statusetc.) print root-relative paths regardless of cwd, so no other rule needed the same treatment — I checked for that rather than assuming. The new test reports sibling results identical from root,core,core/libs/prx/libSceExampleanddocs/dev, and the same test run against main's checker fails with empty subdirectory findings, reproducing the claim. Deterministic output preserved; the pre-existing (unused)base/headparams onfindings_ofremain untouched, correctly outside topic scope.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T09:10:47Z.
Review: CHANGES_REQUESTED
The root-relative path fixes are targeted and preserve root-run behavior. I ran the exact-head checker suites locally: all
test_check_conventions_*.pytests pass (146/146), andtest_env_reference.pypasses (8/8). Exact-head diff-check and conventions pass; hosted conventions, eligibility, intake, labels and relinker Linux/Windows/macOS + ASan jobs pass. The new test verifies identical findings from the root and three nested directories. The body identifies #8777 and #8995 as related open tool changes and reports a clean combined test run.I’ve noticed that holding this PR because of #5239 isn’t necessary. It’s fine for PRs to keep coming in; they’ll be handled in due course. Please disregard my earlier request to hold or defer it.
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T09:27:43Z.
Thanks for the review. Marked as draft to hold it under #5239 until the open queue is below 700 or a title needs it; I'll mark it ready then.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T14:31:03Z.
Review: APPROVED
Correction: my earlier changes-requested review was based only on a mistaken queue hold tied to #5239. My review found no code blocker; PRs may continue to be submitted and will be handled in due course.