@@ -169,7 +169,8 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun findFileInOutputDir(module: JpsModule, relativePath: String): File {
|
||||
@JvmStatic
|
||||
protected fun findFileInOutputDir(module: JpsModule, relativePath: String): File {
|
||||
val outputUrl = JpsJavaExtensionService.getInstance().getOutputUrl(module, false)
|
||||
assertNotNull(outputUrl)
|
||||
val outputDir = File(JpsPathUtil.urlToPath(outputUrl))
|
||||
|
||||
+57
@@ -1,10 +1,33 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.jps.build
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||
import org.jetbrains.jps.builders.JpsBuildTestCase
|
||||
import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner
|
||||
import org.jetbrains.kotlin.config.IncrementalCompilation
|
||||
import org.jetbrains.kotlin.config.LanguageVersion
|
||||
import org.jetbrains.kotlin.jps.JpsKotlinCompilerSettings
|
||||
import kotlin.reflect.KMutableProperty1
|
||||
import org.jetbrains.kotlin.daemon.common.COMPILE_DAEMON_CUSTOM_RUN_FILES_PATH_FOR_TESTS
|
||||
import org.jetbrains.kotlin.daemon.common.COMPILE_DAEMON_ENABLED_PROPERTY
|
||||
import org.jetbrains.kotlin.daemon.common.isDaemonEnabled
|
||||
import java.io.File
|
||||
|
||||
class KotlinJpsBuildTestIncremental : KotlinJpsBuildTest() {
|
||||
var isICEnabledBackup: Boolean = false
|
||||
@@ -20,6 +43,40 @@ class KotlinJpsBuildTestIncremental : KotlinJpsBuildTest() {
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
fun testJpsDaemonIC() {
|
||||
fun testImpl() {
|
||||
assertTrue("Daemon was not enabled!", isDaemonEnabled())
|
||||
|
||||
doTest()
|
||||
val module = myProject.modules.get(0)
|
||||
val mainKtClassFile = findFileInOutputDir(module, "MainKt.class")
|
||||
assertTrue("$mainKtClassFile does not exist!", mainKtClassFile.exists())
|
||||
|
||||
val fooKt = File(workDir, "src/Foo.kt")
|
||||
JpsBuildTestCase.change(fooKt.path, null)
|
||||
buildAllModules().assertSuccessful()
|
||||
assertCompiled(KotlinBuilder.KOTLIN_BUILDER_NAME, "src/Foo.kt")
|
||||
|
||||
JpsBuildTestCase.change(fooKt.path, "class Foo(val x: Int = 0)")
|
||||
buildAllModules().assertSuccessful()
|
||||
assertCompiled(KotlinBuilder.KOTLIN_BUILDER_NAME, "src/main.kt", "src/Foo.kt")
|
||||
}
|
||||
|
||||
val daemonHome = FileUtil.createTempDirectory("daemon-home", "testJpsDaemonIC")
|
||||
try {
|
||||
withSystemProperty(COMPILE_DAEMON_CUSTOM_RUN_FILES_PATH_FOR_TESTS, daemonHome.absolutePath) {
|
||||
withSystemProperty(COMPILE_DAEMON_ENABLED_PROPERTY, "true") {
|
||||
withSystemProperty(JpsKotlinCompilerRunner.FAIL_ON_FALLBACK_PROPERTY, "true") {
|
||||
testImpl()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
daemonHome.deleteRecursively()
|
||||
}
|
||||
}
|
||||
|
||||
fun testManyFiles() {
|
||||
doTest()
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.jps.build
|
||||
|
||||
inline fun withSystemProperty(property: String, newValue: String?, fn: ()->Unit) {
|
||||
val backup = System.getProperty(property)
|
||||
setOrClearSysProperty(property, newValue)
|
||||
|
||||
try {
|
||||
fn()
|
||||
}
|
||||
finally {
|
||||
setOrClearSysProperty(property, backup)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun setOrClearSysProperty(property: String, newValue: String?) {
|
||||
if (newValue != null) {
|
||||
System.setProperty(property, newValue)
|
||||
}
|
||||
else {
|
||||
System.clearProperty(property)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user