Force-set path to exact project for MPP run configurations
Otherwise, path will be set to the root project. Given that we provide task names in relative form rather than absolute, that will lead to launching this task in all subprojects (e.g. task 'jvmTest'). This might be a huge issue, because when we create run configuration for specific test method/class, we pass test filter as well. This test filter will execute in all projects with matched test tasks, so if some other subproject has similarly-named test task, but doesn't have a suitable tests for that filter, the whole build will fail. Note that the ideal fix would involve using fully-qualified task names: the current approach might lead to isses in advanced scenarious (e.g. when user selects several test files from different modules -- then, we won't be able to find one exact project path for the whole test run) ^KT-35038 Fixed
This commit is contained in:
+2
@@ -11,6 +11,7 @@ import com.intellij.execution.actions.ConfigurationFromContext
|
||||
import com.intellij.execution.configurations.ConfigurationFactory
|
||||
import com.intellij.execution.junit.InheritorChooser
|
||||
import com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.util.Ref
|
||||
import com.intellij.psi.PsiClass
|
||||
@@ -87,6 +88,7 @@ abstract class AbstractKotlinMultiplatformTestClassGradleConfigurationProducer :
|
||||
LOG.warn("Cannot apply class test configuration, uses raw run configuration")
|
||||
performRunnable.run()
|
||||
}
|
||||
settings.externalProjectPath = ExternalSystemApiUtil.getExternalProjectPath(context.module)
|
||||
configuration.name = classes.joinToString("|") { it.name ?: "<error>" }
|
||||
performRunnable.run()
|
||||
}
|
||||
|
||||
+3
@@ -11,6 +11,7 @@ import com.intellij.execution.actions.ConfigurationFromContext
|
||||
import com.intellij.execution.configurations.ConfigurationFactory
|
||||
import com.intellij.execution.junit.InheritorChooser
|
||||
import com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.util.Ref
|
||||
import com.intellij.psi.PsiClass
|
||||
@@ -84,6 +85,8 @@ abstract class AbstractKotlinMultiplatformTestMethodGradleConfigurationProducer
|
||||
createTestFilterFrom(context.location, it, psiMethod, true)
|
||||
}
|
||||
|
||||
settings.externalProjectPath = ExternalSystemApiUtil.getExternalProjectPath(context.module)
|
||||
|
||||
if (result) {
|
||||
configuration.name = (if (classes.size == 1) classes[0].name!! + "." else "") + psiMethod.name
|
||||
performRunnable.run()
|
||||
|
||||
+2
-2
@@ -4,9 +4,9 @@ package foo
|
||||
|
||||
import org.junit.Test
|
||||
|
||||
class <lineMarker descr="Run Test" project="", settings="cleanJvmTest jvmTest --tests \"foo.SubprojectTest\"">SubprojectTest</lineMarker> {
|
||||
class <lineMarker descr="Run Test" project="subproject", settings="cleanJvmTest jvmTest --tests \"foo.SubprojectTest\"">SubprojectTest</lineMarker> {
|
||||
@Test
|
||||
fun <lineMarker descr="Run Test" project="", settings="cleanJvmTest jvmTest --tests \"foo.SubprojectTest.otherTest\"">otherTest</lineMarker>() {
|
||||
fun <lineMarker descr="Run Test" project="subproject", settings="cleanJvmTest jvmTest --tests \"foo.SubprojectTest.otherTest\"">otherTest</lineMarker>() {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user