pe: extract main(argv) and add path/struct.error guards in pe_run_package with CLI suite #2579
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2587"
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-25T22:05:47Z.
Summary
Extracts a testable
main(argv=None) -> intentrypoint intools/pe_run_package.py, adds upfront directory/regular-file path validation forpackage,mapper, and--shimarguments, and guardsstruct.erroralongside(ValueError, OSError, pefile.PEFormatError)with zero raw tracebacks, backed by a standalone pure-Python CLI test suite registered in CTest.Changes
tools/pe_run_package.py:main(argv=None) -> intforwardingargvtoparser.parse_args(argv)and returning0, invokingraise SystemExit(main())under__main__.options.packageis an existing directory,options.mapperis not an existing directory (preserving non-existent mapper placeholders in--preflight-only), and every--shimpath resolves to an existing regular file.main()exception handling to(ValueError, OSError, pefile.PEFormatError, struct.error)viaparser.exit(1, f"{exc}\n")with zero raw tracebacks, preserving exact JSON stdout and refusal exits tested bytests/pe_run_package_invalid_check.py,tests/pe_run_package_plan_check.py, andtests/host_commit_check.py.tests/pe_run_package_cli_check.py:CMakeLists.txt:pe_run_package_cli_checkin CTest right afterpe_run_package_plan_check.Verification
All commands executed after rebasing onto
upstream/main(fb2f86ac):out/pe-env/Scripts/python.exe -B tests/pe_run_package_cli_check.py -vRan 3 tests in 0.351s/OK(exit 0)out/pe-env/Scripts/python.exe -B tests/pe_run_package_invalid_check.pyRan 3 tests in 0.520s/OK(exit 0)out/pe-env/Scripts/python.exe -B tests/pe_run_package_plan_check.pyRan 11 tests in 1.219s/OK(exit 0)out/pe-env/Scripts/python.exe -B tests/host_commit_check.pyRan 7 tests in 0.008s/OK(exit 0)out/pe-env/Scripts/python.exe -B tests/form_coverage_check.pyform coverage checks passed(exit 0)out/pe-env/Scripts/python.exe -B tests/docs_links_check.pySelf-test passed. Checked 19 Markdown files and 495 links.(exit 0)out/pe-env/Scripts/python.exe -B tests/bidi_controls_check.pySelf-test passed. Checked 1816 tracked source, script and build/CI files: no bidirectional controls.(exit 0)argvforwarding,root.is_dir(),mapper.is_dir(),--shimdir/file checks,struct.error/PEFormatError/OSErrorcatches, andmain()return code): 8/8 killed.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T22:12:16Z.
Review: COMMENTED
Review of head
91d64011(3 commits behind main, mergeable, CI green).Scope: Python-only (tools/pe_run_package.py, new tests/pe_run_package_cli_check.py, CTest registration). It does not claim to advance game startup, so no game verification is needed.
Code:
main(argv=None) -> int, upfront package/mapper/--shim path checks andstruct.errorin the handled exceptions all look correct. The non-existent mapper placeholder for--preflight-onlyis preserved. Sibling suites (pe_run_package_invalid_check,host_commit_check) still pass.Mutations (each makes the new tests fail, restored afterwards):
struct.errorfrom the except tuple: errorif not root.is_dir()->if False: 1 failureif mapper.is_dir()->if False: 2 failuresLinux commands run (pefile in a throwaway venv):
pe_run_package_cli_check.pyguard tests: OK; the positive preflight test errors only onctypes.WINFUNCTYPE(Windows-only).pe_run_package_plan_check.pyfails the same way on origin/main, so it is not caused by this PR.pe_run_package_invalid_check.py: OK.host_commit_check.py: OK (1 skipped).tests/docs_links_check.py,tests/bidi_controls_check.py,git diff --check origin/main...HEAD: clean.Note: the positive test has no platform skip, like its sibling
pe_run_package_plan_check. This is fine because CTest registers it only in the Windows intake block. The positive path needs a Windows run, which I am queuing next.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T22:19:53Z.
Win2025 WARP receipt for head
d2d75268after updating with main.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
d2d752688507eb5fc8299946d976405eee6f59d2:--preset dev):cmake --build --preset dev --target trap_missing_data_exe trap_missing_exe -- -j 2):0.19s(configure0.00s)ctest --preset dev -R 'pe_run_package' --parallel 2 --no-tests=error --output-on-failure): 4/4 passed (7.96s:pe_run_package_invalid_pe1.43s,pe_run_package_plan_check3.02s,pe_run_package_cli_check1.78s,pe_run_package_trap_missing4.71s)/O2(--preset release):cmake --build --preset release --target trap_missing_data_exe trap_missing_exe -- -j 2):7.98s(configure0.00s)ctest --preset release -R 'pe_run_package' --parallel 2 --no-tests=error --output-on-failure): 4/4 passed (8.50s:pe_run_package_invalid_pe1.40s,pe_run_package_cli_check1.59s,pe_run_package_plan_check3.00s,pe_run_package_trap_missing5.30s)tests/host_commit_check.pyok (0.8s),tests/intake/import_forms_check.pyok (0.4s),tests/pe_package_ordinal_plan_check.pyok (0.6s),tests/pe_package_preflight_check.pyok (1.6s)sccache: 0/3 hits; wall32.3sAI-assisted; commands listed were executed locally.