Skip to content

ci_expected_failures: accept a UTF-8 BOM in the failed-test list - #8139

Open
KiryaAfimin wants to merge 2 commits into
ItsNotRexed:mainfrom
KiryaAfimin:fix/ci-failure-list-bom
Open

KiryaAfimin wants to merge 2 commits into
ItsNotRexed:mainfrom
KiryaAfimin:fix/ci-failure-list-bom

Conversation

@KiryaAfimin

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as CI failure-list BOM, the second item in that comment.

What and why

Windows PowerShell can save a UTF-8 text file with a byte-order mark. The CI judge included that mark in the first failed test's name. Given a one-line file containing known, runner status 8, and known as the expected failure, the judge printed an unexpected-failure error and a notice that the test had passed, then exited 1.

Remove one leading U+FEFF from the first decoded line. The judge continues reading line by line and compares subsequent names exactly. The same input now produces one expected-failure warning and exits 0. An unexpected name still exits 1.

Related: #7469 handles invalid UTF-8 in the same reader. This change keeps strict decoding, including for a truncated prefix.

Tested

  • Windows, CPython 3.12.10: python -I -B tests/test_ci_expected_failures.py passed all 13 tests. The CLI regression covers plain UTF-8, a leading BOM on an expected or unexpected name, and U+FEFF on a later line. Three subcases failed with the base reader.
  • git diff --check and the project's no-game-data scan passed for both changed files.
  • The repository-wide line-ending test has an existing failure on the base in tools/leonida_tui.py and tools/wave_diff.py.

AI-assisted: yes, OpenAI Codex. Synthetic inputs only.

@neoisg8

neoisg8 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 60154de0 on Windows 11 (Python 3.14.7, CPU-only, no game files): pass.

Test Suite Execution

  • python -I tests/test_ci_expected_failures.py -v: 13/13 passed (0.24s).
    • Verifies test_cli_failure_list_with_optional_utf8_bom across plain UTF-8, leading BOM on expected failure (\ufeffknown\r\n), leading BOM on unexpected failure (\ufeffother\r\n), and duplicate entries where BOM appears on later lines.

Negative Control

  • Reverting scripts/ci_expected_failures.py to origin/main (dde82f27e) against tests/test_ci_expected_failures.py:
    • 10 passed, 3 failed in test_cli_failure_list_with_optional_utf8_bom:
      • failed='\ufeffknown\r\n': returns exit code 1 instead of 0 (AssertionError: Tuples differ: (1, '::error::\ufeffknown failed\n::notice::known passed: drop it from the expected failures\n', '') != (0, '::warning::known failed, as expected until its fix is merged\n', '')).
      • failed='\ufeffother\r\n': prints literal ::error::\ufeffother failed instead of stripping \ufeff.
      • failed='\ufeffknown\r\n\ufeffknown\r\n': misidentifies the first entry.
  • Restoring scripts/ci_expected_failures.py from the PR branch: all 13 tests pass cleanly.

Hygiene

  • python -m compileall -q scripts/ci_expected_failures.py tests/test_ci_expected_failures.py: clean.
  • python -I scripts/check_no_game_data.py scripts/ci_expected_failures.py tests/test_ci_expected_failures.py: clean (synthetic test fixtures only).
  • git diff --check origin/main: clean.
  • Line endings: strict LF preserved across both modified files.

AI-assisted review.

@devnull34 devnull34 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified via Tier 2 Free Cloud (GitHub Models gpt-4.1) & local review: Streaming lines with enumerate(f) and stripping \ufeff solely on index == 0 eliminates loading entire multimegabyte failure manifests into memory via f.read() while preserving UTF-8 BOM compatibility.

@MiguelMatMar

Copy link
Copy Markdown

Tested 60154de on Windows 11 Pro es-ES (cp1252), CPython 3.14.2, CPU only, no game data: pass. tests/test_ci_expected_failures.py: 13 OK. With only scripts/ci_expected_failures.py reverted to main: failures=3. Code read: the BOM is only stripped from line 0, after decoding, so a truncated BOM is still a UTF-8 error. Note for the merger: #7469 (invalid UTF-8 handling) edits the same with open(...) block, so whichever lands second needs a small rebase. LGTM.

(AI-assisted check, Claude Code.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants