From 70d434e992e83e5cd02791889e793d3802165d5c Mon Sep 17 00:00:00 2001 From: Alexander Likhachev Date: Sun, 14 Feb 2021 09:53:16 +0300 Subject: [PATCH] Update tests after compiler properties rework #KT-43605 Fixed --- .../jetbrains/kotlin/cli/common/Properties.kt | 6 +++ .../kotlin/daemon/CompilerApiTest.kt | 5 ++- .../kotlin/daemon/CompilerDaemonTest.kt | 43 ++++++++++--------- .../integration/CompilerApiTest.kt | 5 ++- .../integration/CompilerDaemonTest.kt | 33 +++++++------- .../jps/build/AbstractIncrementalJpsTest.kt | 1 - .../build/AbstractIncrementalJpsTest.kt.201 | 1 - .../jps/build/SimpleKotlinJpsBuildTest.kt | 4 +- .../kotlin/jps/build/testingUtils.kt | 7 ++- .../jetbrains/kotlin/gradle/tasks/Tasks.kt | 11 +++-- 10 files changed, 63 insertions(+), 53 deletions(-) diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/Properties.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/Properties.kt index 33b9a4ef343..050a0fa0bcf 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/Properties.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/Properties.kt @@ -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) + } } } diff --git a/compiler/daemon/daemon-tests/test/org/jetbrains/kotlin/daemon/CompilerApiTest.kt b/compiler/daemon/daemon-tests/test/org/jetbrains/kotlin/daemon/CompilerApiTest.kt index 820f7e26f06..aef93f7c1a4 100644 --- a/compiler/daemon/daemon-tests/test/org/jetbrains/kotlin/daemon/CompilerApiTest.kt +++ b/compiler/daemon/daemon-tests/test/org/jetbrains/kotlin/daemon/CompilerApiTest.kt @@ -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( diff --git a/compiler/daemon/daemon-tests/test/org/jetbrains/kotlin/daemon/CompilerDaemonTest.kt b/compiler/daemon/daemon-tests/test/org/jetbrains/kotlin/daemon/CompilerDaemonTest.kt index 519f6843453..c31e0aa4a54 100644 --- a/compiler/daemon/daemon-tests/test/org/jetbrains/kotlin/daemon/CompilerDaemonTest.kt +++ b/compiler/daemon/daemon-tests/test/org/jetbrains/kotlin/daemon/CompilerDaemonTest.kt @@ -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 = listOf()): DaemonJVMOptions { val additionalArgs = arrayListOf() 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 diff --git a/compiler/daemon/daemon-tests/test/org/jetbrains/kotlin/daemon/experimental/integration/CompilerApiTest.kt b/compiler/daemon/daemon-tests/test/org/jetbrains/kotlin/daemon/experimental/integration/CompilerApiTest.kt index ae0ba2d4086..99ce7000ca3 100644 --- a/compiler/daemon/daemon-tests/test/org/jetbrains/kotlin/daemon/experimental/integration/CompilerApiTest.kt +++ b/compiler/daemon/daemon-tests/test/org/jetbrains/kotlin/daemon/experimental/integration/CompilerApiTest.kt @@ -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 { diff --git a/compiler/daemon/daemon-tests/test/org/jetbrains/kotlin/daemon/experimental/integration/CompilerDaemonTest.kt b/compiler/daemon/daemon-tests/test/org/jetbrains/kotlin/daemon/experimental/integration/CompilerDaemonTest.kt index 21541f86b35..987c28cd4a7 100644 --- a/compiler/daemon/daemon-tests/test/org/jetbrains/kotlin/daemon/experimental/integration/CompilerDaemonTest.kt +++ b/compiler/daemon/daemon-tests/test/org/jetbrains/kotlin/daemon/experimental/integration/CompilerDaemonTest.kt @@ -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 = listOf()): DaemonJVMOptions { val additionalArgs = arrayListOf() 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 diff --git a/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt b/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt index 9d1c9816369..62ab22a1cc1 100644 --- a/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt +++ b/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt @@ -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 diff --git a/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt.201 b/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt.201 index 94af68daeef..557bd7ff795 100644 --- a/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt.201 +++ b/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt.201 @@ -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 diff --git a/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/SimpleKotlinJpsBuildTest.kt b/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/SimpleKotlinJpsBuildTest.kt index 7e98717ba8b..a228fcceb6c 100644 --- a/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/SimpleKotlinJpsBuildTest.kt +++ b/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/SimpleKotlinJpsBuildTest.kt @@ -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() } diff --git a/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/testingUtils.kt b/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/testingUtils.kt index 6b2feb62b5d..990f417d6b1 100644 --- a/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/testingUtils.kt +++ b/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/testingUtils.kt @@ -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 { diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt index 9e8c07a43e7..bbbc7c3137a 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt @@ -336,16 +336,19 @@ abstract class AbstractKotlinCompile() : 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"