Update tests after compiler properties rework

#KT-43605 Fixed
This commit is contained in:
Alexander Likhachev
2021-02-14 09:53:16 +03:00
parent 3537c699b5
commit 70d434e992
10 changed files with 63 additions and 53 deletions
@@ -45,6 +45,8 @@ enum class CompilerSystemProperties(val property: String) {
systemPropertySetter(property, value!!)
}
fun clear(): String? = systemPropertyCleaner(property)
companion object {
var systemPropertyGetter: (String) -> String? = {
System.getProperty(it)
@@ -53,6 +55,10 @@ enum class CompilerSystemProperties(val property: String) {
var systemPropertySetter: (String, String) -> String? = { key, value ->
System.setProperty(key, value)
}
var systemPropertyCleaner: (String) -> String? = { key ->
System.clearProperty(key)
}
}
}
@@ -17,6 +17,7 @@
package org.jetbrains.kotlin.daemon
import com.intellij.openapi.application.ApplicationManager
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSourceLocation
@@ -127,7 +128,7 @@ class CompilerApiTest : KotlinIntegrationTestBase() {
val logFile: Path = createTempFile("kotlin-daemon-test.", ".log")
val daemonJVMOptions = configureDaemonJVMOptions("D$COMPILE_DAEMON_LOG_PATH_PROPERTY=\"${logFile.loggerCompatiblePath}\"",
val daemonJVMOptions = configureDaemonJVMOptions("D${CompilerSystemProperties.COMPILE_DAEMON_LOG_PATH_PROPERTY.property}=\"${logFile.loggerCompatiblePath}\"",
inheritMemoryLimits = false, inheritOtherJvmOptions = false, inheritAdditionalProperties = false)
val jar = tmpdir.absolutePath + File.separator + "hello.jar"
@@ -167,7 +168,7 @@ class CompilerApiTest : KotlinIntegrationTestBase() {
val logFile: Path = createTempFile("kotlin-daemon-test.", ".log")
val daemonJVMOptions = configureDaemonJVMOptions("D$COMPILE_DAEMON_LOG_PATH_PROPERTY=\"${logFile.loggerCompatiblePath}\"",
val daemonJVMOptions = configureDaemonJVMOptions("D${CompilerSystemProperties.COMPILE_DAEMON_LOG_PATH_PROPERTY.property}=\"${logFile.loggerCompatiblePath}\"",
inheritMemoryLimits = false, inheritOtherJvmOptions = false, inheritAdditionalProperties = false)
try {
val (code, outputs) = compileOnDaemon(
@@ -20,6 +20,7 @@ import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.util.io.FileUtilRt
import junit.framework.TestCase
import org.jetbrains.kotlin.cli.AbstractCliTest
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties
import org.jetbrains.kotlin.cli.common.messages.MessageRenderer
import org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector
import org.jetbrains.kotlin.cli.common.repl.*
@@ -109,7 +110,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
fun makeTestDaemonJvmOptions(logFile: File? = null, xmx: Int = 384, args: Iterable<String> = listOf()): DaemonJVMOptions {
val additionalArgs = arrayListOf<String>()
if (logFile != null) {
additionalArgs.add("D$COMPILE_DAEMON_LOG_PATH_PROPERTY=\"${logFile.loggerCompatiblePath}\"")
additionalArgs.add("D${CompilerSystemProperties.COMPILE_DAEMON_LOG_PATH_PROPERTY.property}=\"${logFile.loggerCompatiblePath}\"")
}
args.forEach { additionalArgs.add(it) }
val baseOpts = if (xmx > 0) DaemonJVMOptions(maxMemory = "${xmx}m") else DaemonJVMOptions()
@@ -160,16 +161,16 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
}
fun testDaemonJvmOptionsParsing() {
val backupJvmOptions = System.getProperty(COMPILE_DAEMON_JVM_OPTIONS_PROPERTY)
val backupJvmOptions = System.getProperty(CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.property)
try {
System.setProperty(COMPILE_DAEMON_JVM_OPTIONS_PROPERTY, "-aaa,-bbb\\,ccc,-ddd,-Xmx200m,-XX:MaxMetaspaceSize=10k,-XX:ReservedCodeCacheSize=100,-xxx\\,yyy")
System.setProperty(CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.property, "-aaa,-bbb\\,ccc,-ddd,-Xmx200m,-XX:MaxMetaspaceSize=10k,-XX:ReservedCodeCacheSize=100,-xxx\\,yyy")
val opts = configureDaemonJVMOptions(inheritMemoryLimits = false, inheritAdditionalProperties = false, inheritOtherJvmOptions = false)
assertEquals("200m", opts.maxMemory)
assertEquals("10k", opts.maxMetaspaceSize)
assertEquals("100", opts.reservedCodeCacheSize)
assertEquals(arrayListOf("aaa", "bbb,ccc", "ddd", "xxx,yyy", "ea"), opts.jvmParams)
System.setProperty(COMPILE_DAEMON_JVM_OPTIONS_PROPERTY, "-Xmx300m,-XX:MaxMetaspaceSize=10k,-XX:ReservedCodeCacheSize=100")
System.setProperty(CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.property, "-Xmx300m,-XX:MaxMetaspaceSize=10k,-XX:ReservedCodeCacheSize=100")
val opts2 = configureDaemonJVMOptions(inheritMemoryLimits = false, inheritAdditionalProperties = false, inheritOtherJvmOptions = false)
assertEquals("300m", opts2.maxMemory)
assertEquals( -1, DaemonJVMOptionsMemoryComparator().compare(opts, opts2))
@@ -178,14 +179,14 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
val myXmxParam = ManagementFactory.getRuntimeMXBean().inputArguments.first { it.startsWith("-Xmx") }
TestCase.assertNotNull(myXmxParam)
val myXmxVal = myXmxParam.substring(4)
System.clearProperty(COMPILE_DAEMON_JVM_OPTIONS_PROPERTY)
System.clearProperty(CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.property)
val opts3 = configureDaemonJVMOptions(inheritMemoryLimits = true,
inheritOtherJvmOptions = true,
inheritAdditionalProperties = false)
assertEquals(myXmxVal, opts3.maxMemory)
}
finally {
restoreSystemProperty(COMPILE_DAEMON_JVM_OPTIONS_PROPERTY, backupJvmOptions)
restoreSystemProperty(CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.property, backupJvmOptions)
}
}
@@ -215,12 +216,12 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
}
private fun withDaemonJvmOptionsSetTo(newValue: String?, fn: () -> Unit) {
val backup = getAndSetSystemProperty(COMPILE_DAEMON_JVM_OPTIONS_PROPERTY, newValue)
val backup = getAndSetSystemProperty(CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.property, newValue)
try {
fn()
} finally {
getAndSetSystemProperty(COMPILE_DAEMON_JVM_OPTIONS_PROPERTY, backup)
getAndSetSystemProperty(CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.property, backup)
}
}
@@ -237,15 +238,15 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
}
fun testDaemonOptionsParsing() {
val backupOptions = System.getProperty(COMPILE_DAEMON_OPTIONS_PROPERTY)
val backupOptions = System.getProperty(CompilerSystemProperties.COMPILE_DAEMON_OPTIONS_PROPERTY.property)
try {
System.setProperty(COMPILE_DAEMON_OPTIONS_PROPERTY, "runFilesPath=abcd,autoshutdownIdleSeconds=1111")
System.setProperty(CompilerSystemProperties.COMPILE_DAEMON_OPTIONS_PROPERTY.property, "runFilesPath=abcd,autoshutdownIdleSeconds=1111")
val opts = configureDaemonOptions(DaemonOptions(shutdownDelayMilliseconds = 1))
assertEquals("abcd", opts.runFilesPath)
assertEquals(1111, opts.autoshutdownIdleSeconds)
}
finally {
restoreSystemProperty(COMPILE_DAEMON_OPTIONS_PROPERTY, backupOptions)
restoreSystemProperty(CompilerSystemProperties.COMPILE_DAEMON_OPTIONS_PROPERTY.property, backupOptions)
}
}
@@ -518,12 +519,12 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
val daemonOptions = makeTestDaemonOptions(getTestName(true))
val jar = testTempDir.absolutePath + File.separator + "hello.jar"
val args = listOf(
File(File(System.getProperty("java.home"), "bin"), "java").absolutePath,
"-Xmx256m",
"-D$COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY",
"-cp",
daemonClientClassPath.joinToString(File.pathSeparator) { it.absolutePath },
KotlinCompilerClient::class.qualifiedName!!) +
File(File(System.getProperty("java.home"), "bin"), "java").absolutePath,
"-Xmx256m",
"-D${CompilerSystemProperties.COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY.property}",
"-cp",
daemonClientClassPath.joinToString(File.pathSeparator) { it.absolutePath },
KotlinCompilerClient::class.qualifiedName!!) +
daemonOptions.mappers.flatMap { it.toArgs(COMPILE_DAEMON_CMDLINE_OPTIONS_PREFIX) } +
compilerId.mappers.flatMap { it.toArgs(COMPILE_DAEMON_CMDLINE_OPTIONS_PREFIX) } +
File(getHelloAppBaseDir(), "hello.kt").absolutePath +
@@ -651,16 +652,16 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
}
}
System.setProperty(COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY, "true")
System.setProperty(COMPILE_DAEMON_STARTUP_TIMEOUT_PROPERTY, "100000")
CompilerSystemProperties.COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY.value = "true"
CompilerSystemProperties.COMPILE_DAEMON_STARTUP_TIMEOUT_PROPERTY.value = "100000"
val succeeded = try {
(1..ParallelStartParams.threads).forEach { connectThread(it - 1) }
doneLatch.await(PARALLEL_WAIT_TIMEOUT_S, TimeUnit.SECONDS)
}
finally {
System.clearProperty(COMPILE_DAEMON_STARTUP_TIMEOUT_PROPERTY)
System.clearProperty(COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY)
CompilerSystemProperties.COMPILE_DAEMON_STARTUP_TIMEOUT_PROPERTY.clear()
CompilerSystemProperties.COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY.clear()
}
Thread.sleep(100) // Wait for processes to finish and close log files
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.daemon.experimental.integration
import com.intellij.openapi.application.ApplicationManager
import kotlinx.coroutines.runBlocking
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSourceLocation
@@ -217,7 +218,7 @@ class CompilerApiTest : KotlinIntegrationTestBase() {
log.info("creating daemonJVMOptions")
val daemonJVMOptions = configureDaemonJVMOptions(
"D$COMPILE_DAEMON_LOG_PATH_PROPERTY=\"${externalLogFile.loggerCompatiblePath}\"",
"D${CompilerSystemProperties.COMPILE_DAEMON_LOG_PATH_PROPERTY.property}=\"${externalLogFile.loggerCompatiblePath}\"",
inheritMemoryLimits = false,
inheritOtherJvmOptions = false,
inheritAdditionalProperties = false
@@ -278,7 +279,7 @@ class CompilerApiTest : KotlinIntegrationTestBase() {
reportPerf = true
)
val daemonJVMOptions = configureDaemonJVMOptions(
"D$COMPILE_DAEMON_LOG_PATH_PROPERTY=\"${externalLogFile.loggerCompatiblePath}\"",
"D${CompilerSystemProperties.COMPILE_DAEMON_LOG_PATH_PROPERTY.property}=\"${externalLogFile.loggerCompatiblePath}\"",
inheritMemoryLimits = false, inheritOtherJvmOptions = false, inheritAdditionalProperties = false
)
try {
@@ -11,6 +11,7 @@ import junit.framework.TestCase
import kotlinx.coroutines.*
import org.jetbrains.kotlin.cli.AbstractCliTest
import org.jetbrains.kotlin.cli.common.CLICompiler
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties
import org.jetbrains.kotlin.cli.common.messages.MessageRenderer
import org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector
import org.jetbrains.kotlin.cli.common.repl.*
@@ -173,7 +174,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
fun makeTestDaemonJvmOptions(logFile: File? = null, xmx: Int = 384, args: Iterable<String> = listOf()): DaemonJVMOptions {
val additionalArgs = arrayListOf<String>()
if (logFile != null) {
additionalArgs.add("D$COMPILE_DAEMON_LOG_PATH_PROPERTY=\"${logFile.loggerCompatiblePath}\"")
additionalArgs.add("D${CompilerSystemProperties.COMPILE_DAEMON_LOG_PATH_PROPERTY.property}=\"${logFile.loggerCompatiblePath}\"")
}
args.forEach { additionalArgs.add(it) }
val baseOpts = if (xmx > 0) DaemonJVMOptions(maxMemory = "${xmx}m") else DaemonJVMOptions()
@@ -230,10 +231,10 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
}
fun ignore_testDaemonJvmOptionsParsing() {
val backupJvmOptions = System.getProperty(COMPILE_DAEMON_JVM_OPTIONS_PROPERTY)
val backupJvmOptions = System.getProperty(CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.property)
try {
System.setProperty(
COMPILE_DAEMON_JVM_OPTIONS_PROPERTY,
CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.property,
"-aaa,-bbb\\,ccc,-ddd,-Xmx200m,-XX:MaxMetaspaceSize=10k,-XX:ReservedCodeCacheSize=100,-xxx\\,yyy"
)
val opts =
@@ -243,7 +244,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
assertEquals("100", opts.reservedCodeCacheSize)
assertEquals(arrayListOf("aaa", "bbb,ccc", "ddd", "xxx,yyy", "ea"), opts.jvmParams)
System.setProperty(COMPILE_DAEMON_JVM_OPTIONS_PROPERTY, "-Xmx300m,-XX:MaxMetaspaceSize=10k,-XX:ReservedCodeCacheSize=100")
System.setProperty(CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.property, "-Xmx300m,-XX:MaxMetaspaceSize=10k,-XX:ReservedCodeCacheSize=100")
val opts2 =
configureDaemonJVMOptions(inheritMemoryLimits = false, inheritAdditionalProperties = false, inheritOtherJvmOptions = false)
assertEquals("300m", opts2.maxMemory)
@@ -253,7 +254,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
val myXmxParam = ManagementFactory.getRuntimeMXBean().inputArguments.first { it.startsWith("-Xmx") }
TestCase.assertNotNull(myXmxParam)
val myXmxVal = myXmxParam.substring(4)
System.clearProperty(COMPILE_DAEMON_JVM_OPTIONS_PROPERTY)
System.clearProperty(CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.property)
val opts3 = configureDaemonJVMOptions(
inheritMemoryLimits = true,
inheritOtherJvmOptions = true,
@@ -262,7 +263,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
assertEquals(myXmxVal, opts3.maxMemory)
} finally {
restoreSystemProperty(
COMPILE_DAEMON_JVM_OPTIONS_PROPERTY,
CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.property,
backupJvmOptions
)
}
@@ -294,12 +295,12 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
}
private fun withDaemonJvmOptionsSetTo(newValue: String?, fn: () -> Unit) {
val backup = getAndSetSystemProperty(COMPILE_DAEMON_JVM_OPTIONS_PROPERTY, newValue)
val backup = getAndSetSystemProperty(CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.property, newValue)
try {
fn()
} finally {
getAndSetSystemProperty(COMPILE_DAEMON_JVM_OPTIONS_PROPERTY, backup)
getAndSetSystemProperty(CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.property, backup)
}
}
@@ -316,14 +317,14 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
}
fun ignore_testDaemonOptionsParsing() {
val backupOptions = System.getProperty(COMPILE_DAEMON_OPTIONS_PROPERTY)
val backupOptions = System.getProperty(CompilerSystemProperties.COMPILE_DAEMON_OPTIONS_PROPERTY.property)
try {
System.setProperty(COMPILE_DAEMON_OPTIONS_PROPERTY, "runFilesPath=abcd,autoshutdownIdleSeconds=1111")
System.setProperty(CompilerSystemProperties.COMPILE_DAEMON_OPTIONS_PROPERTY.property, "runFilesPath=abcd,autoshutdownIdleSeconds=1111")
val opts = configureDaemonOptions(DaemonOptions(shutdownDelayMilliseconds = 1))
assertEquals("abcd", opts.runFilesPath)
assertEquals(1111, opts.autoshutdownIdleSeconds)
} finally {
restoreSystemProperty(COMPILE_DAEMON_OPTIONS_PROPERTY, backupOptions)
restoreSystemProperty(CompilerSystemProperties.COMPILE_DAEMON_OPTIONS_PROPERTY.property, backupOptions)
}
}
@@ -746,7 +747,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
val args = listOf(
File(File(System.getProperty("java.home"), "bin"), "java").absolutePath,
"-Xmx256m",
"-D$COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY",
"-D${CompilerSystemProperties.COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY.property}",
"-cp",
daemonClientClassPath.joinToString(File.pathSeparator) { it.absolutePath },
KotlinCompilerClientInstance::class.qualifiedName!!
@@ -946,15 +947,15 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
}
runBlocking {
System.setProperty(COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY, "true")
System.setProperty(COMPILE_DAEMON_STARTUP_TIMEOUT_PROPERTY, "100000")
CompilerSystemProperties.COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY.value = "true"
CompilerSystemProperties.COMPILE_DAEMON_STARTUP_TIMEOUT_PROPERTY.value = "100000"
val succeeded = try {
(1..ParallelStartParams.threads).forEach { connectThread(it - 1) }
doneLatch.await(PARALLEL_WAIT_TIMEOUT_S, TimeUnit.SECONDS)
} finally {
System.clearProperty(COMPILE_DAEMON_STARTUP_TIMEOUT_PROPERTY)
System.clearProperty(COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY)
CompilerSystemProperties.COMPILE_DAEMON_STARTUP_TIMEOUT_PROPERTY.clear()
CompilerSystemProperties.COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY.clear()
}
delay(1000) // Wait for processes to finish and close log files
@@ -42,7 +42,6 @@ import org.jetbrains.jps.model.JpsModuleRootModificationUtil
import org.jetbrains.jps.model.java.JpsJavaExtensionService
import org.jetbrains.jps.model.library.sdk.JpsSdk
import org.jetbrains.jps.util.JpsPathUtil
import org.jetbrains.kotlin.cli.common.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments
@@ -42,7 +42,6 @@ import org.jetbrains.jps.model.JpsModuleRootModificationUtil
import org.jetbrains.jps.model.java.JpsJavaExtensionService
import org.jetbrains.jps.model.library.sdk.JpsSdk
import org.jetbrains.jps.util.JpsPathUtil
import org.jetbrains.kotlin.cli.common.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments
@@ -18,8 +18,8 @@ package org.jetbrains.kotlin.jps.build
import com.intellij.util.PathUtil
import org.jetbrains.jps.model.java.JpsJavaExtensionService
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties
import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner
import org.jetbrains.kotlin.daemon.common.COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY
import org.jetbrains.kotlin.daemon.common.OSKind
import org.jetbrains.kotlin.test.KotlinTestUtils
import java.io.File
@@ -69,7 +69,7 @@ class SimpleKotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
// TODO: add JS tests
fun testDaemon() {
withDaemon {
withSystemProperty(COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY, "true") {
withSystemProperty(CompilerSystemProperties.COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY.property, "true") {
withSystemProperty(JpsKotlinCompilerRunner.FAIL_ON_FALLBACK_PROPERTY, "true") {
testLoadingKotlinFromDifferentModules()
}
@@ -17,9 +17,8 @@
package org.jetbrains.kotlin.jps.build
import com.intellij.openapi.util.io.FileUtil
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties
import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner
import org.jetbrains.kotlin.daemon.common.COMPILE_DAEMON_CUSTOM_RUN_FILES_PATH_FOR_TESTS
import org.jetbrains.kotlin.daemon.common.COMPILE_DAEMON_ENABLED_PROPERTY
inline fun withSystemProperty(property: String, newValue: String?, fn: ()->Unit) {
val backup = System.getProperty(property)
@@ -47,8 +46,8 @@ inline fun setOrClearSysProperty(property: String, newValue: String?) {
fun withDaemon(fn: () -> Unit) {
val daemonHome = FileUtil.createTempDirectory("daemon-home", "testJpsDaemonIC")
withSystemProperty(COMPILE_DAEMON_CUSTOM_RUN_FILES_PATH_FOR_TESTS, daemonHome.absolutePath) {
withSystemProperty(COMPILE_DAEMON_ENABLED_PROPERTY, "true") {
withSystemProperty(CompilerSystemProperties.COMPILE_DAEMON_CUSTOM_RUN_FILES_PATH_FOR_TESTS.property, daemonHome.absolutePath) {
withSystemProperty(CompilerSystemProperties.COMPILE_DAEMON_ENABLED_PROPERTY.property, "true") {
try {
fn()
} finally {
@@ -336,16 +336,19 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractKo
@TaskAction
fun execute(inputs: IncrementalTaskInputs) {
CompilerSystemProperties.systemPropertyGetter = {
val value = if (it in kotlinDaemonProperties) kotlinDaemonProperties[it] else System.getProperty(it)
logger.warn("System property read $it = $value (declared: ${it in kotlinDaemonProperties})")
value
if (it in kotlinDaemonProperties) kotlinDaemonProperties[it] else System.getProperty(it)
}
CompilerSystemProperties.systemPropertySetter = setter@{ key, value ->
val oldValue = kotlinDaemonProperties[key]
if (oldValue == value) return@setter oldValue
kotlinDaemonProperties[key] = value
System.setProperty(key, value)
logger.warn("System property set $key = $value (was: $oldValue)")
oldValue
}
CompilerSystemProperties.systemPropertyCleaner = {
val oldValue = kotlinDaemonProperties[it]
kotlinDaemonProperties.remove(it)
System.clearProperty(it)
oldValue
}
CompilerSystemProperties.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY.value = "true"