Replace direct usages of ideaSdk in tests with property passed from build scripts
This commit is contained in:
committed by
Vyacheslav Gerasimov
parent
eb8ef6e803
commit
b490a79d95
@@ -1,4 +1,5 @@
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
import org.jetbrains.intellij.IntelliJPluginExtension
|
||||
|
||||
apply { plugin("kotlin") }
|
||||
|
||||
@@ -127,6 +128,9 @@ sourceSets {
|
||||
projectTest {
|
||||
dependsOnTaskIfExistsRec("dist", project = rootProject)
|
||||
workingDir = rootDir
|
||||
afterEvaluate {
|
||||
systemProperty("ideaSdk.path", the<IntelliJPluginExtension>().ideaDependency.classes.canonicalPath)
|
||||
}
|
||||
}
|
||||
|
||||
testsJar {}
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.intellij.lang.annotations.Language
|
||||
import org.intellij.lang.regexp.RegExpLanguage
|
||||
import org.jetbrains.kotlin.idea.test.SdkAndMockLibraryProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import java.io.File
|
||||
|
||||
class KotlinLibInjectionTest : AbstractInjectionTest() {
|
||||
override fun setUp() {
|
||||
@@ -55,9 +55,10 @@ class KotlinLibInjectionTest : AbstractInjectionTest() {
|
||||
|
||||
|
||||
override fun getProjectDescriptor(): LightProjectDescriptor {
|
||||
val ideaSdkPath = System.getProperty("ideaSdk.path")?.takeIf { File(it).isDirectory }
|
||||
?: throw RuntimeException("Unable to get a valid path from 'ideaSdk.path' property, please point it to the Idea SDK location")
|
||||
return SdkAndMockLibraryProjectDescriptor(
|
||||
PluginTestCaseBase.getTestDataPathBase() + "/injection/lib/", false, false, false, true,
|
||||
listOf(KotlinTestUtils.getHomeDirectory() + "/ideaSDK/lib/annotations.jar")
|
||||
)
|
||||
PluginTestCaseBase.getTestDataPathBase() + "/injection/lib/", false, false, false, true,
|
||||
listOf(File(ideaSdkPath, "lib/annotations.jar").absolutePath))
|
||||
}
|
||||
}
|
||||
|
||||
+7
-2
@@ -106,9 +106,14 @@ abstract class AbstractParcelBoxTest : CodegenTestCase() {
|
||||
super.doTest(File(BASE_DIR, filePath + ".kt").absolutePath)
|
||||
}
|
||||
|
||||
private val androidPluginPath: String by lazy {
|
||||
System.getProperty("ideaSdk.androidPlugin.path")?.takeIf { File(it).isDirectory }
|
||||
?: throw RuntimeException("Unable to get a valid path from 'ideaSdk.androidPlugin.path' property, please point it to the Idea android plugin location")
|
||||
}
|
||||
|
||||
private fun getClasspathForTest(): List<File> {
|
||||
val kotlinRuntimeJar = PathUtil.kotlinPathsForIdeaPlugin.stdlibPath
|
||||
val layoutLibJars = listOf(File("ideaSDK/plugins/android/lib/layoutlib.jar"), File("ideaSDK/plugins/android/lib/layoutlib-api.jar"))
|
||||
val layoutLibJars = listOf(File(androidPluginPath, "layoutlib.jar"), File(androidPluginPath, "layoutlib-api.jar"))
|
||||
|
||||
val robolectricJars = File("dependencies/robolectric")
|
||||
.listFiles { f: File -> f.extension == "jar" }
|
||||
@@ -167,6 +172,6 @@ abstract class AbstractParcelBoxTest : CodegenTestCase() {
|
||||
override fun setupEnvironment(environment: KotlinCoreEnvironment) {
|
||||
AndroidComponentRegistrar.registerParcelExtensions(environment.project)
|
||||
addAndroidExtensionsRuntimeLibrary(environment)
|
||||
environment.updateClasspath(listOf(JvmClasspathRoot(File("ideaSDK/plugins/android/lib/layoutlib.jar"))))
|
||||
environment.updateClasspath(listOf(JvmClasspathRoot(File(androidPluginPath, "layoutlib.jar"))))
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -27,6 +27,8 @@ abstract class AbstractParcelBytecodeListingTest : AbstractAsmLikeInstructionLis
|
||||
override fun setupEnvironment(environment: KotlinCoreEnvironment) {
|
||||
AndroidComponentRegistrar.registerParcelExtensions(environment.project)
|
||||
addAndroidExtensionsRuntimeLibrary(environment)
|
||||
environment.updateClasspath(listOf(JvmClasspathRoot(File("ideaSDK/plugins/android/lib/layoutlib.jar"))))
|
||||
val androidPluginPath = System.getProperty("ideaSdk.androidPlugin.path")?.takeIf { File(it).isDirectory }
|
||||
?: throw RuntimeException("Unable to get a valid path from 'ideaSdk.androidPlugin.path' property, please point it to the Idea android plugin location")
|
||||
environment.updateClasspath(listOf(JvmClasspathRoot(File(androidPluginPath, "layoutlib.jar"))))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user