From 8287e448d1ca0bfcf40b6d6a4e5175a1046f91d7 Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Mon, 8 Apr 2019 21:23:22 +0200 Subject: [PATCH] Support parallel execution of IDEA tests --- .../kotlin/test/JUnit3RunnerWithInners.java | 5 +++++ .../kotlin/test/KotlinTestUtils.java | 20 +++++++++++++++++++ idea/build.gradle.kts | 4 ++++ 3 files changed, 29 insertions(+) diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/JUnit3RunnerWithInners.java b/compiler/tests-common/tests/org/jetbrains/kotlin/test/JUnit3RunnerWithInners.java index c296274be27..c66c1dcc312 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/JUnit3RunnerWithInners.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/JUnit3RunnerWithInners.java @@ -31,6 +31,11 @@ import java.lang.reflect.Modifier; * Works differently for Gradle and JPS. Default is Gradle for now. */ public class JUnit3RunnerWithInners extends Runner implements Filterable, Sortable { + + static { + KotlinTestUtils.setIdeaSystemPathProperties(); + } + private final Runner delegateRunner; public JUnit3RunnerWithInners(Class klass) { diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java index 3cd789e1156..20bcf63aba0 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java @@ -90,6 +90,8 @@ import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; +import static com.intellij.openapi.application.PathManager.PROPERTY_CONFIG_PATH; +import static com.intellij.openapi.application.PathManager.PROPERTY_SYSTEM_PATH; import static org.jetbrains.kotlin.test.InTextDirectivesUtils.*; public class KotlinTestUtils { @@ -112,6 +114,19 @@ public class KotlinTestUtils { private static final List filesToDelete = new ArrayList<>(); + // It's important that this is not created per test, but rather per process. + public static final String IDEA_SYSTEM_PATH; + + static { + try { + IDEA_SYSTEM_PATH = tmpDirForReusableLibrary("idea-system").getPath(); + } + catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** * Syntax: * @@ -1294,4 +1309,9 @@ public class KotlinTestUtils { // Several extension if name contains another dot return name.indexOf('.', firstDotIndex + 1) != -1; } + + public static void setIdeaSystemPathProperties() { + System.setProperty(PROPERTY_SYSTEM_PATH, IDEA_SYSTEM_PATH); + System.setProperty(PROPERTY_CONFIG_PATH, IDEA_SYSTEM_PATH + "/config"); + } } diff --git a/idea/build.gradle.kts b/idea/build.gradle.kts index 009b57560cb..d765a0be7e1 100644 --- a/idea/build.gradle.kts +++ b/idea/build.gradle.kts @@ -1,3 +1,7 @@ +tasks.withType { + maxParallelForks = Math.max(Runtime.getRuntime().availableProcessors() / 2, 1) +} + plugins { kotlin("jvm") id("jps-compatible")