script: report path replay failures without a traceback #1593

Merged
RenzoWit35 merged 1 commit from upstream-pr/1600 into main 2026-11-24 14:55:44 +00:00
RenzoWit35 commented 2026-11-24 14:45:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RenzoWit35 on 2026-11-24T14:45:45Z.


Change

In tools/script_path_replay.py only select_tree was inside the try that turns OSError and ValueError into <archive>: <message> with exit code 1. The replay(...) call was outside it, so its input errors ended in a raw traceback: ValueError("Expected one root states container"), the state-label errors, and the OSError (FileNotFoundError) from ctypes.CDLL for a missing --host library.

  • The replay(...) call is now wrapped in the same except (OSError, ValueError) handler and reports parser.exit(1, f"{args.archive}: {exc}\n"). The JSON is printed only after replay succeeds, so stdout stays empty on failure.
  • I kept the existing <archive>: prefix for the missing-host case too. The message from the loader names the missing module itself (Could not find module '<host path>' ...), so the cause stays clear. replay() is not restructured.

Verification

Environment: Windows 11, Python 3.14.5, origin/main at a3ac47a9. Pure Python, nothing built.

Before (origin/main): python -B tools/script_path_replay.py replay.bin --host nohost.dll --record-with synthetic_orbit a//b, where replay.bin is fixture(priorities=(9, 8)) from tests/script_state_check.py: exit 1, stdout empty, stderr ends with a full traceback and ValueError: Expected one root states container. Calling replay() directly on the fixture of tests/script_path_check.py with a nonexistent host path raised FileNotFoundError: Could not find module '...nohost.dll' (or one of its dependencies)....

After (same command): exit 1, stdout empty, stderr is one line: <dir>\replay.bin: Expected one root states container.

New test test_replay_failure_is_reported_without_a_traceback in CommandLineTests (tests/script_state_check.py) runs that command through run_tool and asserts exit code 1, the archive name and Expected one root states container in stderr, no Traceback, and empty stdout.

  • out/pe-env/Scripts/python.exe -B tests/script_state_check.py: Ran 16 tests ... OK.
  • out/pe-env/Scripts/python.exe -B tests/bidi_controls_check.py: Self-test passed. and no bidirectional controls in 1233 files.
  • Negative control: with only tools/script_path_replay.py restored to origin/main, the same command gives FAILED (failures=1): AssertionError: 'replay.bin' not found in 'Traceback (most recent call last): ... ValueError: Expected one root states container'. With the fix restored it passes.

Rebased onto origin/main at a3ac47a9 before opening this pull request and re-run there: tests/script_state_check.py ran 16 tests, OK; tests/docs_links_check.py passed (16 Markdown files, 347 links); tests/bidi_controls_check.py passed (1259 files, no bidirectional controls); with tools/script_path_replay.py restored to origin/main the new test fails.

Not run: the missing-host (OSError) path is not covered by a test. Reaching ctypes.CDLL needs an archive with a root states container, and the fixture builder in tests/script_state_check.py cannot produce one; the fixture in tests/script_path_check.py returns an in-memory tree, not an archive. I only observed that path by calling replay() directly, before the change. tests/script_path_check.py was not run: it takes the built host DLL as an argument (tools/script_path_host.cpp), and no build was done. The test is already registered in AGENTS.md, the workflow and CMake.

Evidence and follow-up

Checked again after the rebase: no open upstream PR touches tools/script_path_replay.py, tests/script_state_check.py or tests/script_path_check.py. No issue is linked.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6584424798 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1600). Originally posted by [RenzoWit35](https://github.com/RenzoWit35) on 2026-11-24T14:45:45Z. --- ## Change In `tools/script_path_replay.py` only `select_tree` was inside the `try` that turns `OSError` and `ValueError` into `<archive>: <message>` with exit code 1. The `replay(...)` call was outside it, so its input errors ended in a raw traceback: `ValueError("Expected one root states container")`, the state-label errors, and the `OSError` (FileNotFoundError) from `ctypes.CDLL` for a missing `--host` library. - The `replay(...)` call is now wrapped in the same `except (OSError, ValueError)` handler and reports `parser.exit(1, f"{args.archive}: {exc}\n")`. The JSON is printed only after `replay` succeeds, so stdout stays empty on failure. - I kept the existing `<archive>:` prefix for the missing-host case too. The message from the loader names the missing module itself (`Could not find module '<host path>' ...`), so the cause stays clear. `replay()` is not restructured. ## Verification Environment: Windows 11, Python 3.14.5, `origin/main` at a3ac47a9. Pure Python, nothing built. Before (`origin/main`): `python -B tools/script_path_replay.py replay.bin --host nohost.dll --record-with synthetic_orbit a//b`, where `replay.bin` is `fixture(priorities=(9, 8))` from `tests/script_state_check.py`: exit 1, stdout empty, stderr ends with a full traceback and `ValueError: Expected one root states container`. Calling `replay()` directly on the fixture of `tests/script_path_check.py` with a nonexistent host path raised `FileNotFoundError: Could not find module '...nohost.dll' (or one of its dependencies)...`. After (same command): exit 1, stdout empty, stderr is one line: `<dir>\replay.bin: Expected one root states container`. New test `test_replay_failure_is_reported_without_a_traceback` in `CommandLineTests` (`tests/script_state_check.py`) runs that command through `run_tool` and asserts exit code 1, the archive name and `Expected one root states container` in stderr, no `Traceback`, and empty stdout. - `out/pe-env/Scripts/python.exe -B tests/script_state_check.py`: `Ran 16 tests ... OK`. - `out/pe-env/Scripts/python.exe -B tests/bidi_controls_check.py`: `Self-test passed.` and no bidirectional controls in 1233 files. - Negative control: with only `tools/script_path_replay.py` restored to `origin/main`, the same command gives `FAILED (failures=1)`: `AssertionError: 'replay.bin' not found in 'Traceback (most recent call last): ... ValueError: Expected one root states container'`. With the fix restored it passes. Rebased onto `origin/main` at `a3ac47a9` before opening this pull request and re-run there: `tests/script_state_check.py` ran 16 tests, OK; `tests/docs_links_check.py` passed (16 Markdown files, 347 links); `tests/bidi_controls_check.py` passed (1259 files, no bidirectional controls); with `tools/script_path_replay.py` restored to `origin/main` the new test fails. Not run: the missing-host (`OSError`) path is not covered by a test. Reaching `ctypes.CDLL` needs an archive with a root `states` container, and the fixture builder in `tests/script_state_check.py` cannot produce one; the fixture in `tests/script_path_check.py` returns an in-memory tree, not an archive. I only observed that path by calling `replay()` directly, before the change. `tests/script_path_check.py` was not run: it takes the built host DLL as an argument (`tools/script_path_host.cpp`), and no build was done. The test is already registered in `AGENTS.md`, the workflow and CMake. ## Evidence and follow-up Checked again after the rebase: no open upstream PR touches `tools/script_path_replay.py`, `tests/script_state_check.py` or `tests/script_path_check.py`. No issue is linked. AI-assisted.
upstream-sync closed this pull request 2026-11-24 15:02:17 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!1593
No description provided.