Repository navigation
Live output: cache the tail per requested byte limit — v0.10.8 - #176
Merged
jamesabel merged 4 commits intoOct 20, 2026
Merged
Conversation
The decoded live-output cache is keyed by the file's (size, mtime_ns) only, but the text it holds is the *tail* of the file and therefore depends on max_bytes. A read with one byte limit can be served the tail computed for a different one. Adds two regression tests that fail on the current implementation: - a large-limit read after a small-limit read must not reuse the small tail - a small-limit read after a large-limit read must not return more than the limit
The decoded live-output cache was keyed by the log file's path alone, but the text it stores is the *tail* of that file, so the cached value also depends on the max_bytes limit the read was made with. The first call for a given file therefore fixed the length of the text every later call received. This is reachable in the app: the Table tab and the Live Output pane read the same log file with the 65536-byte default, while resolve_test_output() asks for 10,000,000 bytes. Whichever ran first decided how much output the others saw -- a read could return far fewer bytes than requested (with a spurious "...[truncated]..." marker) or far more than requested. Key the cache by (path, max_bytes) so each limit gets its own cached tail. Also bumps the version to 0.10.7.
…mesabel#177) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #176 +/- ##
=======================================
Coverage 85.70% 85.70%
=======================================
Files 74 74
Lines 6450 6451 +1
=======================================
+ Hits 5528 5529 +1
Misses 922 922 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was broken
read_live_output()could return text that did not match themax_byteslimit it was called with. The decoded-text cache was keyed by the log file's path alone, but the text it stores is the tail of that file, so the cached value also depends on the byte limit. The first read of a given log file therefore fixed the length of the text that every later read of that file received:...[truncated]...marker even when nothing had to be elided;In the running app the Table tab and the Live Output pane read the same log file with the 65536-byte default, while
resolve_test_output()asks for 10,000,000 bytes — so whichever of them ran first decided how much output the others saw.Root cause
src/pytest_fly/pytest_runner/live_output.py:22declared the module-level cache as_read_cache: dict[Path, tuple[int, int, str]] = {}— keyed by path only. The entry was looked up atsrc/pytest_fly/pytest_runner/live_output.py:52and stored atsrc/pytest_fly/pytest_runner/live_output.py:66, and neither the key nor the stored value tookmax_bytesinto account — even though the stored string is the tail read atsrc/pytest_fly/pytest_runner/live_output.py:57-59, and so is a function ofmax_bytesas well as of the file's contents.The change
src/pytest_fly/pytest_runner/live_output.py— the cache is now keyed by(path, max_bytes), so each byte limit gets its own cached tail. The cached value keeps its(size, mtime_ns, text)shape; only the key changed.tests/test_live_output.py— two regression tests, one for each direction (a large limit after a small one, and a small limit after a large one). The existing cache test now addresses the cache by its new key.pyproject.toml— version bump to 0.10.7.How this was verified
Regression tests against the unmodified
live_output.py:The same tests with the fix applied:
Full suite, unmodified
masterbaseline versus this branch:The +4 is accounted for: +2 are the new regression tests, and +2 are
tests/tests_many/test_many_000.pyandtest_many_001.py— the session fixturemake_many_testscreates that directory during the first run (after collection, so those two files are not collected in that run) and they are collected from the second run onwards.Lint and format are clean:
Coverage of the changed module is unchanged; the only uncovered lines in
src/pytest_fly/pytest_runner/live_output.pyare the two pre-existingexcept OSError: passbranches inclear_live_output(lines 82-83 and 86-87), which this change does not touch.The above was run locally on macOS (Python 3.13.9, PySide6 6.11.0) with the suite headless, using
QT_QPA_PLATFORM=offscreenas CI does. The change itself is pure Python and platform-independent.CI status
The
mainworkflow for this branch did run — run 39335619684,conclusion: failure. Its jobs are:test (3.14)→ failuretest (3.15)→ cancelledtest (3.12)→ cancelledmain.ymlbuilds a matrix over['3.12', '3.14', '3.15']and does not setfail-fast: false, so the default fail-fast applies: the 3.12 and 3.15 jobs were cancelled once the 3.14 job failed, rather than running to completion.The 3.14 job log ends with the suite passing and the process then dying:
Exit code 139 is
128 + SIGSEGV, so no test failed — the interpreter crashed during shutdown (Qt/PySide6 teardown) after the test session had already finished.That crash is pre-existing on the base commit and is not caused by this change. This PR's base is
bfa652b1c6b0db810844daa42d40da754e7bcc1c, which is the currentmasterhead of this repository. Themainworkflow on that same commit — run 36520991752 (event: push,head_branch: master,run_attempt: 2) — also concludesfailure, with the same signature:test (3.14)fails while 3.12/3.15 are cancelled, and its log ends withThe only difference between the two runs is the test count: 519 on the base commit versus 521 here — exactly the two regression tests added by this PR. The failing job, the exit code and the timing are identical.
So the workflow is not waiting for a maintainer approval: it ran, and the failure reproduces on the unmodified base commit.
Fixes #175
This change was prepared with the assistance of an AI coding agent.