Refactor embeddable compiler client tests:
- move from the legacy location to the project dir - move testdata from resources to the separate folder (fixes global compileTestKotlin build) - fix classpaths handling
This commit is contained in:
@@ -5,9 +5,8 @@ plugins {
|
|||||||
kotlin("jvm")
|
kotlin("jvm")
|
||||||
}
|
}
|
||||||
|
|
||||||
val testRuntimeCompilerJar by configurations.creating
|
val testCompilerClasspath by configurations.creating
|
||||||
val testStdlibJar by configurations.creating
|
val testCompilationClasspath by configurations.creating
|
||||||
val testScriptRuntimeJar by configurations.creating
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
embedded(project(":compiler:cli-common")) { isTransitive = false }
|
embedded(project(":compiler:cli-common")) { isTransitive = false }
|
||||||
@@ -22,27 +21,23 @@ dependencies {
|
|||||||
testCompile(commonDep("junit:junit"))
|
testCompile(commonDep("junit:junit"))
|
||||||
testCompile(project(":kotlin-test:kotlin-test-jvm"))
|
testCompile(project(":kotlin-test:kotlin-test-jvm"))
|
||||||
testCompile(project(":kotlin-test:kotlin-test-junit"))
|
testCompile(project(":kotlin-test:kotlin-test-junit"))
|
||||||
testRuntimeCompilerJar(project(":kotlin-compiler"))
|
testCompilerClasspath(project(":kotlin-compiler"))
|
||||||
testStdlibJar(kotlinStdlib())
|
testCompilerClasspath(project(":kotlin-scripting-compiler"))
|
||||||
testScriptRuntimeJar(project(":kotlin-script-runtime"))
|
testCompilerClasspath(project(":kotlin-daemon"))
|
||||||
|
testCompilationClasspath(kotlinStdlib())
|
||||||
|
testCompilationClasspath(project(":kotlin-script-runtime"))
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
"main" {}
|
"main" {}
|
||||||
"test" {
|
"test" { projectDefault() }
|
||||||
// TODO: move closer
|
|
||||||
java.srcDir("../../libraries/tools/kotlin-compiler-client-embeddable-test/src")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
projectTest {
|
projectTest {
|
||||||
dependsOn(":dist")
|
|
||||||
workingDir = File(rootDir, "libraries/tools/kotlin-compiler-client-embeddable-test/src")
|
|
||||||
doFirst {
|
doFirst {
|
||||||
systemProperty("kotlin.test.script.classpath", testSourceSet.output.classesDirs.joinToString(File.pathSeparator))
|
systemProperty("kotlin.test.script.classpath", testSourceSet.output.classesDirs.joinToString(File.pathSeparator))
|
||||||
systemProperty("compilerJar", testRuntimeCompilerJar.singleFile.canonicalPath)
|
systemProperty("compilerClasspath", testCompilerClasspath.asPath)
|
||||||
systemProperty("stdlibJar", testStdlibJar.singleFile.canonicalPath)
|
systemProperty("compilationClasspath", testCompilationClasspath.asPath)
|
||||||
systemProperty("scriptRuntimeJar", testScriptRuntimeJar.singleFile.canonicalPath)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-9
@@ -38,12 +38,11 @@ class CompilerClientIT {
|
|||||||
val workingDir = TemporaryFolder()
|
val workingDir = TemporaryFolder()
|
||||||
|
|
||||||
private val compilerClasspath: List<File> by lazy {
|
private val compilerClasspath: List<File> by lazy {
|
||||||
listOf(fileFromProp("compilerJar", "kotlin-compiler.jar"))
|
filesFromProp("compilerClasspath", "kotlin-compiler.jar", "kotlin-daemon.jar")
|
||||||
}
|
}
|
||||||
|
|
||||||
private val compilationClasspath: List<File> by lazy {
|
private val compilationClasspath: List<File> by lazy {
|
||||||
listOf(fileFromProp("stdlibJar", "kotlin-stdlib.jar"),
|
filesFromProp("compilationClasspath", "kotlin-stdlib.jar", "kotlin-script-runtime.jar")
|
||||||
fileFromProp("scriptRuntimeJar", "kotlin-script-runtime.jar"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val clientAliveFile by lazy {
|
private val clientAliveFile by lazy {
|
||||||
@@ -52,11 +51,11 @@ class CompilerClientIT {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun fileFromProp(propName: String, defaultPath: String) =
|
private fun filesFromProp(propName: String, vararg defaultPaths: String): List<File> =
|
||||||
File((System.getProperty(propName) ?: defaultPath)).apply {
|
(System.getProperty(propName)?.split(File.pathSeparator) ?: defaultPaths.asList()).map {
|
||||||
if (!exists())
|
File(it).takeIf(File::exists)
|
||||||
throw FileNotFoundException("cannot find $defaultPath ($this)")
|
?: throw FileNotFoundException("cannot find ($it)")
|
||||||
}
|
}
|
||||||
|
|
||||||
private val compilerService: CompileService by lazy {
|
private val compilerService: CompileService by lazy {
|
||||||
val compilerId = CompilerId.makeCompilerId(compilerClasspath)
|
val compilerId = CompilerId.makeCompilerId(compilerClasspath)
|
||||||
@@ -75,7 +74,7 @@ class CompilerClientIT {
|
|||||||
fun testSimpleScript() {
|
fun testSimpleScript() {
|
||||||
val (out, code) = runCompiler(
|
val (out, code) = runCompiler(
|
||||||
"-cp", compilationClasspath.joinToString(File.pathSeparator) { it.canonicalPath },
|
"-cp", compilationClasspath.joinToString(File.pathSeparator) { it.canonicalPath },
|
||||||
File("../src/test/resources/scripts/simpleHelloWorld.kts").canonicalPath)
|
File("testData/scripts/simpleHelloWorld.kts").canonicalPath)
|
||||||
assertEquals(0, code, "compilation failed:\n" + out + "\n")
|
assertEquals(0, code, "compilation failed:\n" + out + "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user