-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Introduce experimental memory cleanup mode #5588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
41b9bb5
Introduce experimental memory cleanup mode
marcphilipp a3eee5e
Override removeInternal in InternalTestPlan
mpkorstanje 8737d94
Spotless
mpkorstanje 3fbe8b5
Also remove from parent->child mapping
mpkorstanje a53fea8
Wrap parent engine execution listener as well
marcphilipp 3a00e90
Avoid unnecessary operations for descendants of removed identifiers
marcphilipp 48f77bb
Fix summary printing
marcphilipp b80c372
Add integration test
marcphilipp 1d11a29
Document default value
marcphilipp b0825f5
Improve Javadoc
marcphilipp 747739c
Add entry to release notes
marcphilipp a04e062
Disable on OpenJ9
marcphilipp 3c0b0e7
Increase timeout on Windows
marcphilipp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
54 changes: 54 additions & 0 deletions
54
...atform-launcher/src/main/java/org/junit/platform/launcher/core/MemoryCleanupListener.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| /* | ||
| * Copyright 2026 the original author or authors. | ||
| * | ||
| * All rights reserved. This program and the accompanying materials are | ||
| * made available under the terms of the Eclipse Public License v2.0 which | ||
| * accompanies this distribution and is available at | ||
| * | ||
| * https://www.eclipse.org/legal/epl-v20.html | ||
| */ | ||
|
|
||
| package org.junit.platform.launcher.core; | ||
|
|
||
| import java.util.stream.Stream; | ||
|
|
||
| import org.junit.platform.engine.EngineExecutionListener; | ||
| import org.junit.platform.engine.TestDescriptor; | ||
| import org.junit.platform.engine.TestExecutionResult; | ||
| import org.junit.platform.launcher.TestPlan; | ||
|
|
||
| /** | ||
| * @since 6.1 | ||
| */ | ||
| class MemoryCleanupListener extends DelegatingEngineExecutionListener { | ||
|
|
||
| private final TestPlan testPlan; | ||
|
|
||
| MemoryCleanupListener(EngineExecutionListener delegate, TestPlan testPlan) { | ||
| super(delegate); | ||
| this.testPlan = testPlan; | ||
| } | ||
|
|
||
| @Override | ||
| public void executionSkipped(TestDescriptor testDescriptor, String reason) { | ||
| super.executionSkipped(testDescriptor, reason); | ||
| cleanUp(testDescriptor); | ||
| } | ||
|
|
||
| @Override | ||
| public void executionFinished(TestDescriptor testDescriptor, TestExecutionResult testExecutionResult) { | ||
| super.executionFinished(testDescriptor, testExecutionResult); | ||
| cleanUp(testDescriptor); | ||
| } | ||
|
|
||
| private void cleanUp(TestDescriptor testDescriptor) { | ||
| var ownUniqueId = Stream.of(testDescriptor.getUniqueId()); | ||
| var descendantUniqueIds = testDescriptor.getDescendants().stream() // | ||
| .map(TestDescriptor::getUniqueId); | ||
| Stream.concat(ownUniqueId, descendantUniqueIds) // | ||
| .forEach(testPlan::removeInternal); | ||
|
marcphilipp marked this conversation as resolved.
Outdated
|
||
| if (!testDescriptor.isRoot()) { | ||
| testDescriptor.removeFromHierarchy(); | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.