mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-03-10 08:31:29 +00:00
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")
|
||||
}
|
||||
|
||||
val testRuntimeCompilerJar by configurations.creating
|
||||
val testStdlibJar by configurations.creating
|
||||
val testScriptRuntimeJar by configurations.creating
|
||||
val testCompilerClasspath by configurations.creating
|
||||
val testCompilationClasspath by configurations.creating
|
||||
|
||||
dependencies {
|
||||
embedded(project(":compiler:cli-common")) { isTransitive = false }
|
||||
@@ -22,27 +21,23 @@ dependencies {
|
||||
testCompile(commonDep("junit:junit"))
|
||||
testCompile(project(":kotlin-test:kotlin-test-jvm"))
|
||||
testCompile(project(":kotlin-test:kotlin-test-junit"))
|
||||
testRuntimeCompilerJar(project(":kotlin-compiler"))
|
||||
testStdlibJar(kotlinStdlib())
|
||||
testScriptRuntimeJar(project(":kotlin-script-runtime"))
|
||||
testCompilerClasspath(project(":kotlin-compiler"))
|
||||
testCompilerClasspath(project(":kotlin-scripting-compiler"))
|
||||
testCompilerClasspath(project(":kotlin-daemon"))
|
||||
testCompilationClasspath(kotlinStdlib())
|
||||
testCompilationClasspath(project(":kotlin-script-runtime"))
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
"main" {}
|
||||
"test" {
|
||||
// TODO: move closer
|
||||
java.srcDir("../../libraries/tools/kotlin-compiler-client-embeddable-test/src")
|
||||
}
|
||||
"test" { projectDefault() }
|
||||
}
|
||||
|
||||
projectTest {
|
||||
dependsOn(":dist")
|
||||
workingDir = File(rootDir, "libraries/tools/kotlin-compiler-client-embeddable-test/src")
|
||||
doFirst {
|
||||
systemProperty("kotlin.test.script.classpath", testSourceSet.output.classesDirs.joinToString(File.pathSeparator))
|
||||
systemProperty("compilerJar", testRuntimeCompilerJar.singleFile.canonicalPath)
|
||||
systemProperty("stdlibJar", testStdlibJar.singleFile.canonicalPath)
|
||||
systemProperty("scriptRuntimeJar", testScriptRuntimeJar.singleFile.canonicalPath)
|
||||
systemProperty("compilerClasspath", testCompilerClasspath.asPath)
|
||||
systemProperty("compilationClasspath", testCompilationClasspath.asPath)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,12 +38,11 @@ class CompilerClientIT {
|
||||
val workingDir = TemporaryFolder()
|
||||
|
||||
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 {
|
||||
listOf(fileFromProp("stdlibJar", "kotlin-stdlib.jar"),
|
||||
fileFromProp("scriptRuntimeJar", "kotlin-script-runtime.jar"))
|
||||
filesFromProp("compilationClasspath", "kotlin-stdlib.jar", "kotlin-script-runtime.jar")
|
||||
}
|
||||
|
||||
private val clientAliveFile by lazy {
|
||||
@@ -52,11 +51,11 @@ class CompilerClientIT {
|
||||
}
|
||||
}
|
||||
|
||||
private fun fileFromProp(propName: String, defaultPath: String) =
|
||||
File((System.getProperty(propName) ?: defaultPath)).apply {
|
||||
if (!exists())
|
||||
throw FileNotFoundException("cannot find $defaultPath ($this)")
|
||||
}
|
||||
private fun filesFromProp(propName: String, vararg defaultPaths: String): List<File> =
|
||||
(System.getProperty(propName)?.split(File.pathSeparator) ?: defaultPaths.asList()).map {
|
||||
File(it).takeIf(File::exists)
|
||||
?: throw FileNotFoundException("cannot find ($it)")
|
||||
}
|
||||
|
||||
private val compilerService: CompileService by lazy {
|
||||
val compilerId = CompilerId.makeCompilerId(compilerClasspath)
|
||||
@@ -75,7 +74,7 @@ class CompilerClientIT {
|
||||
fun testSimpleScript() {
|
||||
val (out, code) = runCompiler(
|
||||
"-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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user