tooling: report unreadable layouts in verify_build #2463

Merged
louisdibiasi merged 2 commits from upstream-pr/2471 into main 2026-11-25 19:16:58 +00:00
louisdibiasi commented 2026-11-25 17:40:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by louisdibiasi on 2026-11-25T17:40:39Z.


Malformed XML or a layout missing required attributes currently raises a traceback and exits 1, the same status used for a failed payload check. Report these cases as usage errors instead, without writing an integrity report.

The regression check exercises malformed XML and missing chunk and file-group attributes through the CLI. Existing valid layout and torrent checks remain in the same test.

Tests:

  • python -B tests/layout_chunks_check.py (passed)
  • python -B tests/bidi_controls_check.py (passed)
  • git diff --check (passed before commit)

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6610220526 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2471). Originally posted by [louisdibiasi](https://github.com/louisdibiasi) on 2026-11-25T17:40:39Z. --- Malformed XML or a layout missing required attributes currently raises a traceback and exits 1, the same status used for a failed payload check. Report these cases as usage errors instead, without writing an integrity report. The regression check exercises malformed XML and missing chunk and file-group attributes through the CLI. Existing valid layout and torrent checks remain in the same test. Tests: - `python -B tests/layout_chunks_check.py` (passed) - `python -B tests/bidi_controls_check.py` (passed) - `git diff --check` (passed before commit) AI-assisted.
ChazY11 commented 2026-11-25 19:04:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T18:02:31Z.


Four mutations caught, two survive — and the survivors are both cases the fixture's three layouts cannot reach

Baseline: tests/layout_chunks_check.py → layout chunk summary ok, exit 0.

mutation of the new except in verify_build.py result
the whole except clause replaced with except () (nothing caught) caught
ET.ParseError dropped from the tuple caught
KeyError dropped from the tuple caught
OSError dropped from the tuple survived
the message loses {type(exc).__name__} and {exc!a} survived

Why those two survive, from reading the fixture rather than guessing

check_unreadable_layout_is_a_usage_error builds three layouts — <Package>, a <Package><Chunk/></Package> with
a missing field, and a chunk without a FileGroup — and asserts returncode == 2, "layout.xml" in run.stderr,
no Traceback, and no report file. Those three cover ParseError (case 1) and KeyError (cases 2 and 3). None of
them produces an OSError, and none of them looks at the part of the message after the file name:

assert run.returncode == 2
assert "layout.xml" in run.stderr and "Traceback" not in run.stderr

So OSError is in the tuple on principle rather than because a case needs it, and the type(exc).__name__: {exc!a}
suffix — which is the part that makes the message actionable — is unasserted. A reader of this PR learns that an
unreadable layout is a usage error, but not that the error says which kind.

Two cheap ways to close it, either is enough:

  1. assert the suffix for one case: for the empty <Package> case, assert "ParseError" in run.stderr — one line,
    and it distinguishes "readable message" from "any message that mentions the file".
  2. make one layout unreadable rather than malformed: write layout.xml as a directory, or chmod 0 on POSIX
    only, and assert the same three things — that is the only way OSError gets exercised.

I would take (1); (2) is platform-dependent and this check is in the cross-platform list.

What the caught rows establish

Dropping ET.ParseError or KeyError individually each turns the check red, so the tuple is not decorative: the
three fixture layouts really do exercise two of the four members, and losing either makes a malformed layout escape
as an uncaught exception. And except () (nothing caught) fails, which means the assertion on Traceback is doing
its job rather than being satisfied by accident.

AI-assisted; the five mutations were run locally on Windows 11 build 26300.9974.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7170355319 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2471#issuecomment-7170355319). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-25T18:02:31Z. --- ## Four mutations caught, two survive — and the survivors are both cases the fixture's three layouts cannot reach Baseline: `tests/layout_chunks_check.py` → `layout chunk summary ok`, exit 0. | mutation of the new `except` in `verify_build.py` | result | |---|---| | the whole except clause replaced with `except ()` (nothing caught) | **caught** | | `ET.ParseError` dropped from the tuple | **caught** | | `KeyError` dropped from the tuple | **caught** | | `OSError` dropped from the tuple | survived | | the message loses `{type(exc).__name__}` and `{exc!a}` | survived | ### Why those two survive, from reading the fixture rather than guessing `check_unreadable_layout_is_a_usage_error` builds three layouts — `<Package>`, a `<Package><Chunk/></Package>` with a missing field, and a chunk without a `FileGroup` — and asserts `returncode == 2`, `"layout.xml" in run.stderr`, no `Traceback`, and no report file. Those three cover `ParseError` (case 1) and `KeyError` (cases 2 and 3). None of them produces an `OSError`, and none of them looks at the part of the message after the file name: ```python assert run.returncode == 2 assert "layout.xml" in run.stderr and "Traceback" not in run.stderr ``` So `OSError` is in the tuple on principle rather than because a case needs it, and the `type(exc).__name__: {exc!a}` suffix — which is the part that makes the message actionable — is unasserted. A reader of this PR learns that an unreadable layout is a usage error, but not that the error says *which* kind. Two cheap ways to close it, either is enough: 1. **assert the suffix for one case**: for the empty `<Package>` case, `assert "ParseError" in run.stderr` — one line, and it distinguishes "readable message" from "any message that mentions the file". 2. **make one layout unreadable rather than malformed**: write `layout.xml` as a directory, or `chmod 0` on POSIX only, and assert the same three things — that is the only way `OSError` gets exercised. I would take (1); (2) is platform-dependent and this check is in the cross-platform list. ### What the caught rows establish Dropping `ET.ParseError` or `KeyError` individually each turns the check red, so the tuple is not decorative: the three fixture layouts really do exercise two of the four members, and losing either makes a malformed layout escape as an uncaught exception. And `except ()` (nothing caught) fails, which means the assertion on `Traceback` is doing its job rather than being satisfied by accident. AI-assisted; the five mutations were run locally on Windows 11 build 26300.9974.
upstream-sync closed this pull request 2026-11-25 20:04:21 +00:00
tedin7 commented 2026-11-25 20:04:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T19:11:32Z.

Review: COMMENTED


Review of head c798b8e9: sound.

  • compare_layout is now wrapped, so OSError, ET.ParseError and KeyError become a usage error (exit 2). No report is written before the check.
  • Valid layouts take the same path as before.
  • The new test covers three cases through the CLI: unclosed XML, a Chunk without Id, and a FileGroup without attributes. Each checks exit 2, "layout.xml" on stderr, no Traceback, and no report file.
  • Mutation: narrowing the except to OSError only makes tests/layout_chunks_check.py fail on the first case (exit 1 with a traceback). The new test guards the change.
  • No other open or merged PR covers this.

Commands run:

  • python3 -B tests/layout_chunks_check.py (pass)
  • python3 tests/docs_links_check.py (pass)
  • python3 tests/bidi_controls_check.py (pass)
  • git diff --check origin/main...HEAD (clean)

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6063471233 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2471#pullrequestreview-6063471233). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T19:11:32Z. **Review:** COMMENTED --- Review of head c798b8e9: sound. - `compare_layout` is now wrapped, so `OSError`, `ET.ParseError` and `KeyError` become a usage error (exit 2). No report is written before the check. - Valid layouts take the same path as before. - The new test covers three cases through the CLI: unclosed XML, a Chunk without Id, and a FileGroup without attributes. Each checks exit 2, "layout.xml" on stderr, no Traceback, and no report file. - Mutation: narrowing the `except` to `OSError` only makes `tests/layout_chunks_check.py` fail on the first case (exit 1 with a traceback). The new test guards the change. - No other open or merged PR covers this. Commands run: - `python3 -B tests/layout_chunks_check.py` (pass) - `python3 tests/docs_links_check.py` (pass) - `python3 tests/bidi_controls_check.py` (pass) - `git diff --check origin/main...HEAD` (clean) AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 20:04:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T19:16:07Z.


Win2025 WARP receipt for head ac4cd6b0 after updating with main.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit ac4cd6b0a024a3bf9004e42f5907b86e30670852:

  • Windows Python checks: tests/layout_chunks_check.py ok (1.2s)
  • sccache: 0/8 hits; wall 17.5s

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7172059248 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2471#issuecomment-7172059248). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T19:16:07Z. --- Win2025 WARP receipt for head ac4cd6b0 after updating with main. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `ac4cd6b0a024a3bf9004e42f5907b86e30670852`: - **Windows Python checks**: `tests/layout_chunks_check.py` ok (`1.2s`) - `sccache`: 0/8 hits; wall `17.5s` AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 20:04:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T19:16:43Z.


Win2025 WARP receipt for head ac4cd6b0 after updating with main (dev + release).

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit ac4cd6b0a024a3bf9004e42f5907b86e30670852:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev -- -j 2): 0.00s (configure 0.00s)
    • Test (ctest --preset dev -R '^layout_chunk_summary$' --parallel 2 --no-tests=error --output-on-failure): 1/1 passed (1.16s: layout_chunk_summary 1.00s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release -- -j 2): 0.00s (configure 0.00s)
    • Test (ctest --preset release -R '^layout_chunk_summary$' --parallel 2 --no-tests=error --output-on-failure): 1/1 passed (1.20s: layout_chunk_summary 1.03s)
  • Windows Python checks: tests/layout_chunks_check.py ok (0.9s)
  • sccache: 0/12 hits; wall 15.3s

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7172074308 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2471#issuecomment-7172074308). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T19:16:43Z. --- Win2025 WARP receipt for head ac4cd6b0 after updating with main (dev + release). Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `ac4cd6b0a024a3bf9004e42f5907b86e30670852`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev -- -j 2`): `0.00s` (configure `0.00s`) - Test (`ctest --preset dev -R '^layout_chunk_summary$' --parallel 2 --no-tests=error --output-on-failure`): **1/1 passed** (`1.16s`: `layout_chunk_summary` `1.00s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release -- -j 2`): `0.00s` (configure `0.00s`) - Test (`ctest --preset release -R '^layout_chunk_summary$' --parallel 2 --no-tests=error --output-on-failure`): **1/1 passed** (`1.20s`: `layout_chunk_summary` `1.03s`) - **Windows Python checks**: `tests/layout_chunks_check.py` ok (`0.9s`) - `sccache`: 0/12 hits; wall `15.3s` AI-assisted; commands listed were executed locally.
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!2463
No description provided.