The mocked walk test only shows that main's tool never receives onerror. This
adds a POSIX-only test that makes an empty sub-folder mode 000 and runs the scan
as an unprivileged user, so the listing really fails: on WSL2 Ubuntu as nobody
(uid 65534) it fails on main's tool (exit 0, expected 2) and passes with the fix
(13 tests OK). Windows skips it, since a mode change cannot make a folder
unlistable there. Synthetic XML only, no game files.
AI-assisted.
xml_files walked a directory of XML documents with os.walk and no onerror, so
an unlistable sub-folder was silently skipped: the scan printed its summary and
exited 0 with fewer documents, and the report-collision check could not see
those files either. Raise the listing error; main already prints one
`ERROR: cannot read ...` line and exits 2 for an OSError.
The new test on main's tool fails (os.walk receives no onerror); with the fix,
tests/test_gamedata_xml.py runs 12 tests, OK. CPU only, synthetic XML, no game
files.
AI-assisted.
Since 93211578 comments are counted from iterparse "comment" events, which is right for a well-formed
document (comment-like text in CDATA is not a comment). But a truncated or tail-only document stops the
parser at the error, and the comments after it were never counted. When parsing fails, the comment starts
are now counted in the bytes, skipping CDATA sections (an unclosed one runs to the end).
Real data (counts only), the common.rpf carve: --check reports 507 comment starts (412 in 257
declaration-bearing documents), as docs/gamedata.md:471 says; main reported 412 (412). The 95 missing
ones were in 2 truncated tail-only documents.
Tests: test_comments_in_a_document_that_does_not_parse_are_counted (unclosed root, tail-only document,
CDATA closed and cut off; main: the tail-only case gives 0).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
scan_xml() read each element's tail at its "end" event and then cleared the
element, but iterparse can deliver the end event before the parser has read
the tail, so a $(...) reference after a close tag at a 16 KiB boundary was
lost. The tail is now read at the next event (or after the loop), before the
element is cleared.
An encoding declaration Python doesn't know raised LookupError out of
scan_xml() and ended --check in a traceback. It is now recorded as the
document's error, so the file counts as malformed like any other parse error.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>