[PR #1853] [MERGED] tools/ab_control_flow: handle UTF-8-SIG/CRLF inputs, subprocess encoding and atomic outcomes.tsv #1865

Closed
opened 2026-11-26 21:19:13 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1853
Author: @kirigayakazima
Created: 11/25/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142

Base: main ← Head: fix/ab-control-flow-safety


📝 Commits (1)

  • 3a84ae7 tools/ab_control_flow: handle UTF-8-SIG/CRLF inputs, subprocess encoding and atomic outcomes.tsv

📊 Changes

2 files changed (+128 additions, -11 deletions)

View changed files

📝 tests/test_ab_control_flow.py (+90 -0)
📝 tools/ab_control_flow.py (+38 -11)

📄 Description

Claimed in the coordination issue as: AB-CONTROL-FLOW-CRLF-BOM-AND-ATOMIC-TSV (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7163364385)

What and why

  • Read --names and index.json in tools/ab_control_flow.py with encoding="utf-8-sig" and parse --names lines via splitlines() + .strip() so UTF-8 BOMs and Windows CRLF endings do not corrupt shader names.
  • Write outcomes.tsv atomically in write_outcomes() (tempfile.mkstemp beside os.path.realpath(...), os.fsync, published_mode, and replace_retry.replace), preserving any existing file and cleaning up staging files on failure.
  • Pass encoding="utf-8", errors="replace" to subprocess.run(..., capture_output=True, text=True) in render_targets() and main() for safe decoding under python -I.
  • Add regression tests in tests/test_ab_control_flow.py.

Tested

  • python -I tests/test_ab_control_flow.py -v -> Ran 70 tests in 1.849s, OK (skipped=1) (Windows skips chmod 000 test).
  • Detached upstream/main (98c2f777) baseline worktree with updated tests/test_ab_control_flow.py -> Ran 70 tests in 1.733s, FAILED (failures=2, errors=2, skipped=1).
  • python -I tests/test_ci_registration.py -> Ran 16 tests in 7.338s, OK.
  • python -I tests/test_text_write_line_endings.py -> Ran 3 tests in 14.354s, OK.
  • python -I scripts/check_no_game_data.py tools/ab_control_flow.py tests/test_ab_control_flow.py, python -I -m compileall -q tools/ab_control_flow.py tests/test_ab_control_flow.py, and git diff --check -> exit 0.

GPUs tested: n/a (CPU/stdlib Python tests on Windows 11 x64)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1853 **Author:** [@kirigayakazima](https://github.com/kirigayakazima) **Created:** 11/25/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `fix/ab-control-flow-safety` --- ### 📝 Commits (1) - [`3a84ae7`](https://github.com/ubiquitarianism/leonida/commit/3a84ae7aa84afed797f9fd652eda09851d293661) tools/ab_control_flow: handle UTF-8-SIG/CRLF inputs, subprocess encoding and atomic outcomes.tsv ### 📊 Changes **2 files changed** (+128 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_ab_control_flow.py` (+90 -0) 📝 `tools/ab_control_flow.py` (+38 -11) </details> ### 📄 Description Claimed in the coordination issue as: AB-CONTROL-FLOW-CRLF-BOM-AND-ATOMIC-TSV (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7163364385) ### What and why - Read `--names` and `index.json` in `tools/ab_control_flow.py` with `encoding="utf-8-sig"` and parse `--names` lines via `splitlines()` + `.strip()` so UTF-8 BOMs and Windows CRLF endings do not corrupt shader names. - Write `outcomes.tsv` atomically in `write_outcomes()` (`tempfile.mkstemp` beside `os.path.realpath(...)`, `os.fsync`, `published_mode`, and `replace_retry.replace`), preserving any existing file and cleaning up staging files on failure. - Pass `encoding="utf-8", errors="replace"` to `subprocess.run(..., capture_output=True, text=True)` in `render_targets()` and `main()` for safe decoding under `python -I`. - Add regression tests in `tests/test_ab_control_flow.py`. ### Tested - `python -I tests/test_ab_control_flow.py -v` -> `Ran 70 tests in 1.849s`, `OK (skipped=1)` (Windows skips `chmod 000` test). - Detached `upstream/main` (`98c2f777`) baseline worktree with updated `tests/test_ab_control_flow.py` -> `Ran 70 tests in 1.733s`, `FAILED (failures=2, errors=2, skipped=1)`. - `python -I tests/test_ci_registration.py` -> `Ran 16 tests in 7.338s`, `OK`. - `python -I tests/test_text_write_line_endings.py` -> `Ran 3 tests in 14.354s`, `OK`. - `python -I scripts/check_no_game_data.py tools/ab_control_flow.py tests/test_ab_control_flow.py`, `python -I -m compileall -q tools/ab_control_flow.py tests/test_ab_control_flow.py`, and `git diff --check` -> exit `0`. GPUs tested: n/a (CPU/stdlib Python tests on Windows 11 x64) AI-assisted: yes ### Checklist - [x] Based on current main and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 21:19:13 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1865
No description provided.