script: extract testable main(argv) in script_path_replay and expand unit and CLI coverage #2073
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2080"
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-25T00:03:58Z.
Change
Extract a testable
main(argv=None) -> intentry point intools/script_path_replay.pyand expand positive and negative unit and CLI coverage intests/script_state_check.py:tools/script_path_replay.py: extractmain(argv=None) -> int, preservingparser.exit(1, ...)error handling on(OSError, ValueError)(zero uncaught Python tracebacks) and preservingselect_tree(),state_index(),replay(), and JSON stdout output.tests/script_state_check.py: preserve all existing literal probe tests and add a synthetic RPF9 (9FPR) linked-sibling state hierarchy fixture + mockedctypes.CDLLresolve_script_pathoracle covering:select_tree(),state_index(),replay()across absolute and relative paths (.,.., nested, missing, ambiguous, verified camera parameters), andmain(argv)JSON stdout validation.9FPRmagic, missing/duplicate anchor, invalid parent index (i == 0withparent != 65535,parent >= i), out-of-bounds attribute slices, duplicate state ID attribute, missing/multiple rootstatescontainers, non-root node 0, malformed paths ("","./","a//b","a/.","a/..",".",".."), native-vs-parent-index mismatch (actual != expectedand unchangedactive), andmain(argv)missing/invalid archive or missing/failing--hostDLL pinningSystemExit(1)with zero tracebacks.Verification
Tested on commit
f7aa7790(rebased ontoupstream/main6218beb2, Windows x64, Python viaout/pe-env):.\out\pe-env\Scripts\python.exe -B tests/script_state_check.pyRan 22 tests in 0.872s—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 18 Markdown files and 393 links.(exit 0)..\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.pySelf-test passed. Checked 1413 tracked source, script and build/CI files: no bidirectional controls.(exit 0).Note:
tests/script_state_check.pyis already registered in CTest (CMakeLists.txtuntouched) and no C++ targets were modified.Evidence and follow-up
9FPR) fixture and mockedresolve_script_pathoracle; no external binaries or game files are used.ValueErrormessages andSystemExit(1)exit codes with zero raw tracebacks acrossselect_tree(),state_index(),replay(), andmain(argv).Checklist
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:25:00Z.
Review: COMMENTED
Review of head
f7aa7790c8c2538d83d95832da761d35571ef199(comment only, no approval).Scope:
tools/script_path_replay.py(+9/-4) extractsmain(argv=None) -> int;tests/script_state_check.py(+391) adds a synthetic RPF9 fixture, a Python stand-in for the nativeresolve_script_path, and positive and negative tests. Title is neutral, no clean-room concerns seen. CI: Linux checks, Windows build/test and fixtures pass. Mergeable.Commands executed locally (worktree at the head SHA):
python3 tests/script_state_check.py->Ran 22 tests ... OKpython3 tests/docs_links_check.py->Checked 18 Markdown files and 393 links.python3 tests/bidi_controls_check.py->no bidirectional controlsgit diff --check origin/main...HEAD-> cleanMutations of the changed logic (each reverted with
git checkout -- .):mainreturns 2 instead of 0 -> killed (1 failure).parser.exit(1, ...)error path -> killed (5 failures, 7 errors).replay:expected = -2 if matches else -1changed toexpected = -1(ambiguity reported as missing) -> killed (1 error).replay:expected = -1 if up > len(active_keys) else containers[0]changed toexpected = containers[0]-> survived (22 OK).Findings
tests/script_state_check.py(_mock_cdll_factory, about lines 330-400): the "native" side is a Python re-implementation of the resolver, and the Python reference inreplay()is a second implementation of the same rules. The tests therefore check two Python copies agree. They do not exercise the real host DLL, so a drift in the native resolver is not caught on Linux. Please say in the docstring that this is a model of the native contract, and keep a Windows test that runsreplay()against the real host build...than the current depth (for example a first path..plus a label, or../../xafter a depth-1 match) and expectsmissingwithactiveunchanged. Please add one such case inScriptPathReplayNegativeTests.The
main()extraction is behavior-preserving (same parser, same exit paths, JSON on stdout,SystemExit(main())).AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-25T06:34:49Z.
Review: APPROVED
Verified head
f7aa7790on Windows x64 (Python 3.12).python -B tests/script_state_check.py-> passed (Ran 22 tests in 0.762s,OK)Verdict: Approved at
f7aa7790.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T11:36:04Z.
Review: COMMENTED
Re-review of head
05503a043623a52d4471b0f0c4858b792e39077c(comment only, no approval). Previous review was onf7aa779.Delta since
f7aa779: onlytests/script_state_check.py(+14). A docstring on_mock_cdll_factory, and an over-up relative path case inScriptPathReplayNegativeTests(["../alpha", "alpha", "../../gamma"]expectsmissing, matched, missingwith before/after unchanged).Previous points
tools/script_path_host.cpp.tests/script_path_check.pyrunsreplay()against the real compiled host library, so the native side stays covered on Windows.expected = containers[0]intools/script_path_replay.py:81) and the suite now fails (FAILED (errors=1)). Reverted withgit checkout -- ..Commands executed locally (worktree at the head SHA):
python3 tests/script_state_check.py->Ran 22 tests ... OKpython3 tests/docs_links_check.py->Checked 18 Markdown files and 393 links.python3 tests/bidi_controls_check.py->no bidirectional controlsgit diff --check origin/main...HEAD-> cleanState: title neutral, no clean-room concerns, MERGEABLE. CI was still pending when I looked (Linux checks, Windows build/test, fixtures), so please wait for it to go green.
Findings: P1: none. P2: none. Nit: the over-up case sits inside an existing test body, so a failure there will not name the scenario. A short
subTestlabel would help. Optional.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-25T11:34:00Z.
Updated PR #2080 (commit
05503a04) to address the P2 findings:_mock_cdll_factory(tests/script_state_check.py) that it modelstools/script_path_host.cppfor platform-independent tests whiletests/script_path_check.pyexercisesreplay()against the real Windowsscript_path_hostDLL.["../alpha", "alpha", "../../gamma"]coverage inScriptPathReplayNegativeTests.test_replay_rejects_bad_containers_root_paths_and_native_mismatch(tests/script_state_check.py); verified mutatingexpected = -1 if up > len(active_keys) else containers[0]toexpected = containers[0]fails withValueError: Linked traversal returned -1, parent index returned 2 for ../alpha.tests/script_state_check.py(22 tests OK),tests/form_coverage_check.py,tests/docs_links_check.py(393 links), andtests/bidi_controls_check.py(1413 files).AI-assisted.