Save system properties in incremental jps tests
This commit is contained in:
@@ -31,22 +31,12 @@ public class IncrementalCompilation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@TestOnly
|
@TestOnly
|
||||||
public static void disableIncrementalCompilation() {
|
public static void setIsEnabled(boolean value) {
|
||||||
System.setProperty(INCREMENTAL_COMPILATION_PROPERTY, "false");
|
System.setProperty(INCREMENTAL_COMPILATION_PROPERTY, String.valueOf(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestOnly
|
@TestOnly
|
||||||
public static void enableIncrementalCompilation() {
|
public static void setIsExperimental(boolean value) {
|
||||||
System.setProperty(INCREMENTAL_COMPILATION_PROPERTY, "true");
|
System.setProperty(IS_EXPERIMENTAL_PROPERTY, String.valueOf(value));
|
||||||
}
|
|
||||||
|
|
||||||
@TestOnly
|
|
||||||
public static void disableExperimental() {
|
|
||||||
System.setProperty(IS_EXPERIMENTAL_PROPERTY, "false");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestOnly
|
|
||||||
public static void enableExperimental() {
|
|
||||||
System.setProperty(IS_EXPERIMENTAL_PROPERTY, "true");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -53,6 +53,7 @@ import org.jetbrains.kotlin.jps.incremental.getKotlinCache
|
|||||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||||
import org.jetbrains.kotlin.utils.Printer
|
import org.jetbrains.kotlin.utils.Printer
|
||||||
import org.jetbrains.kotlin.utils.keysToMap
|
import org.jetbrains.kotlin.utils.keysToMap
|
||||||
|
import java.io.ByteArrayInputStream
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.PrintStream
|
import java.io.PrintStream
|
||||||
@@ -106,14 +107,25 @@ public abstract class AbstractIncrementalJpsTest(
|
|||||||
Logger.getRootLogger().addAppender(console)
|
Logger.getRootLogger().addAppender(console)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val systemPropertiesBackup = run {
|
||||||
|
val props = System.getProperties()
|
||||||
|
val output = ByteArrayOutputStream()
|
||||||
|
props.store(output, "System properties backup")
|
||||||
|
output.toByteArray()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun restoreSystemProperties() {
|
||||||
|
val input = ByteArrayInputStream(systemPropertiesBackup)
|
||||||
|
val props = Properties()
|
||||||
|
props.load(input)
|
||||||
|
System.setProperties(props)
|
||||||
|
}
|
||||||
|
|
||||||
override fun setUp() {
|
override fun setUp() {
|
||||||
super.setUp()
|
super.setUp()
|
||||||
System.setProperty("kotlin.jps.tests", "true")
|
System.setProperty("kotlin.jps.tests", "true")
|
||||||
lookupsDuringTest = hashSetOf()
|
lookupsDuringTest = hashSetOf()
|
||||||
|
IncrementalCompilation.setIsExperimental(enableExperimentalIncrementalCompilation)
|
||||||
if (enableExperimentalIncrementalCompilation) {
|
|
||||||
IncrementalCompilation.enableExperimental()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DEBUG_LOGGING_ENABLED) {
|
if (DEBUG_LOGGING_ENABLED) {
|
||||||
enableDebugLogging()
|
enableDebugLogging()
|
||||||
@@ -121,12 +133,7 @@ public abstract class AbstractIncrementalJpsTest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun tearDown() {
|
override fun tearDown() {
|
||||||
System.clearProperty("kotlin.jps.tests")
|
restoreSystemProperties()
|
||||||
|
|
||||||
if (enableExperimentalIncrementalCompilation) {
|
|
||||||
IncrementalCompilation.disableExperimental()
|
|
||||||
}
|
|
||||||
|
|
||||||
super.tearDown()
|
super.tearDown()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-21
@@ -33,16 +33,11 @@ public abstract class AbstractIncrementalLazyCachesTest : AbstractIncrementalJps
|
|||||||
get() = "expected-kotlin-caches.txt"
|
get() = "expected-kotlin-caches.txt"
|
||||||
|
|
||||||
override fun doTest(testDataPath: String) {
|
override fun doTest(testDataPath: String) {
|
||||||
try {
|
super.doTest(testDataPath)
|
||||||
super.doTest(testDataPath)
|
|
||||||
|
|
||||||
val actual = dumpKotlinCachesFileNames()
|
val actual = dumpKotlinCachesFileNames()
|
||||||
val expectedFile = File(testDataPath, expectedCachesFileName)
|
val expectedFile = File(testDataPath, expectedCachesFileName)
|
||||||
UsefulTestCase.assertSameLinesWithFile(expectedFile.canonicalPath, actual)
|
UsefulTestCase.assertSameLinesWithFile(expectedFile.canonicalPath, actual)
|
||||||
}
|
|
||||||
finally {
|
|
||||||
IncrementalCompilation.enableIncrementalCompilation()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun performAdditionalModifications(modifications: List<AbstractIncrementalJpsTest.Modification>) {
|
override fun performAdditionalModifications(modifications: List<AbstractIncrementalJpsTest.Modification>) {
|
||||||
@@ -55,20 +50,10 @@ public abstract class AbstractIncrementalLazyCachesTest : AbstractIncrementalJps
|
|||||||
|
|
||||||
when {
|
when {
|
||||||
name.endsWith("incremental-compilation") -> {
|
name.endsWith("incremental-compilation") -> {
|
||||||
if (modification.dataFile.readAsBool()) {
|
IncrementalCompilation.setIsEnabled(modification.dataFile.readAsBool())
|
||||||
IncrementalCompilation.enableIncrementalCompilation()
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
IncrementalCompilation.disableIncrementalCompilation()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
name.endsWith("experimental-compilation") -> {
|
name.endsWith("experimental-compilation") -> {
|
||||||
if (modification.dataFile.readAsBool()) {
|
IncrementalCompilation.setIsExperimental(modification.dataFile.readAsBool())
|
||||||
IncrementalCompilation.enableExperimental()
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
IncrementalCompilation.disableExperimental()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-7
@@ -31,13 +31,7 @@ abstract class AbstractExperimentalIncrementalLazyCachesTest : AbstractIncrement
|
|||||||
get() = "experimental-expected-kotlin-caches.txt"
|
get() = "experimental-expected-kotlin-caches.txt"
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class AbstractExperimentalChangeIncrementalOptionTest : AbstractIncrementalLazyCachesTest() {
|
abstract class AbstractExperimentalChangeIncrementalOptionTest : AbstractIncrementalLazyCachesTest()
|
||||||
override fun setUp() {
|
|
||||||
super.setUp()
|
|
||||||
IncrementalCompilation.enableIncrementalCompilation()
|
|
||||||
IncrementalCompilation.disableExperimental()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class AbstractExperimentalIncrementalCacheVersionChangedTest : AbstractIncrementalCacheVersionChangedTest() {
|
abstract class AbstractExperimentalIncrementalCacheVersionChangedTest : AbstractIncrementalCacheVersionChangedTest() {
|
||||||
override val enableExperimentalIncrementalCompilation = true
|
override val enableExperimentalIncrementalCompilation = true
|
||||||
|
|||||||
Reference in New Issue
Block a user