Fix test failure because of duplicates file templates in classpath
There're two ways for getting templates in test runtime. One is from sources resource files, the second one is from compiled jar. Remove the first entry manually. A better fix is to extract tests to separate module. This will leave only jar in the test runtime classpath.
This commit is contained in:
@@ -48,9 +48,10 @@ public class PrintingLogger extends Logger {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void debug(@Nullable Throwable t) {
|
public void debug(@Nullable Throwable t) {
|
||||||
//noinspection ConstantConditions
|
if (t != null) {
|
||||||
t.printStackTrace(out);
|
t.printStackTrace(out);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void debug(@NonNls String message, @Nullable Throwable t) {
|
public void debug(@NonNls String message, @Nullable Throwable t) {
|
||||||
|
|||||||
@@ -78,6 +78,18 @@ testsJar()
|
|||||||
projectTest(parallel = true) {
|
projectTest(parallel = true) {
|
||||||
workingDir = rootDir
|
workingDir = rootDir
|
||||||
useAndroidSdk()
|
useAndroidSdk()
|
||||||
|
|
||||||
|
doFirst {
|
||||||
|
val mainResourceDirPath = File(project.buildDir, "resources/main").absolutePath
|
||||||
|
sourceSets["test"].runtimeClasspath = sourceSets["test"].runtimeClasspath.filter { file ->
|
||||||
|
if (!file.absolutePath.contains(mainResourceDirPath)) {
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
println("Remove `${file.path}` from the test runtime classpath")
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
configureFormInstrumentation()
|
configureFormInstrumentation()
|
||||||
|
|||||||
+1
-17
@@ -45,7 +45,7 @@ import com.intellij.util.containers.ContainerUtil
|
|||||||
import com.intellij.util.containers.ContainerUtilRt
|
import com.intellij.util.containers.ContainerUtilRt
|
||||||
import junit.framework.TestCase
|
import junit.framework.TestCase
|
||||||
import org.jetbrains.kotlin.idea.codeInsight.gradle.GradleImportingTestCase
|
import org.jetbrains.kotlin.idea.codeInsight.gradle.GradleImportingTestCase
|
||||||
import org.jetbrains.kotlin.idea.configuration.KotlinGradleAbstractMultiplatformModuleBuilder
|
import org.jetbrains.kotlin.idea.configuration.*
|
||||||
import org.jetbrains.kotlin.utils.PrintingLogger
|
import org.jetbrains.kotlin.utils.PrintingLogger
|
||||||
import org.jetbrains.plugins.gradle.service.execution.GradleExecutionHelper
|
import org.jetbrains.plugins.gradle.service.execution.GradleExecutionHelper
|
||||||
import org.jetbrains.plugins.gradle.settings.DistributionType
|
import org.jetbrains.plugins.gradle.settings.DistributionType
|
||||||
@@ -85,19 +85,6 @@ abstract class AbstractGradleMultiplatformWizardTest : ProjectWizardTestCase<Abs
|
|||||||
performImport: Boolean = true,
|
performImport: Boolean = true,
|
||||||
useQualifiedModuleNames: Boolean = false
|
useQualifiedModuleNames: Boolean = false
|
||||||
): Project {
|
): Project {
|
||||||
// TODO: check whether it's necessary to have templates in sources
|
|
||||||
// Temporary workaround for duplicated bundled template
|
|
||||||
class PrintingFactory : Logger.Factory {
|
|
||||||
override fun getLoggerInstance(category: String): Logger {
|
|
||||||
return PrintingLogger(System.out)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val oldFactory = Logger.getFactory().javaClass
|
|
||||||
|
|
||||||
try {
|
|
||||||
Logger.setFactory(PrintingFactory::class.java)
|
|
||||||
|
|
||||||
val project = createProject { step ->
|
val project = createProject { step ->
|
||||||
if (step is ProjectTypeStep) {
|
if (step is ProjectTypeStep) {
|
||||||
TestCase.assertTrue(step.setSelectedTemplate("Kotlin", builder.presentableName))
|
TestCase.assertTrue(step.setSelectedTemplate("Kotlin", builder.presentableName))
|
||||||
@@ -142,9 +129,6 @@ abstract class AbstractGradleMultiplatformWizardTest : ProjectWizardTestCase<Abs
|
|||||||
doTestProject(project, *testClassNames)
|
doTestProject(project, *testClassNames)
|
||||||
}
|
}
|
||||||
return project
|
return project
|
||||||
} finally {
|
|
||||||
Logger.setFactory(oldFactory)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun File.assertNoEmptyChildren() {
|
private fun File.assertNoEmptyChildren() {
|
||||||
|
|||||||
Reference in New Issue
Block a user