pe: add main(argv) and JSON/schema/IO error guards in dependency_paths with CLI suite #2428
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2436"
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 R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-25T16:41:32Z.
Change
Add a testable
main(argv=None) -> intentrypoint, upfront directory and JSON schema validation, and structured error handling totools/dependency_paths.py, together with a standalone pure-Python CLI test suite registered inCMakeLists.txt(pe_dependency_paths_cli_check).tools/dependency_paths.py:argv: list[str] | None = Noneinmain, forwardargvtoparser.parse_args(argv), return0on success, and invokeraise SystemExit(main())under__main__.args.inventory.is_dir()), validate that the inventory JSON root is an object with a mappingimagesand listimports, and checkargs.entry is not None and args.entry not in imagesviaparser.error(...)(handling empty-string""entry cleanly).(OSError, UnicodeDecodeError, ValueError, KeyError, TypeError)viaparser.exit(1, f"{args.inventory}: {exc}\n")with zero raw tracebacks while preserving exact JSON stdout (including narrowcp1252stdout encoding).tests/dependency_paths_cli_check.py: standalone unittest suite using synthetic inventory JSON covering single-entry and all-entry JSON schema (inventory_sha256+entries), non-ASCII survival oncp1252stdout,main(None)/__main__forwarding, and negative/mutation controls (missing/directory inventory, invalid UTF-8, invalid JSON, non-object root, missing/invalidimagesorimports,KeyError/TypeErrorduringtrace, and missing/emptyentryexit 2).CMakeLists.txt: registerpe_dependency_paths_cli_checkimmediately afterdependency_paths_controls(tests/dependency_paths_check.pyleft untouched).Verification
Verified on commit
38990c71(based onupstream/mainb442b57f) usingout/pe-env/Scripts/python.exe -B:out/pe-env/Scripts/python.exe -B tests/dependency_paths_cli_check.py -v->Ran 6 tests in 1.789s,OK(exit 0).out/pe-env/Scripts/python.exe -B tests/dependency_paths_check.py->dependency_paths: the pinned hash reaches the conditional target; a different hash reports unverified_loader_hash and no conditional edge(exit 0).out/pe-env/Scripts/python.exe -B tests/intake/paths_check.py-> exit 0.out/pe-env/Scripts/python.exe -B tests/form_coverage_check.py->form coverage checks passed(exit 0).out/pe-env/Scripts/python.exe -B tests/docs_links_check.py->Self-test passed. Checked 19 Markdown files and 465 links.(exit 0).out/pe-env/Scripts/python.exe -B tests/bidi_controls_check.py->Self-test passed. Checked 1726 tracked source, script and build/CI files: no bidirectional controls.(exit 0).tools/dependency_paths.py: 8/8 mutations killed (argvforwarding,is_dir(), rootdictcheck,imagesdictcheck,importslistcheck,args.entry is not None,KeyError/TypeErrorguard, integer0return).Evidence and follow-up
All fixtures in
tests/dependency_paths_cli_check.pyare synthetic minimal inventory dictionaries generated in-memory under the repository MIT license; no external binaries or game files are used. Contributors can run the suite directly viaout/pe-env/Scripts/python.exe -B tests/dependency_paths_cli_check.pyor through CTest (pe_dependency_paths_cli_check).Checklist
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T18:24:27Z.
Review: COMMENTED
Review of head
38990c71(diff against origin/main, 3 files).What I checked
main(argv=None) -> intwithraise SystemExit(main()), input checks, and one new CTest entry next todependency_paths_controls. The existingtests/dependency_paths_check.pyis untouched.parser.errorraises SystemExit, so the newexcepttuple does not swallow the usage error (exit 2). I/O, JSON and schema problems exit 1 with one line and no traceback. Theentry is not Nonecheck makes an empty-string entry a usage error instead of "all entries".38990c71. I did not run them.Commands run locally (worktree at the PR head)
python3 -B tests/dependency_paths_cli_check.py: 6 tests, OKpython3 -B tests/dependency_paths_check.py: passpython3 tests/docs_links_check.py: passpython3 tests/bidi_controls_check.py: passgit diff --check origin/main...HEAD: cleanparser.exit(1, ...)changed toparser.exit(0, ...): the suite fails (9 failures).args.entry is not Nonechanged to a truthiness test: the suite fails (1 failure).Non-blocking note: the
excepttuple includesKeyErrorandTypeError. A real bug insidetracewould be reported as an inventory error with exit 1, not a traceback. The suite pins this on purpose, so I am only flagging it.No blocking findings. No Windows run on my side. This comment is not an approval.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T20:02:26Z.
Review: COMMENTED
Review of head
30d83e29(tooling only:tools/dependency_paths.py, new CLI suite, CTest registration). No blocking findings.What I checked:
main(argv)returns an int and the script exits throughSystemExit(main()).parser.errorfor an unknown entry still exits 2, and I/O, decode, JSON and schema failures exit 1 with a one-line message.pe_dependency_paths_cli_checkis registered next to its siblings inCMakeLists.txt.imagesobject check withif False:makes 2 of 6 tests fail. Mutation 2: changing the error exit code from 1 to 0 makes the suite fail (9 failures).dependency_paths; #635 and #212 touched other behavior).Commands run locally on the exact head:
python3 tests/dependency_paths_cli_check.py-> 6 tests OKpython3 tests/docs_links_check.py-> OKpython3 tests/bidi_controls_check.py-> OKgit diff --check origin/main...HEAD-> cleangit checkout -- .AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T20:06:08Z.
Win2025 WARP receipt for head
30d83e29after updating with main.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
30d83e29a55624ac19f834be4355910b89e96e55:--preset dev):cmake --build --preset dev -- -j 2):2.96s(configure2.58s)ctest --preset dev -R 'dependency_paths' --parallel 4 --no-tests=error --output-on-failure): 2/2 passed (2.61s:dependency_paths_controls0.23s,pe_dependency_paths_cli_check2.46s)/O2(--preset release):cmake --build --preset release -- -j 2):3.51s(configure2.55s)ctest --preset release -R 'dependency_paths' --parallel 4 --no-tests=error --output-on-failure): 2/2 passed (2.31s:dependency_paths_controls0.23s,pe_dependency_paths_cli_check2.16s)tests/dependency_paths_check.pyok (0.2s),tests/intake/paths_check.pyok (0.2s)sccache: 25/40 hits; wall22.3sAI-assisted; commands listed were executed locally.