mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:55:52 +01:00
[PR #662] [MERGED] run_semantic_tests: count the tests from unittest, not from the merged output #702
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#702
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/662
Author: @Mby159
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @QemmHD
Base:
main← Head:fix/semantic-ran-count-stream📝 Commits (3)
23b190brun_semantic_tests: count the tests from unittest, not from the merged output7d184afsemantic tests: count from unittest's own summaryf48c2b2semantic tests: count from unittest's result object📊 Changes
2 files changed (+100 additions, -17 deletions)
View changed files
📝
scripts/run_semantic_tests.py(+51 -17)📝
tests/test_run_semantic_tests.py(+49 -0)📄 Description
Claim: SEMANTIC-RAN-COUNT-STREAM
The count came from the wrong stream.
scripts/run_semantic_tests.pycounted a module's tests by scanning themerged stdout+stderr for the first line that reads
Ran N tests in, so a test that printed such a line itself couldbe counted instead of unittest's own summary. @Dezmonius reported this on #14
(#issuecomment-7128362815) and offered to take it if it were added to Open work; the Open work table cannot be
edited by a contributor (GitHub answers
403 Must have admin rights to Repository), so I took it rather than leaveit unowned. His finding is the starting point.
Reproduced on
main21625bca8. A module whose test printsRan 0 tests in 0.000sand flushes it was reportedas
1 files, 0 tests, 0 files failedandno tests ran, and the runner exited 1, although the module ran itstests and passed. Which line won depended on stdout buffering: a test that does not flush lands its line after
unittest's summary (the count is right), a test that does flush lands it first (the count is 0). Neither the first
nor the last match is reliable.
The fix. unittest writes its own summary (
Ran N tests in X s) and itsNO TESTS RANto stderr; a test's ownoutput goes to stdout. The runner now captures the two streams apart and counts from stderr. The merged text is
still what a failing module prints, and the timeout path keeps both streams.
Testing. Windows 11 10.0.29712, CPython 3.13.17:
1 files, 1 tests, 0 files failedand exits 0;python -I tests/test_run_semantic_tests.py: 20 tests, OK. The file gained a case that covers both orders, a testthat flushes its line and a test that prints it at process exit;
tests/semantic, one subset counted the same in parallel and in serial:-j 4gave4 files, 18 tests, 0 files failed,-j 1(unittest discover) gaveRan 18 tests.No game files, no GPU and no particular hardware: the runner and its test file are the check.
AI-assisted (MiniMax Code).
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.