Repository navigation
Dispose the display of the test thread after each test class - #3873
Draft
HeikoKlare wants to merge 2 commits into
Draft
HeikoKlare wants to merge 2 commits into
HeikoKlare wants to merge 2 commits into
Conversation
Contributor
HeikoKlare
force-pushed
the
display-lifecycle-extension
branch
from
November 19, 2026 16:01
a0c2706 to
d3c4177
Compare
When a shell opens, adjustTrim derives the trim from the difference between the frame extents and the allocation of the window, and stores it on the display for all later shells. The allocation can still be the one from before the window was resized, so the shell measures a trim that does not exist and every later shell reports a size that is off by it. For example, a shell opened with 300x200 reports a width of 400. Use the current size of the window instead. This was hidden in the test suite as long as an earlier test had opened a shell with a trim above the maximum, which disables learning the trim for the rest of the lifetime of the display. The new test therefore opens its shells on a new display. Assisted-by: Claude Opus 5.5 <[email protected]>
The test classes of a suite share the test thread, and a display stays associated with the thread that created it until it is disposed. A class that leaves the default display behind therefore influences all classes that run after it. For example, a class that creates its own display fails with an invalid thread access, and the failure points at that class instead of the one that left the display behind. The new DisplayLifecycleExtension disposes the display after all tests of a class and fails a test that leaves shells open. It keeps the display for all tests of a class, as recreating it for every test disturbs the focus that keyboard and drag-and-drop tests rely on. JUnit registers the extension for every test class of the bundle by automatic extension detection, so new test classes get it without further effort. Tests that disposed the display only to clean up no longer do so. Assisted-by: Claude Opus 5.5 <[email protected]>
HeikoKlare
force-pushed
the
display-lifecycle-extension
branch
from
November 19, 2026 21:22
d3c4177 to
74f9ca3
Compare
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.
Important
This PR is based on #3878 and contains its commit, so only the last commit belongs to this PR. #3878 needs to be merged first: it fixes a GTK3 bug in the size of new shells, which this PR exposes because every test class now starts with a new display.
Problem
The test classes of a suite share one test thread, and a display stays associated with the thread that created it until it is disposed. A class that leaves the default display behind therefore affects every class that runs after it. A class that creates its own display then fails with an invalid thread access, and the failure points at that class instead of the one that left the display behind. Whether the suite passes depends on the order of its classes.
Solution
A new JUnit extension disposes the display after all tests of a class, so every class starts on a thread without a display. It also fails any test that leaves shells open, so the test that leaks is the one that gets reported. The display stays alive for all tests of a class, because creating a new display for every test disturbs the focus that the keyboard and drag-and-drop tests rely on.
JUnit registers the extension for every test class of the bundle by automatic extension detection, so new test classes get it without further effort. Tests that disposed the display only to clean up no longer do so.
This follows #3870, which fixed the shells that tests left open.
🤖 Generated with Claude Code