tooling: canonicalize script paths when checking duplicates #3002
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3002
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3002"
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?
@ashishdhillon on GitHub · 2026-11-27 04:00 UTC · original
ashishdhillon:tooling/normalize-duplicate-check-paths→main· +29 −6 · 3 files · 1 commits · merged 2026-11-27 04:19 UTCChange
Follow-up to #2805:
tools/run_checks_parallel.pypreviously compared script paths using exact raw strings inmain(),read_check_files(), andmerge_checks(), so spelling variants of the same file (such astests/a_check.pyvs./tests/a_check.py) were not recognized as duplicates and ran twice._command_key(command)using(str(Path(command[0]).resolve()), *command[1:])to collapse path spelling variants while keeping each command's original display path intact for::group::output and error messages, and preserving distinct commands with different arguments.main(), file-list duplicate detection inread_check_files(), and inline/fragment deduplication inmerge_checks()to key on_command_key.tests/run_checks_parallel_check.py), across--from-dirfiles (tests/run_checks_fragments_check.py), and between inline and--from-dircommands.Verification
python3 -B tools/run_checks_parallel.py tests/run_checks_parallel_check.py tests/run_checks_fragments_check.py tests/run_checks_parallel_cli_check.py tests/startup_tools_lint_check.py->all 4 checks passed(run_checks_parallel_cli_check ran 7 tests, OK)python3 -B tests/bidi_controls_check.py --self-test->Self-test passed.git diff --check-> cleanEvidence and follow-up
All assertions ran locally on macOS (pure-Python tooling tests; Windows GPU suite not run locally as no source build or Windows GPU host is present).
Checklist
AI-assisted.
@KelboLive on GitHub · 2026-11-27 04:13 UTC · original · reviewed
Nice fix —
Path.resolve()elegantly collapses spelling variants and the regression tests are tight.Findings
✅ What works well
_command_keyadds minimal cognitive load: one pure helper, three call-site updates, all same pattern.scriptstring in the error message (duplicate command-line script: {script}), which is user-friendly — it shows exactly what the user typed.--from-dirfragment dedup (merge_checks) now correctly matches paths saved in different spellings.case_dot_twocatches the./scripts/x_check.pyvsscripts/x_check.pycase, andspelled_twicevalidates that display output (::group::,ran) stays single.⚠️ Minor observations
Symlinks / junctions on Windows —
Path.resolve()follows symlinks (since Python 3.6). Iftests/itself is a symlinked directory, both spellings resolve to the same real path anyway, so dedup still works. The only edge case would be two distinct filesystem paths resolving to the same inode — extremely rare in this project. No action needed, just noting the behavior.seen_scriptsset inmain()— stores tuples of(resolved_path, *rest). Sincerestis always empty for CLI scripts, this is effectivelyset[str]. Consider adding a one-liner comment:# CLI commands have no arguments after the script path, so the key is just the resolved path.— purely for future maintainers.merge_checksdedup display — when a--from-dirfile is skipped as a duplicate of an inline script (or vice versa), the error referencesseen[key]which stores the firstwherevalue. This is correct and user-actionable.Recommendation
Looks good as-is. A trivial comment on the
main()loop would make it slightly easier to read, but it's not blocking.🏷 One thought for future: if
run_checks_parallel.pyever supports arguments after the script path (like--env KEY=VAL),_command_keyalready handles that via*command[1:]— clean design.@R0Y00 on GitHub · 2026-11-27 04:19 UTC · original · approved these changes
Reviewed
92f31268756b076237fb0f4f6bfdc606cd4f5343. The resolved path affects duplicate comparison only. Execution still receives the original path and the complete argument tail remains in the comparison key. On Windows I ranpython -B tests/run_checks_parallel_check.pyandpython -B tests/run_checks_fragments_check.pyon this head; both passed. Required Windows CI passed.@thepatrickworld on GitHub · 2026-11-27 04:27 UTC · original
Post-merge Python-only audit of
92f31268(=main): the change is correct, three of its four_command_keysites are pinned by the tests, themerge_checksfilter is notNot a code change; measurements only. No GPU, no C++ and no Windows is involved —
tools/run_checks_parallel.pyis plain Python, so the whole change can be exercised without the hardware this repository usually needs.Environment and tree
python3 -B tests/<fixture>.pyfrom the repository root, the way thepython-linuxjob invokes them).git rev-parse HEAD=92f31268;git status --porcelain --untracked-files=noempty.2026-11-27T04:19:46Z. The three files below are byte-identical between92f31268andmain(comparison of each blob at both refs, not a line number):Baseline
Mutation matrix
One site reverted at a time,
git checkout -- tools/run_checks_parallel.pybetween two mutants, the file sha256 checked before and after the whole matrix (identical,6b58a1dd…) andgit status --porcelain --untracked-files=noempty at the end.:117key = _command_key(command)→key = tuple(command)— killed byrun_checks_fragments_check.py:87(case_dot_two).:132known = {_command_key(command) …}→{tuple(command) …}— killed bytests/run_checks_fragments_check.py:89(dedup;all 4 checks passed).:134if _command_key(command) not in known]→if tuple(command) not in known]— survives all three fixtures, rc=0.:194key = _command_key([script])→key = tuple([script])— killed byrun_checks_parallel_check.py:79.return (str(Path(command[0]).resolve()), *command[1:])→return (command[0], *command[1:])— killed byrun_checks_parallel_check.py:79andrun_checks_fragments_check.py:87.So the merged code pins three of the four call sites.
tests/run_checks_parallel_cli_check.pykills none of the five mutants — not a defect, just worth knowing before it is cited as coverage.The site nothing pins
M2b is a half-applied version of this exact patch — updating
knownand leaving the comprehension alone — and it is not equivalent.knownholdsstr(Path(…).resolve()), i.e. absolute paths, while the comprehension compares the raw text of the listing line, which is relative in this repository (tests/…). Under M2b the two never match, so a command that is both listed and inline runs twice, with one identical spelling and no./anywhere. Two lines reproduce it from the repository root on both trees:Observed, same relative spelling on both sides:
Same result with the repository's own path instead of a probe file: listing
tests/mesh_bitcmp_check.pyand passingtests/mesh_bitcmp_check.pyinline prints one::group::onmainand two under M2b.That breaks the rule in
tests/checks/README.md:17("A command that is also in the inline list runs once") and the docstring ofmerge_checks("an entry can move from the inline list to a file without running twice"). The existingdedupcase does not see it: it puts the non-canonical spelling inline (dot_echo) and the canonical one in the listing, so it only drives_command_keywhen buildingknown—case_dot_twolikewise drivesread_check_files, not the filter.Scope
tests/checks/use only thetests/…spelling (grep -v -E '^#|^$|^tests/' tests/checks/*/*.txt→ no match) and none of the six listed scripts appears in the inline lists of.github/workflows/windows.yml(grep tests/<script>.py→ 0 for each), so no pair differs today.tests/checks/README.mdencourages.merge_checksis on the CI path atwindows.yml:178and--from-dirat:199, so the code runs at every push; only the differing pair is missing.Two-line follow-up, if you want the site pinned
Add one mirror case next to the existing
dedup— add, do not replace (replacing lets M2a survive; measured):Measured on top of the head: green on
92f31268, and red under M2b (all 2 checks passed) while M1, M2a and M4 stay red too. A single relative pair on both sides separates M2a and M2b at once, but needs a working directory passed to the fixture's subprocess.Limits
Path.resolve()goes through the OS on Windows (case, short names); nothing above depends on that, but it was not exercised. This is not a second Windows run — the approval above already has one.grep -rl 'run_checks_parallel\|merge_checks\|read_check_files' tests/); the wider Python suite was not re-run.AI-assisted.