Repository navigation
test: drive collect_until's late-finaliser test off a fake clock (#2016) - #2017
Merged
Merged
Conversation
The test called the engine's real gc.collect under a wall-clock grace of 5 s, so GraalPy on a loaded runner could not fit the three collections the predicate needs. Patch gc.collect, time.monotonic and time.sleep with fakes (each collection costing a fake second), so the test checks the contract rather than engine speed, and cover the two edges it left untested: a predicate that holds with no grace, and one that never holds and must stop once the grace is spent.
JarryShaw
force-pushed
the
fix/2016-collect-until-grace
branch
from
October 21, 2026 15:08
8d17724 to
18d3284
Compare
Owner
Author
|
GOOD TO GO at A Sonnet cross-review:
GraalPy itself was not run; the graalpy-25.4 leg will be the first real check. |
Contributor
|
Coverage: 91.55% (unit tier, Python 3.15,
Per-file detail: the |
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.
Please follow the guide below
You will be asked some questions, please read them carefully and answer honestly
Put an
xinto all the boxes [ ] relevant to your pull request (like that [x])Use Preview tab to see how your pull request will actually look like
Searched for similar pull requests
Followed the coding style (
make pylint,make mypy;make isortnot run)make testpasses, and a test case covers the change (onlytests/foundation/test_extraction_ownership.pywas run locally; CI covers the rest)Added a changelog entry under
docs/source/changelog/and regeneratedCHANGELOG.md, if the change is user-visible — N/A — centralised in docs(changelog): shared 1.5.0 changelog — long-lived, merges last (#610, #616, #617, #618, #620) #657What is the purpose of your pull request?
Tick the commit type your subject line carries.
fix— corrects a defectfeat— adds a featureperf— changes performance, not behaviourrefactor— changes neither behaviour nor performancetest— tests onlydocs— documentation onlyci— workflows or build toolingrelease— bumps the version or rolls up a distributionchore— anything elseDescription of your pull request and other information
Closes #2016.
collect_untilitself is sound: it checks the predicate before the deadline. The trouble was the test, which ran the engine's realgc.collectagainst a 5 s wall-clock grace. It now patchesgc.collect,time.monotonicandtime.sleepwith fakes, each collection costing one fake second. It also covers two edges that were untested: a predicate that holds with no grace (CPython's case), and one that never holds and stops once the grace is spent.Evidence, with
gc.collectpatched to sleep 3 s: the old test fails withFalse is not true, matching the GraalPy leg, and the new one passes in 0.05 s. The new test also fails against a mutant that checks the deadline first and against one that ignores the grace.FINALISER_GRACEis left untouched, so this does not conflict with #2006.