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

Open
github-bot wants to merge 1 commit from github-bot/gh-1410 into main AGit
Owner

@⁠milk4sale on GitHub · 2026-11-24 23:38 UTC · original
milk4sale:test/wine-jobs-timing-log → main · +7 −5 · 1 files · 1 commits · open

Claimed in the coordination issue as: TEST-WINE-JOBS-TIMING-LOG (#14)

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

**@⁠milk4sale** on GitHub · 2026-11-24 23:38 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1410) `milk4sale:test/wine-jobs-timing-log` → `main` · +7 −5 · 1 files · 1 commits · open Claimed in the coordination issue as: TEST-WINE-JOBS-TIMING-LOG (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### 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)
tests/test_run_wine_tests.py fails on Windows since #1354 added the --jobs tests: in the check job's loop it
failed in 2 of 4 runs on a windows-latest runner, 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. The job's 15-minute limit cancels it before it prints its list of failed files, which is why
nobody saw it.

The fake test programs of those tests run several at a time, and each appended its "start" and "end" line to one
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. A test whose 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), and a mangled line fails in intervals().

Each fake test now gets its own log (timing.<name>.log) and intervals() reads them all. The tests assert what
they asserted before.

Measured on GitHub's runners with Python 3.12 (a scratch branch on a fork, each system once):
- four processes that append two lines each to one file at the same moment, 150 rounds: a line was lost in 150
  rounds on windows-latest and in none on ubuntu-24.04 and macos-26; with a file per process, in none anywhere;
- the two --jobs tests run 60 times: 60 failures on windows-latest before this change and none after; none
  before or after on ubuntu-24.04 and macos-26.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:50:27 +00:00
Author
Owner

@⁠PierreEbele on GitHub · 2026-11-25 09:29 UTC · original

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

**@⁠PierreEbele** on GitHub · 2026-11-25 09:29 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1410#issuecomment-7158400099) 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
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1410/head:github-bot/gh-1410'
git switch 'github-bot/gh-1410'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1410'
git switch 'github-bot/gh-1410'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1410'
git switch 'github-bot/gh-1410'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1410'
git switch 'main'
git merge --squash 'github-bot/gh-1410'
git switch 'main'
git merge --ff-only 'github-bot/gh-1410'
git switch 'main'
git merge 'github-bot/gh-1410'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.