[test framework] IJI-1588 Fix filter out non-performance classes in performance-only runs

GitOrigin-RevId: 807a28b0586034a14fce44d819cfcd7118215dc8
This commit is contained in:
Vladislav Rassokhin
2024-04-11 12:12:59 +00:00
committed by intellij-monorepo-bot
parent d8d9789887
commit 6ac4c11b22
2 changed files with 14 additions and 4 deletions
@@ -771,7 +771,7 @@ internal class TestingTasksImpl(private val context: CompilationContext, private
fun runOneClass(testClassName: String) {
val exitCode = blockAndSpan("running test class '$testClassName'") {
runJUnit5Engine(
systemProperties = systemProperties + ("idea.performance.tests.discovery.filter" to "true"),
systemProperties = systemProperties,
jvmArgs = jvmArgs,
envVariables = envVariables,
bootstrapClasspath = bootstrapClasspath,
@@ -806,7 +806,7 @@ internal class TestingTasksImpl(private val context: CompilationContext, private
val exitCode = blockAndSpan("running tests in package '$packageName'") {
runJUnit5Engine(
systemProperties = systemProperties + ("idea.performance.tests.discovery.filter" to "true"),
systemProperties = systemProperties,
jvmArgs = jvmArgs,
envVariables = envVariables,
bootstrapClasspath = bootstrapClasspath,
@@ -62,8 +62,13 @@ public final class JUnit5TeamCityRunnerForTestAllSuite {
else {
selectors = Collections.singletonList(DiscoverySelectors.selectMethod(args[0], args[1]));
}
if (Boolean.getBoolean("idea.performance.tests.discovery.filter")) {
// Add filter
// isIncludingPerformanceTestsRun() || isPerformanceTestsRun() && isPerformanceTest(test) -> add test
// otherwise -> skip test
if (Boolean.getBoolean("idea.include.performance.tests")) {
// no filter
}
else if (Boolean.getBoolean("idea.performance.tests")) {
// Add filter for 'isPerformanceTest'
filters.add(createPerformancePostDiscoveryFilter(classLoader));
}
LauncherDiscoveryRequest discoveryRequest = LauncherDiscoveryRequestBuilder.request()
@@ -93,6 +98,11 @@ public final class JUnit5TeamCityRunnerForTestAllSuite {
.findStatic(Class.forName("com.intellij.testFramework.TestFrameworkUtil", true, classLoader),
"isPerformanceTest", MethodType.methodType(boolean.class, String.class, String.class));
return new PostDiscoveryFilter() {
@Override
public String toString() {
return "PerformanceOnlyTestsPostDiscoveryFilter";
}
private FilterResult isIncluded(String className, String methodName) {
try {
if ((boolean)method.invokeExact(methodName, className)) {