FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Auto-port 5.0: Avoid leak presence detector in leak profile by netty-project-bot · Pull Request #17082 · netty/netty · GitHub

/ netty Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .java  (2) .xml  (1) All 2 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
6 changes: 5 additions & 1 deletion pom.xml
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
Expand Up @@ -339,7 +339,11 @@
<profile>
<id>leak</id>
<properties>
<argLine.leak>-Dio.netty.leakDetectionLevel=paranoid -Dio.netty.leakDetection.targetRecords=32</argLine.leak>
<argLine.leak>
-Dio.netty.leakDetectionLevel=paranoid
-Dio.netty.leakDetection.targetRecords=32
-Dio.netty.test.leakPresenceDetection.disabled=true
</argLine.leak>
</properties>
</profile>
<profile>
Expand Down
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
Expand Up @@ -21,7 +21,9 @@
import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ConditionEvaluationResult;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.ExecutionCondition;

import java.util.Objects;
import java.util.concurrent.TimeUnit;
Expand All @@ -44,13 +46,27 @@
* in a test are assigned to the test resource scope.
*/
public final class LeakPresenceExtension
implements BeforeAllCallback, BeforeEachCallback, AfterEachCallback, AfterAllCallback {
implements ExecutionCondition, BeforeAllCallback, BeforeEachCallback, AfterEachCallback, AfterAllCallback {

static final String LEAK_PRESENCE_DETECTION_DISABLED_PROPERTY =
"io.netty.test.leakPresenceDetection.disabled";

private static final Object SCOPE_KEY = new Object();
private static final Object PREVIOUS_SCOPE_KEY = new Object();

static {
System.setProperty("io.netty.customResourceLeakDetector", WithTransferableScope.class.getName());
if (!Boolean.getBoolean(LEAK_PRESENCE_DETECTION_DISABLED_PROPERTY)) {
System.setProperty("io.netty.customResourceLeakDetector", WithTransferableScope.class.getName());
}
}

@Override
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
if (Boolean.getBoolean(LEAK_PRESENCE_DETECTION_DISABLED_PROPERTY)) {
return ConditionEvaluationResult.disabled(
"Leak presence detection disabled by " + LEAK_PRESENCE_DETECTION_DISABLED_PROPERTY);
}
return ConditionEvaluationResult.enabled("Leak presence detection enabled");
}

@Override
Expand Down
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
Expand Up @@ -17,6 +17,7 @@

import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.platform.testkit.engine.EngineExecutionResults;
import org.junit.platform.testkit.engine.EngineTestKit;

Expand All @@ -35,6 +36,27 @@ void nestedClassLifecycleIsSupported() {
results.testEvents().succeeded().assertThatEvents().hasSize(2);
}

@Test
void explicitExtensionTestIsSkippedWhenLeakPresenceDetectionIsDisabled() {
String previous = System.getProperty(LeakPresenceExtension.LEAK_PRESENCE_DETECTION_DISABLED_PROPERTY);
System.setProperty(LeakPresenceExtension.LEAK_PRESENCE_DETECTION_DISABLED_PROPERTY, "true");
try {
EngineExecutionResults results = EngineTestKit.engine("junit-jupiter")
.selectors(selectClass(ExplicitExtensionTest.class))
.execute();

results.containerEvents().failed().assertThatEvents().isEmpty();
results.containerEvents().skipped().assertThatEvents().hasSize(1);
results.testEvents().succeeded().assertThatEvents().isEmpty();
} finally {
if (previous == null) {
System.clearProperty(LeakPresenceExtension.LEAK_PRESENCE_DETECTION_DISABLED_PROPERTY);
} else {
System.setProperty(LeakPresenceExtension.LEAK_PRESENCE_DETECTION_DISABLED_PROPERTY, previous);
}
}
}

@Test
void inheritedTestClassExecutesParentAndChildTests() {
EngineExecutionResults results = EngineTestKit.engine("junit-jupiter")
Expand Down Expand Up @@ -70,4 +92,11 @@ static class InheritedChildTest extends InheritedParentTest {
void childTest() {
}
}

@ExtendWith(LeakPresenceExtension.class)
static class ExplicitExtensionTest {
@Test
void test() {
}
}
}
Loading

Back | FazBrowse Home | New Git URL