Use new kotlin.io.path API in tests
This commit is contained in:
@@ -10,14 +10,16 @@ import org.jetbrains.kotlin.cli.common.ExitCode
|
||||
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
|
||||
import org.jetbrains.kotlin.config.Services
|
||||
import java.io.File
|
||||
import kotlin.io.path.ExperimentalPathApi
|
||||
import kotlin.io.path.createTempDirectory
|
||||
|
||||
abstract class BaseJvmAbiTest : TestCase() {
|
||||
private lateinit var workingDir: File
|
||||
|
||||
@OptIn(ExperimentalPathApi::class)
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
workingDir = createTempDir(javaClass.simpleName)
|
||||
workingDir.deleteOnExit()
|
||||
workingDir = createTempDirectory(javaClass.simpleName).toFile().apply { deleteOnExit() }
|
||||
}
|
||||
|
||||
override fun tearDown() {
|
||||
|
||||
+3
-1
@@ -21,6 +21,8 @@ import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.TestJdkKind
|
||||
import org.junit.Assert
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
import kotlin.io.path.*
|
||||
import kotlin.script.experimental.annotations.KotlinScript
|
||||
import kotlin.script.experimental.api.*
|
||||
import kotlin.script.experimental.host.ScriptingHostConfiguration
|
||||
@@ -160,7 +162,7 @@ object CompileTimeFibonacciConfiguration : ScriptCompilationConfiguration(
|
||||
.mapIndexed { index, number -> "val FIB_${index + 1} = $number" }
|
||||
.joinToString("\n")
|
||||
|
||||
val file = createTempFile("CompileTimeFibonacci", ".fib.kts")
|
||||
val file = Files.createTempFile("CompileTimeFibonacci", ".fib.kts").toFile()
|
||||
.apply {
|
||||
deleteOnExit()
|
||||
writeText(sourceCode)
|
||||
|
||||
@@ -18,6 +18,7 @@ val embeddableTestRuntime by configurations.creating {
|
||||
|
||||
dependencies {
|
||||
allTestsRuntime(commonDep("junit"))
|
||||
testCompile(kotlinStdlib("jdk8"))
|
||||
testCompile(project(":kotlin-scripting-ide-services-unshaded"))
|
||||
testCompile(project(":kotlin-scripting-compiler"))
|
||||
testCompile(project(":kotlin-scripting-dependencies"))
|
||||
|
||||
+4
-2
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
|
||||
import org.jetbrains.kotlin.config.Services
|
||||
import org.jetbrains.kotlin.scripting.ide_services.test_util.*
|
||||
import java.io.File
|
||||
import kotlin.io.path.*
|
||||
import kotlin.script.experimental.api.*
|
||||
import kotlin.script.experimental.jvm.impl.KJvmCompiledScript
|
||||
import kotlin.script.experimental.jvm.jvm
|
||||
@@ -318,14 +319,15 @@ class JvmIdeServicesTest : TestCase() {
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalPathApi::class)
|
||||
companion object {
|
||||
private const val MODULE_PATH = "plugins/scripting/scripting-ide-services-test"
|
||||
private val outputJarDir = createTempDir("temp-ide-services").toPath()
|
||||
private val outputJarDir = createTempDirectory("temp-ide-services")
|
||||
|
||||
private data class CliCompilationResult(val exitCode: ExitCode, val outputJarPath: String)
|
||||
|
||||
private fun compileFile(inputKtFileName: String, outputJarName: String): CliCompilationResult {
|
||||
val jarPath = outputJarDir.resolve(outputJarName).toAbsolutePath().toString().replace('\\', '/')
|
||||
val jarPath = outputJarDir.resolve(outputJarName).toAbsolutePath().invariantSeparatorsPath
|
||||
|
||||
val compilerArgs = arrayOf(
|
||||
"$MODULE_PATH/testData/$inputKtFileName",
|
||||
|
||||
Reference in New Issue
Block a user