[PR #1591] xcl_compare: open transcript before Popen, format float timeouts, validate paths upfront, write JSON atomically (XCL-COMPARE-GUARDS-AND-ATOMIC-IO) #1611

Open
opened 2026-11-26 20:21:51 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1591
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: fix/xcl-compare-guards-and-atomic-io


📝 Commits (1)

  • 97f9a33 xcl_compare: open transcript before Popen, format float timeouts, validate paths upfront, write JSON atomically

📊 Changes

2 files changed (+202 additions, -25 deletions)

View changed files

📝 tests/test_xcl_compare.py (+101 -0)
📝 tools/xcl_compare.py (+101 -25)

📄 Description

Item: XCL-COMPARE-GUARDS-AND-ATOMIC-IO (unclaimed — coordination issue #14 is at GitHub's 2,500-comment cap with no successor open issue yet, and 0 open PRs touch tools/xcl_compare.py).

Summary

  • Open transcript before spawning subprocess.Popen in run_title() and clean up any still-running child process on unexpected exceptions, preventing leaked child processes when opening the transcript fails.
  • Catch OSError (including ProcessLookupError) in kill_tree() when a hung process exits just before termination, and fall back to proc.kill() if taskkill fails on Windows.
  • Format hang reasons with %g s instead of %d s in _follow() so sub-second --timeout values (e.g. 0.5) report "no output for 0.5 s" rather than truncating to "no output for 0 s".
  • Validate empty/whitespace --xcl/--gta6rt/--work/--cdb/--out and directory/trailing-separator --out upfront before running either runtime, write report.json atomically via file_mode.published_mode + replace_retry.replace with allow_nan=False, accept optional argv=None in main(), and guard sys.stdout.reconfigure.

Verification

  • python3 -W error -I tests/test_xcl_compare.py -v: 20/20 passed.
  • python3 -I tests/test_text_write_line_endings.py: 3/3 passed.
  • python3 -I scripts/check_no_game_data.py tools/xcl_compare.py tests/test_xcl_compare.py: passed.
  • python3 -m compileall -q tools/xcl_compare.py tests/test_xcl_compare.py: passed.
  • Mutation check (running tests/test_xcl_compare.py against unpatched main:tools/xcl_compare.py): failures=8, errors=1 across all 5 new regression tests.

AI-assisted: yes
GPUs tested: none (CPU-only Python test harness; synthetic Python stand-ins only, no game data)


🔄 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/1591 **Author:** [@IlyassRS3](https://github.com/IlyassRS3) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/xcl-compare-guards-and-atomic-io` --- ### 📝 Commits (1) - [`97f9a33`](https://github.com/ubiquitarianism/leonida/commit/97f9a33178e39caebef9e66f50ffd813dce6bb1c) xcl_compare: open transcript before Popen, format float timeouts, validate paths upfront, write JSON atomically ### 📊 Changes **2 files changed** (+202 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_xcl_compare.py` (+101 -0) 📝 `tools/xcl_compare.py` (+101 -25) </details> ### 📄 Description Item: `XCL-COMPARE-GUARDS-AND-ATOMIC-IO` (unclaimed — coordination issue #14 is at GitHub's 2,500-comment cap with no successor open issue yet, and 0 open PRs touch `tools/xcl_compare.py`). ### Summary - Open `transcript` before spawning `subprocess.Popen` in `run_title()` and clean up any still-running child process on unexpected exceptions, preventing leaked child processes when opening the transcript fails. - Catch `OSError` (including `ProcessLookupError`) in `kill_tree()` when a hung process exits just before termination, and fall back to `proc.kill()` if `taskkill` fails on Windows. - Format hang reasons with `%g s` instead of `%d s` in `_follow()` so sub-second `--timeout` values (e.g. `0.5`) report `"no output for 0.5 s"` rather than truncating to `"no output for 0 s"`. - Validate empty/whitespace `--xcl`/`--gta6rt`/`--work`/`--cdb`/`--out` and directory/trailing-separator `--out` upfront before running either runtime, write `report.json` atomically via `file_mode.published_mode` + `replace_retry.replace` with `allow_nan=False`, accept optional `argv=None` in `main()`, and guard `sys.stdout.reconfigure`. ### Verification - `python3 -W error -I tests/test_xcl_compare.py -v`: 20/20 passed. - `python3 -I tests/test_text_write_line_endings.py`: 3/3 passed. - `python3 -I scripts/check_no_game_data.py tools/xcl_compare.py tests/test_xcl_compare.py`: passed. - `python3 -m compileall -q tools/xcl_compare.py tests/test_xcl_compare.py`: passed. - Mutation check (running `tests/test_xcl_compare.py` against unpatched `main:tools/xcl_compare.py`): `failures=8, errors=1` across all 5 new regression tests. AI-assisted: yes GPUs tested: none (CPU-only Python test harness; synthetic Python stand-ins only, no game data) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#1611
No description provided.