tests: each fake test of the --jobs tests logs to a file of its own (TEST-WINE-JOBS-TIMING-LOG) #1410

Closed
milk4sale wants to merge 1 commit from upstream-pr/1410 into main
milk4sale commented 2026-11-24 23:38:09 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by milk4sale on 2026-11-24T23:38:09Z.


Claimed in the coordination issue as: TEST-WINE-JOBS-TIMING-LOG (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7147387006)

What and why

tests/test_run_wine_tests.py fails on Windows since #1354 added the --jobs tests. In the check job's loop on a windows-latest runner it failed in 2 of the 4 runs that had the file, both times in MainTest.test_jobs_keeps_locks_serial_tests_and_dependencies: once with KeyError: 'after' and once with IndexError: list index out of range in overlap(). It passes on Linux and macOS. Nobody saw it because check is cancelled at its 15-minute limit before it prints its list of failed files (#1404).

The cause is in the test, not in scripts/run_wine_tests.py. The fake test programs of the two --jobs tests run several at a time, and each appended its start and end line to one shared timing.log with open(log, 'a').write(...). On Windows an append from another process is not atomic: both writers find the same end of file and one line replaces the other. Then:

  • a fake test whose two lines are both lost is missing from the result (the KeyError);
  • one that lost a line has a single timestamp (the IndexError, or not enough values to unpack in most_at_once);
  • a mangled line fails in intervals().

Each fake test now logs to a file of its own (timing.<name>.log), and intervals() reads them all. The tests assert exactly what they asserted before. Seven lines change in one test file.

Tested

Measured on GitHub's runners with Python 3.12, one run per system, from a scratch branch on my fork whose workflow ran only this (run 45510380923):

windows-latest ubuntu-24.04 macos-26
Four processes append two lines each to one file at the same moment, 150 rounds: rounds that lost a line 150 0 0
The same with a file per process 0 0 0
The two --jobs tests run 60 times on main's file: runs that failed 60 0 0
The same with this change 0 0 0

The first row is the cause measured on its own; a round on Windows typically kept 2 to 4 of its 8 lines. The scratch branch ran this change without the sentence I then added to timed's docstring; the code is the same.

In the full check loop the file failed in 2 of 4 runs (fork runs 45502632816 and 45506216167) and passed in 2, so there it is intermittent; run on their own the two tests failed every time.

Locally, on Linux with Python 3.14.10:

  • python -I tests/test_run_wine_tests.py: 72 tests pass.
  • The two --jobs tests 20 times in a row: 20 pass.
  • python -I scripts/check_no_game_data.py tests/test_run_wine_tests.py and git diff --check.

Not run: Wine itself. The change is inside the test's fake programs and does not touch the runner.

GPUs tested: n/a (one Python test file)

AI-assisted: yes (Claude Code)

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. (No translator change.)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5482202298 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1410). Originally posted by [milk4sale](https://github.com/milk4sale) on 2026-11-24T23:38:09Z. --- Claimed in the coordination issue as: TEST-WINE-JOBS-TIMING-LOG (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7147387006) ### What and why `tests/test_run_wine_tests.py` fails on Windows since #1354 added the `--jobs` tests. In the `check` job's loop on a `windows-latest` runner it failed in 2 of the 4 runs that had the file, both times in `MainTest.test_jobs_keeps_locks_serial_tests_and_dependencies`: once with `KeyError: 'after'` and once with `IndexError: list index out of range` in `overlap()`. It passes on Linux and macOS. Nobody saw it because `check` is cancelled at its 15-minute limit before it prints its list of failed files (#1404). The cause is in the test, not in `scripts/run_wine_tests.py`. The fake test programs of the two `--jobs` tests run several at a time, and each appended its `start` and `end` line to one shared `timing.log` with `open(log, 'a').write(...)`. On Windows an append from another process is not atomic: both writers find the same end of file and one line replaces the other. Then: - a fake test whose two lines are both lost is missing from the result (the `KeyError`); - one that lost a line has a single timestamp (the `IndexError`, or `not enough values to unpack` in `most_at_once`); - a mangled line fails in `intervals()`. Each fake test now logs to a file of its own (`timing.<name>.log`), and `intervals()` reads them all. The tests assert exactly what they asserted before. Seven lines change in one test file. ### Tested Measured on GitHub's runners with Python 3.12, one run per system, from a scratch branch on my fork whose workflow ran only this ([run 45510380923](https://github.com/milk4sale/leonida/actions/runs/45510380923)): | | `windows-latest` | `ubuntu-24.04` | `macos-26` | |---|---|---|---| | Four processes append two lines each to one file at the same moment, 150 rounds: rounds that lost a line | 150 | 0 | 0 | | The same with a file per process | 0 | 0 | 0 | | The two `--jobs` tests run 60 times on `main`'s file: runs that failed | 60 | 0 | 0 | | The same with this change | 0 | 0 | 0 | The first row is the cause measured on its own; a round on Windows typically kept 2 to 4 of its 8 lines. The scratch branch ran this change without the sentence I then added to `timed`'s docstring; the code is the same. In the full `check` loop the file failed in 2 of 4 runs (fork runs [45502632816](https://github.com/milk4sale/leonida/actions/runs/45502632816) and [45506216167](https://github.com/milk4sale/leonida/actions/runs/45506216167)) and passed in 2, so there it is intermittent; run on their own the two tests failed every time. Locally, on Linux with Python 3.14.10: - `python -I tests/test_run_wine_tests.py`: 72 tests pass. - The two `--jobs` tests 20 times in a row: 20 pass. - `python -I scripts/check_no_game_data.py tests/test_run_wine_tests.py` and `git diff --check`. Not run: Wine itself. The change is inside the test's fake programs and does not touch the runner. GPUs tested: n/a (one Python test file) AI-assisted: yes (Claude Code) ### 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. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (No translator change.) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
PierreEbele commented 2026-11-25 09:29:24 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-25T09:29:24Z.


Reviewed 63be3a6: ran the full tests/test_run_wine_tests.py on my side (Linux), 72/72 pass on the PR and
on main, plus 20 reruns of the two --jobs tests on both trees; the per-file timing logs parse to the same
spans the shared log gives and the existing assertions are untouched. The Windows-only line loss cannot
reproduce on this host (Linux appends are atomic), but a corrupted shared log reproduces the reported
KeyError on main, and with one file per process no writer can lose another test's line. No findings.

AI-assisted review.

Recommendation: Merge

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7158400099 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1410#issuecomment-7158400099). Originally posted by [PierreEbele](https://github.com/PierreEbele) on 2026-11-25T09:29:24Z. --- Reviewed 63be3a6: ran the full tests/test_run_wine_tests.py on my side (Linux), 72/72 pass on the PR and on main, plus 20 reruns of the two --jobs tests on both trees; the per-file timing logs parse to the same spans the shared log gives and the existing assertions are untouched. The Windows-only line loss cannot reproduce on this host (Linux appends are atomic), but a corrupted shared log reproduces the reported KeyError on main, and with one file per process no writer can lose another test's line. No findings. AI-assisted review. **Recommendation:** Merge
MoonEyes commented 2026-11-28 02:54:54 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T02:54:54Z.


Hi @milk4sale, thanks for this pull request. It currently conflicts with main (conflicting file(s): tests/test_run_wine_tests.py), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232675113 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1410#issuecomment-7232675113). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T02:54:54Z. --- Hi @milk4sale, thanks for this pull request. It currently conflicts with `main` (conflicting file(s): `tests/test_run_wine_tests.py`), so it carries the `needs rebase` label. CONTRIBUTING.md asks authors to rebase their branch on `main`; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here. AI-assisted (Claude Code, Claude Opus 5.5).
aslan2142 commented 2026-12-01 11:37:12 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:37:12Z.


Closing as already fixed on main: tests/test_run_wine_tests.py:688-715 on main already gives each timed test its own per-test timing log file and globs them in intervals(). (AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7309892352 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1410#issuecomment-7309892352). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T11:37:12Z. --- Closing as already fixed on main: tests/test_run_wine_tests.py:688-715 on main already gives each timed test its own per-test timing log file and globs them in intervals(). *(AI-assisted review.)*

Pull request closed

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
ProjectLeonida/mandy!1410
No description provided.