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

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

📋 Pull Request Information

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

Base: main ← Head: test/wine-jobs-timing-log


📝 Commits (1)

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

📊 Changes

1 file changed (+7 additions, -5 deletions)

View changed files

📝 tests/test_run_wine_tests.py (+7 -5)

📄 Description

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


🔄 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/1410 **Author:** [@milk4sale](https://github.com/milk4sale) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `test/wine-jobs-timing-log` --- ### 📝 Commits (1) - [`63be3a6`](https://github.com/ubiquitarianism/leonida/commit/63be3a6eb3731c2b7fa4952dab86554a99bf22a3) tests: each fake test of the --jobs tests logs to a file of its own (TEST-WINE-JOBS-TIMING-LOG) ### 📊 Changes **1 file changed** (+7 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_run_wine_tests.py` (+7 -5) </details> ### 📄 Description 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) --- <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#1440
No description provided.