Shorten temp paths used in tests
#KT-32490 fixed
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
package org.jetbrains.kotlin.daemon
|
package org.jetbrains.kotlin.daemon
|
||||||
|
|
||||||
import com.intellij.openapi.util.io.FileUtil
|
import com.intellij.openapi.util.io.FileUtil
|
||||||
|
import com.intellij.openapi.util.io.FileUtilRt
|
||||||
import junit.framework.TestCase
|
import junit.framework.TestCase
|
||||||
import org.jetbrains.kotlin.cli.AbstractCliTest
|
import org.jetbrains.kotlin.cli.AbstractCliTest
|
||||||
import org.jetbrains.kotlin.cli.common.messages.MessageRenderer
|
import org.jetbrains.kotlin.cli.common.messages.MessageRenderer
|
||||||
@@ -67,6 +68,12 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
|
|||||||
CompilerId.makeCompilerId(compilerWithScriptingClassPath)
|
CompilerId.makeCompilerId(compilerWithScriptingClassPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun shouldContainTempFiles(): Boolean = true
|
||||||
|
|
||||||
|
// Using tmpDir from TestCaseWithTmpdir leads to the file paths with >255 chars (see e.g. #KT-32490), while KtUsefulTestCase already
|
||||||
|
// setups a separate temp dir for each tests, if shouldContainTempFiles() returns true. Therefore current temp dir is used directly
|
||||||
|
val testTempDir = File(FileUtilRt.getTempDirectory())
|
||||||
|
|
||||||
private fun compileOnDaemon(clientAliveFile: File, compilerId: CompilerId, daemonJVMOptions: DaemonJVMOptions, daemonOptions: DaemonOptions, vararg args: String): CompilerResults {
|
private fun compileOnDaemon(clientAliveFile: File, compilerId: CompilerId, daemonJVMOptions: DaemonJVMOptions, daemonOptions: DaemonOptions, vararg args: String): CompilerResults {
|
||||||
val daemon = KotlinCompilerClient.connectToCompileService(compilerId, clientAliveFile, daemonJVMOptions, daemonOptions, DaemonReportingTargets(out = System.err), autostart = true)
|
val daemon = KotlinCompilerClient.connectToCompileService(compilerId, clientAliveFile, daemonJVMOptions, daemonOptions, DaemonReportingTargets(out = System.err), autostart = true)
|
||||||
assertNotNull("failed to connect daemon", daemon)
|
assertNotNull("failed to connect daemon", daemon)
|
||||||
@@ -92,7 +99,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
|
|||||||
private fun run(logName: String, vararg args: String): Int = runJava(getTestBaseDir(), logName, *args)
|
private fun run(logName: String, vararg args: String): Int = runJava(getTestBaseDir(), logName, *args)
|
||||||
|
|
||||||
fun makeTestDaemonOptions(testName: String, shutdownDelay: Int = 5) =
|
fun makeTestDaemonOptions(testName: String, shutdownDelay: Int = 5) =
|
||||||
DaemonOptions(runFilesPath = File(tmpdir, testName).absolutePath,
|
DaemonOptions(runFilesPath = File(testTempDir, testName).absolutePath,
|
||||||
shutdownDelayMilliseconds = shutdownDelay.toLong(),
|
shutdownDelayMilliseconds = shutdownDelay.toLong(),
|
||||||
verbose = true,
|
verbose = true,
|
||||||
reportPerf = true)
|
reportPerf = true)
|
||||||
@@ -121,7 +128,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
|
|||||||
var daemonShotDown = false
|
var daemonShotDown = false
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val jar = tmpdir.absolutePath + File.separator + "hello.jar"
|
val jar = testTempDir.absolutePath + File.separator + "hello.jar"
|
||||||
runDaemonCompilerTwice(flagFile, compilerId, daemonJVMOptions, daemonOptions,
|
runDaemonCompilerTwice(flagFile, compilerId, daemonJVMOptions, daemonOptions,
|
||||||
"-include-runtime", File(getTestBaseDir(), "hello.kt").absolutePath, "-d", jar)
|
"-include-runtime", File(getTestBaseDir(), "hello.kt").absolutePath, "-d", jar)
|
||||||
|
|
||||||
@@ -206,14 +213,14 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
|
|||||||
|
|
||||||
assertTrue(logFile1.length() == 0L && logFile2.length() == 0L)
|
assertTrue(logFile1.length() == 0L && logFile2.length() == 0L)
|
||||||
|
|
||||||
val jar1 = tmpdir.absolutePath + File.separator + "hello1.jar"
|
val jar1 = testTempDir.absolutePath + File.separator + "hello1.jar"
|
||||||
val res1 = compileOnDaemon(flagFile, compilerId, daemonJVMOptions1, daemonOptions, "-include-runtime", File(getHelloAppBaseDir(), "hello.kt").absolutePath, "-d", jar1)
|
val res1 = compileOnDaemon(flagFile, compilerId, daemonJVMOptions1, daemonOptions, "-include-runtime", File(getHelloAppBaseDir(), "hello.kt").absolutePath, "-d", jar1)
|
||||||
assertEquals("first compilation failed:\n${res1.out}", 0, res1.resultCode)
|
assertEquals("first compilation failed:\n${res1.out}", 0, res1.resultCode)
|
||||||
|
|
||||||
logFile1.assertLogContainsSequence("Starting compilation with args: ")
|
logFile1.assertLogContainsSequence("Starting compilation with args: ")
|
||||||
assertEquals("expecting '${logFile2.absolutePath}' to be empty", 0L, logFile2.length())
|
assertEquals("expecting '${logFile2.absolutePath}' to be empty", 0L, logFile2.length())
|
||||||
|
|
||||||
val jar2 = tmpdir.absolutePath + File.separator + "hello2.jar"
|
val jar2 = testTempDir.absolutePath + File.separator + "hello2.jar"
|
||||||
val res2 = compileOnDaemon(flagFile, compilerId2, daemonJVMOptions2, daemonOptions, "-include-runtime", File(getHelloAppBaseDir(), "hello.kt").absolutePath, "-d", jar2)
|
val res2 = compileOnDaemon(flagFile, compilerId2, daemonJVMOptions2, daemonOptions, "-include-runtime", File(getHelloAppBaseDir(), "hello.kt").absolutePath, "-d", jar2)
|
||||||
assertEquals("second compilation failed:\n${res2.out}", 0, res1.resultCode)
|
assertEquals("second compilation failed:\n${res2.out}", 0, res1.resultCode)
|
||||||
|
|
||||||
@@ -233,7 +240,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
|
|||||||
|
|
||||||
fun testDaemonRunError() {
|
fun testDaemonRunError() {
|
||||||
withFlagFile(getTestName(true), ".alive") { flagFile ->
|
withFlagFile(getTestName(true), ".alive") { flagFile ->
|
||||||
val daemonOptions = DaemonOptions(shutdownDelayMilliseconds = 1, verbose = true, runFilesPath = File(tmpdir, getTestName(true)).absolutePath)
|
val daemonOptions = DaemonOptions(shutdownDelayMilliseconds = 1, verbose = true, runFilesPath = File(testTempDir, getTestName(true)).absolutePath)
|
||||||
|
|
||||||
val daemonJVMOptions = configureDaemonJVMOptions("-abracadabra", inheritMemoryLimits = false, inheritOtherJvmOptions = false, inheritAdditionalProperties = false)
|
val daemonJVMOptions = configureDaemonJVMOptions("-abracadabra", inheritMemoryLimits = false, inheritOtherJvmOptions = false, inheritAdditionalProperties = false)
|
||||||
|
|
||||||
@@ -251,7 +258,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
|
|||||||
// TODO: find out how to reliably cause the retry
|
// TODO: find out how to reliably cause the retry
|
||||||
fun ignore_testDaemonStartRetry() {
|
fun ignore_testDaemonStartRetry() {
|
||||||
withFlagFile(getTestName(true), ".alive") { flagFile ->
|
withFlagFile(getTestName(true), ".alive") { flagFile ->
|
||||||
val daemonOptions = DaemonOptions(shutdownDelayMilliseconds = 1, verbose = true, runFilesPath = File(tmpdir, getTestName(true)).absolutePath)
|
val daemonOptions = DaemonOptions(shutdownDelayMilliseconds = 1, verbose = true, runFilesPath = File(testTempDir, getTestName(true)).absolutePath)
|
||||||
|
|
||||||
val daemonJVMOptions = configureDaemonJVMOptions(inheritMemoryLimits = false, inheritOtherJvmOptions = false, inheritAdditionalProperties = false)
|
val daemonJVMOptions = configureDaemonJVMOptions(inheritMemoryLimits = false, inheritOtherJvmOptions = false, inheritAdditionalProperties = false)
|
||||||
|
|
||||||
@@ -271,7 +278,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
|
|||||||
|
|
||||||
fun testDaemonAutoshutdownOnUnused() {
|
fun testDaemonAutoshutdownOnUnused() {
|
||||||
withFlagFile(getTestName(true), ".alive") { flagFile ->
|
withFlagFile(getTestName(true), ".alive") { flagFile ->
|
||||||
val daemonOptions = DaemonOptions(autoshutdownUnusedSeconds = 1, shutdownDelayMilliseconds = 1, runFilesPath = File(tmpdir, getTestName(true)).absolutePath)
|
val daemonOptions = DaemonOptions(autoshutdownUnusedSeconds = 1, shutdownDelayMilliseconds = 1, runFilesPath = File(testTempDir, getTestName(true)).absolutePath)
|
||||||
|
|
||||||
withLogFile("kotlin-daemon-test") { logFile ->
|
withLogFile("kotlin-daemon-test") { logFile ->
|
||||||
val daemonJVMOptions = makeTestDaemonJvmOptions(logFile)
|
val daemonJVMOptions = makeTestDaemonJvmOptions(logFile)
|
||||||
@@ -295,7 +302,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
|
|||||||
|
|
||||||
fun testDaemonAutoshutdownOnIdle() {
|
fun testDaemonAutoshutdownOnIdle() {
|
||||||
withFlagFile(getTestName(true), ".alive") { flagFile ->
|
withFlagFile(getTestName(true), ".alive") { flagFile ->
|
||||||
val daemonOptions = DaemonOptions(autoshutdownIdleSeconds = 1, shutdownDelayMilliseconds = 1, runFilesPath = File(tmpdir, getTestName(true)).absolutePath)
|
val daemonOptions = DaemonOptions(autoshutdownIdleSeconds = 1, shutdownDelayMilliseconds = 1, runFilesPath = File(testTempDir, getTestName(true)).absolutePath)
|
||||||
|
|
||||||
withLogFile("kotlin-daemon-test") { logFile ->
|
withLogFile("kotlin-daemon-test") { logFile ->
|
||||||
val daemonJVMOptions = makeTestDaemonJvmOptions(logFile)
|
val daemonJVMOptions = makeTestDaemonJvmOptions(logFile)
|
||||||
@@ -303,7 +310,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
|
|||||||
val daemon = KotlinCompilerClient.connectToCompileService(compilerId, flagFile, daemonJVMOptions, daemonOptions, DaemonReportingTargets(out = System.err), autostart = true)
|
val daemon = KotlinCompilerClient.connectToCompileService(compilerId, flagFile, daemonJVMOptions, daemonOptions, DaemonReportingTargets(out = System.err), autostart = true)
|
||||||
assertNotNull("failed to connect daemon", daemon)
|
assertNotNull("failed to connect daemon", daemon)
|
||||||
daemon?.registerClient(flagFile.absolutePath)
|
daemon?.registerClient(flagFile.absolutePath)
|
||||||
val jar = tmpdir.absolutePath + File.separator + "hello1.jar"
|
val jar = testTempDir.absolutePath + File.separator + "hello1.jar"
|
||||||
val strm = ByteArrayOutputStream()
|
val strm = ByteArrayOutputStream()
|
||||||
val code = KotlinCompilerClient.compile(daemon!!, CompileService.NO_SESSION, CompileService.TargetPlatform.JVM,
|
val code = KotlinCompilerClient.compile(daemon!!, CompileService.NO_SESSION, CompileService.TargetPlatform.JVM,
|
||||||
arrayOf("-include-runtime", File(getHelloAppBaseDir(), "hello.kt").absolutePath, "-d", jar),
|
arrayOf("-include-runtime", File(getHelloAppBaseDir(), "hello.kt").absolutePath, "-d", jar),
|
||||||
@@ -327,7 +334,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
|
|||||||
|
|
||||||
fun testDaemonGracefulShutdown() {
|
fun testDaemonGracefulShutdown() {
|
||||||
withFlagFile(getTestName(true), ".alive") { flagFile ->
|
withFlagFile(getTestName(true), ".alive") { flagFile ->
|
||||||
val daemonOptions = DaemonOptions(autoshutdownIdleSeconds = 1, shutdownDelayMilliseconds = 1, forceShutdownTimeoutMilliseconds = 60000, runFilesPath = File(tmpdir, getTestName(true)).absolutePath)
|
val daemonOptions = DaemonOptions(autoshutdownIdleSeconds = 1, shutdownDelayMilliseconds = 1, forceShutdownTimeoutMilliseconds = 60000, runFilesPath = File(testTempDir, getTestName(true)).absolutePath)
|
||||||
|
|
||||||
withLogFile("kotlin-daemon-test") { logFile ->
|
withLogFile("kotlin-daemon-test") { logFile ->
|
||||||
val daemonJVMOptions = makeTestDaemonJvmOptions(logFile)
|
val daemonJVMOptions = makeTestDaemonJvmOptions(logFile)
|
||||||
@@ -360,7 +367,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun testDaemonExitsOnClientFlagDeletedWithActiveSessions() {
|
fun testDaemonExitsOnClientFlagDeletedWithActiveSessions() {
|
||||||
val daemonOptions = DaemonOptions(autoshutdownIdleSeconds = 1000, shutdownDelayMilliseconds = 1, runFilesPath = File(tmpdir, getTestName(true)).absolutePath)
|
val daemonOptions = DaemonOptions(autoshutdownIdleSeconds = 1000, shutdownDelayMilliseconds = 1, runFilesPath = File(testTempDir, getTestName(true)).absolutePath)
|
||||||
val clientFlag = FileUtil.createTempFile(getTestName(true), "-client.alive")
|
val clientFlag = FileUtil.createTempFile(getTestName(true), "-client.alive")
|
||||||
val sessionFlag = FileUtil.createTempFile(getTestName(true), "-session.alive")
|
val sessionFlag = FileUtil.createTempFile(getTestName(true), "-session.alive")
|
||||||
try {
|
try {
|
||||||
@@ -386,7 +393,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun testDaemonExitsOnClientFlagDeletedWithAllSessionsReleased() {
|
fun testDaemonExitsOnClientFlagDeletedWithAllSessionsReleased() {
|
||||||
val daemonOptions = DaemonOptions(autoshutdownIdleSeconds = 1000, shutdownDelayMilliseconds = 1, runFilesPath = File(tmpdir, getTestName(true)).absolutePath)
|
val daemonOptions = DaemonOptions(autoshutdownIdleSeconds = 1000, shutdownDelayMilliseconds = 1, runFilesPath = File(testTempDir, getTestName(true)).absolutePath)
|
||||||
val clientFlag = FileUtil.createTempFile(getTestName(true), "-client.alive")
|
val clientFlag = FileUtil.createTempFile(getTestName(true), "-client.alive")
|
||||||
val sessionFlag = FileUtil.createTempFile(getTestName(true), "-session.alive")
|
val sessionFlag = FileUtil.createTempFile(getTestName(true), "-session.alive")
|
||||||
try {
|
try {
|
||||||
@@ -415,7 +422,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun testDaemonCancelShutdownOnANewClient() {
|
fun testDaemonCancelShutdownOnANewClient() {
|
||||||
val daemonOptions = DaemonOptions(autoshutdownIdleSeconds = 1000, shutdownDelayMilliseconds = 3000, runFilesPath = File(tmpdir, getTestName(true)).absolutePath)
|
val daemonOptions = DaemonOptions(autoshutdownIdleSeconds = 1000, shutdownDelayMilliseconds = 3000, runFilesPath = File(testTempDir, getTestName(true)).absolutePath)
|
||||||
val clientFlag = FileUtil.createTempFile(getTestName(true), "-client.alive")
|
val clientFlag = FileUtil.createTempFile(getTestName(true), "-client.alive")
|
||||||
val clientFlag2 = FileUtil.createTempFile(getTestName(true), "-client.alive")
|
val clientFlag2 = FileUtil.createTempFile(getTestName(true), "-client.alive")
|
||||||
try {
|
try {
|
||||||
@@ -460,7 +467,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
|
|||||||
fun testDaemonExecutionViaIntermediateProcess() {
|
fun testDaemonExecutionViaIntermediateProcess() {
|
||||||
val clientAliveFile = FileUtil.createTempFile("kotlin-daemon-transitive-run-test", ".run")
|
val clientAliveFile = FileUtil.createTempFile("kotlin-daemon-transitive-run-test", ".run")
|
||||||
val daemonOptions = makeTestDaemonOptions(getTestName(true))
|
val daemonOptions = makeTestDaemonOptions(getTestName(true))
|
||||||
val jar = tmpdir.absolutePath + File.separator + "hello.jar"
|
val jar = testTempDir.absolutePath + File.separator + "hello.jar"
|
||||||
val args = listOf(
|
val args = listOf(
|
||||||
File(File(System.getProperty("java.home"), "bin"), "java").absolutePath,
|
File(File(System.getProperty("java.home"), "bin"), "java").absolutePath,
|
||||||
"-Xmx256m",
|
"-Xmx256m",
|
||||||
@@ -517,7 +524,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
|
|||||||
|
|
||||||
fun runCompile(threadNo: Int) =
|
fun runCompile(threadNo: Int) =
|
||||||
thread {
|
thread {
|
||||||
val jar = tmpdir.absolutePath + File.separator + "hello.$threadNo.jar"
|
val jar = testTempDir.absolutePath + File.separator + "hello.$threadNo.jar"
|
||||||
val res = KotlinCompilerClient.compile(
|
val res = KotlinCompilerClient.compile(
|
||||||
daemon!!,
|
daemon!!,
|
||||||
CompileService.NO_SESSION,
|
CompileService.NO_SESSION,
|
||||||
@@ -577,7 +584,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
|
|||||||
ParallelStartParams.connectionFailedErr
|
ParallelStartParams.connectionFailedErr
|
||||||
}
|
}
|
||||||
ParallelStartParams.performCompilation -> {
|
ParallelStartParams.performCompilation -> {
|
||||||
val jar = tmpdir.absolutePath + File.separator + "hello.$threadNo.jar"
|
val jar = testTempDir.absolutePath + File.separator + "hello.$threadNo.jar"
|
||||||
KotlinCompilerClient.compile(
|
KotlinCompilerClient.compile(
|
||||||
compileServiceSession.compileService,
|
compileServiceSession.compileService,
|
||||||
compileServiceSession.sessionId,
|
compileServiceSession.sessionId,
|
||||||
@@ -688,9 +695,9 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
|
|||||||
assertNotNull("failed to connect daemon", daemon)
|
assertNotNull("failed to connect daemon", daemon)
|
||||||
daemon?.registerClient(flagFile.absolutePath)
|
daemon?.registerClient(flagFile.absolutePath)
|
||||||
|
|
||||||
val file = File(tmpdir, "largeKotlinFile.kt")
|
val file = File(testTempDir, "largeKotlinFile.kt")
|
||||||
file.writeText(generateLargeKotlinFile(10))
|
file.writeText(generateLargeKotlinFile(10))
|
||||||
val jar = File(tmpdir, "largeKotlinFile.jar").absolutePath
|
val jar = File(testTempDir, "largeKotlinFile.jar").absolutePath
|
||||||
|
|
||||||
var callbackServices: CompilerCallbackServicesFacadeServer? = null
|
var callbackServices: CompilerCallbackServicesFacadeServer? = null
|
||||||
callbackServices = CompilerCallbackServicesFacadeServer(compilationCanceledStatus = object : CompilationCanceledStatus {
|
callbackServices = CompilerCallbackServicesFacadeServer(compilationCanceledStatus = object : CompilationCanceledStatus {
|
||||||
@@ -804,7 +811,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
|
|||||||
|
|
||||||
fun testDaemonReplAutoshutdownOnIdle() {
|
fun testDaemonReplAutoshutdownOnIdle() {
|
||||||
withFlagFile(getTestName(true), ".alive") { flagFile ->
|
withFlagFile(getTestName(true), ".alive") { flagFile ->
|
||||||
val daemonOptions = DaemonOptions(autoshutdownIdleSeconds = 1, autoshutdownUnusedSeconds = 1, shutdownDelayMilliseconds = 1, runFilesPath = File(tmpdir, getTestName(true)).absolutePath)
|
val daemonOptions = DaemonOptions(autoshutdownIdleSeconds = 1, autoshutdownUnusedSeconds = 1, shutdownDelayMilliseconds = 1, runFilesPath = File(testTempDir, getTestName(true)).absolutePath)
|
||||||
|
|
||||||
withLogFile("kotlin-daemon-test") { logFile ->
|
withLogFile("kotlin-daemon-test") { logFile ->
|
||||||
val daemonJVMOptions = makeTestDaemonJvmOptions(logFile)
|
val daemonJVMOptions = makeTestDaemonJvmOptions(logFile)
|
||||||
|
|||||||
Reference in New Issue
Block a user