Mock constant search in JPS tests
This commit is contained in:
+6
@@ -176,6 +176,12 @@ public class IncrementalJsCompilerRunnerTestGenerated extends AbstractIncrementa
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("constantValueChanged")
|
||||||
|
public void testConstantValueChanged() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/constantValueChanged/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("constantsUnchanged")
|
@TestMetadata("constantsUnchanged")
|
||||||
public void testConstantsUnchanged() throws Exception {
|
public void testConstantsUnchanged() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/constantsUnchanged/");
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/constantsUnchanged/");
|
||||||
|
|||||||
+6
@@ -176,6 +176,12 @@ public class IncrementalJvmCompilerRunnerTestGenerated extends AbstractIncrement
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("constantValueChanged")
|
||||||
|
public void testConstantValueChanged() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/constantValueChanged/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("constantsUnchanged")
|
@TestMetadata("constantsUnchanged")
|
||||||
public void testConstantsUnchanged() throws Exception {
|
public void testConstantsUnchanged() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/constantsUnchanged/");
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/constantsUnchanged/");
|
||||||
|
|||||||
+23
-2
@@ -22,6 +22,7 @@ import com.intellij.openapi.util.io.FileUtil
|
|||||||
import com.intellij.openapi.util.io.FileUtilRt
|
import com.intellij.openapi.util.io.FileUtilRt
|
||||||
import com.intellij.testFramework.TestLoggerFactory
|
import com.intellij.testFramework.TestLoggerFactory
|
||||||
import com.intellij.testFramework.UsefulTestCase
|
import com.intellij.testFramework.UsefulTestCase
|
||||||
|
import com.intellij.util.concurrency.FixedFuture
|
||||||
import junit.framework.TestCase
|
import junit.framework.TestCase
|
||||||
import org.apache.log4j.ConsoleAppender
|
import org.apache.log4j.ConsoleAppender
|
||||||
import org.apache.log4j.Level
|
import org.apache.log4j.Level
|
||||||
@@ -45,7 +46,6 @@ import org.jetbrains.jps.util.JpsPathUtil
|
|||||||
import org.jetbrains.kotlin.config.IncrementalCompilation
|
import org.jetbrains.kotlin.config.IncrementalCompilation
|
||||||
import org.jetbrains.kotlin.incremental.CacheVersion
|
import org.jetbrains.kotlin.incremental.CacheVersion
|
||||||
import org.jetbrains.kotlin.incremental.LookupSymbol
|
import org.jetbrains.kotlin.incremental.LookupSymbol
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
|
||||||
import org.jetbrains.kotlin.incremental.testingUtils.*
|
import org.jetbrains.kotlin.incremental.testingUtils.*
|
||||||
import org.jetbrains.kotlin.jps.incremental.JpsLookupStorageProvider
|
import org.jetbrains.kotlin.jps.incremental.JpsLookupStorageProvider
|
||||||
import org.jetbrains.kotlin.jps.incremental.KotlinDataContainerTarget
|
import org.jetbrains.kotlin.jps.incremental.KotlinDataContainerTarget
|
||||||
@@ -55,6 +55,7 @@ import org.jetbrains.kotlin.utils.Printer
|
|||||||
import org.jetbrains.kotlin.utils.keysToMap
|
import org.jetbrains.kotlin.utils.keysToMap
|
||||||
import java.io.*
|
import java.io.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import java.util.concurrent.Future
|
||||||
import kotlin.reflect.jvm.javaField
|
import kotlin.reflect.jvm.javaField
|
||||||
|
|
||||||
abstract class AbstractIncrementalJpsTest(
|
abstract class AbstractIncrementalJpsTest(
|
||||||
@@ -130,11 +131,14 @@ abstract class AbstractIncrementalJpsTest(
|
|||||||
super.tearDown()
|
super.tearDown()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// JPS forces rebuild of all files when JVM constant has been changed and Callbacks.ConstantAffectionResolver
|
||||||
|
// is not provided, so ConstantAffectionResolver is mocked with empty implementation
|
||||||
protected open val mockConstantSearch: Callbacks.ConstantAffectionResolver?
|
protected open val mockConstantSearch: Callbacks.ConstantAffectionResolver?
|
||||||
get() = null
|
get() = MockConstantSearch(workDir)
|
||||||
|
|
||||||
private fun build(scope: CompileScopeTestBuilder = CompileScopeTestBuilder.make().allModules()): MakeResult {
|
private fun build(scope: CompileScopeTestBuilder = CompileScopeTestBuilder.make().allModules()): MakeResult {
|
||||||
val workDirPath = FileUtil.toSystemIndependentName(workDir.absolutePath)
|
val workDirPath = FileUtil.toSystemIndependentName(workDir.absolutePath)
|
||||||
|
|
||||||
val logger = MyLogger(workDirPath)
|
val logger = MyLogger(workDirPath)
|
||||||
projectDescriptor = createProjectDescriptor(BuildLoggingManager(logger))
|
projectDescriptor = createProjectDescriptor(BuildLoggingManager(logger))
|
||||||
|
|
||||||
@@ -476,6 +480,23 @@ abstract class AbstractIncrementalJpsTest(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class MockConstantSearch(private val workDir: File) : Callbacks.ConstantAffectionResolver {
|
||||||
|
override fun request(
|
||||||
|
ownerClassName: String,
|
||||||
|
fieldName: String,
|
||||||
|
accessFlags: Int,
|
||||||
|
fieldRemoved: Boolean,
|
||||||
|
accessChanged: Boolean
|
||||||
|
): Future<Callbacks.ConstantAffection> {
|
||||||
|
val affectedFiles = workDir.walk().filter { it.isFile && it.isNameUsage() }
|
||||||
|
return FixedFuture(Callbacks.ConstantAffection(affectedFiles.toList()))
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun File.isNameUsage(): Boolean =
|
||||||
|
name.equals("usage.kt", ignoreCase = true)
|
||||||
|
|| name.equals("usage.java", ignoreCase = true)
|
||||||
|
}
|
||||||
|
|
||||||
internal val ProjectDescriptor.allModuleTargets: Collection<ModuleBuildTarget>
|
internal val ProjectDescriptor.allModuleTargets: Collection<ModuleBuildTarget>
|
||||||
get() = buildTargetIndex.allTargets.filterIsInstance<ModuleBuildTarget>()
|
get() = buildTargetIndex.allTargets.filterIsInstance<ModuleBuildTarget>()
|
||||||
|
|
||||||
|
|||||||
+6
@@ -347,6 +347,12 @@ public class IncrementalJpsTestGenerated extends AbstractIncrementalJpsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("constantValueChanged")
|
||||||
|
public void testConstantValueChanged() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/constantValueChanged/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("constantsUnchanged")
|
@TestMetadata("constantsUnchanged")
|
||||||
public void testConstantsUnchanged() throws Exception {
|
public void testConstantsUnchanged() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/constantsUnchanged/");
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/constantsUnchanged/");
|
||||||
|
|||||||
@@ -13,12 +13,10 @@ Exit code: ADDITIONAL_PASS_REQUIRED
|
|||||||
------------------------------------------
|
------------------------------------------
|
||||||
Cleaning output files:
|
Cleaning output files:
|
||||||
out/production/module/META-INF/module.kotlin_module
|
out/production/module/META-INF/module.kotlin_module
|
||||||
out/production/module/constant/ConstantKt.class
|
|
||||||
out/production/module/usage/UsageKt.class
|
out/production/module/usage/UsageKt.class
|
||||||
End of files
|
End of files
|
||||||
Compiling files:
|
Compiling files:
|
||||||
src/constant.kt
|
|
||||||
src/usage.kt
|
src/usage.kt
|
||||||
End of files
|
End of files
|
||||||
Exit code: OK
|
Exit code: OK
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
@@ -12,14 +12,7 @@ Marked as dirty by Kotlin:
|
|||||||
module2/src/usage.kt
|
module2/src/usage.kt
|
||||||
Exit code: ADDITIONAL_PASS_REQUIRED
|
Exit code: ADDITIONAL_PASS_REQUIRED
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
Cleaning output files:
|
Exit code: NOTHING_DONE
|
||||||
out/production/module1/META-INF/module1.kotlin_module
|
|
||||||
out/production/module1/test/ConstKt.class
|
|
||||||
End of files
|
|
||||||
Compiling files:
|
|
||||||
module1/src/const.kt
|
|
||||||
End of files
|
|
||||||
Exit code: OK
|
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
Building module2
|
Building module2
|
||||||
Cleaning output files:
|
Cleaning output files:
|
||||||
@@ -29,4 +22,4 @@ Compiling files:
|
|||||||
module2/src/usage.kt
|
module2/src/usage.kt
|
||||||
End of files
|
End of files
|
||||||
Exit code: OK
|
Exit code: OK
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
@@ -24,13 +24,10 @@ Marked as dirty by Kotlin:
|
|||||||
Exit code: ADDITIONAL_PASS_REQUIRED
|
Exit code: ADDITIONAL_PASS_REQUIRED
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
Cleaning output files:
|
Cleaning output files:
|
||||||
out/production/module/META-INF/module.kotlin_module
|
|
||||||
out/production/module/test/ConstKt.class
|
|
||||||
out/production/module/test/Usage.class
|
out/production/module/test/Usage.class
|
||||||
End of files
|
End of files
|
||||||
Compiling files:
|
Compiling files:
|
||||||
src/const.kt
|
|
||||||
src/usage.kt
|
src/usage.kt
|
||||||
End of files
|
End of files
|
||||||
Exit code: OK
|
Exit code: OK
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
-3
@@ -12,12 +12,9 @@ Marked as dirty by Kotlin:
|
|||||||
Exit code: ADDITIONAL_PASS_REQUIRED
|
Exit code: ADDITIONAL_PASS_REQUIRED
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
Cleaning output files:
|
Cleaning output files:
|
||||||
out/production/module/test/Klass$Companion.class
|
|
||||||
out/production/module/test/Klass.class
|
|
||||||
out/production/module/test/Usage.class
|
out/production/module/test/Usage.class
|
||||||
End of files
|
End of files
|
||||||
Compiling files:
|
Compiling files:
|
||||||
src/const.kt
|
|
||||||
src/usage.kt
|
src/usage.kt
|
||||||
End of files
|
End of files
|
||||||
Exit code: OK
|
Exit code: OK
|
||||||
|
|||||||
@@ -7,5 +7,30 @@ End of files
|
|||||||
Compiling files:
|
Compiling files:
|
||||||
src/const.kt
|
src/const.kt
|
||||||
End of files
|
End of files
|
||||||
Exit code: OK
|
Marked as dirty by Kotlin:
|
||||||
|
src/usage.kt
|
||||||
|
Exit code: ADDITIONAL_PASS_REQUIRED
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
|
Cleaning output files:
|
||||||
|
out/production/module/META-INF/module.kotlin_module
|
||||||
|
out/production/module/test/UsageKt.class
|
||||||
|
End of files
|
||||||
|
Compiling files:
|
||||||
|
src/usage.kt
|
||||||
|
End of files
|
||||||
|
Exit code: ABORT
|
||||||
|
------------------------------------------
|
||||||
|
COMPILATION FAILED
|
||||||
|
Unresolved reference: FOO
|
||||||
|
|
||||||
|
================ Step #2 =================
|
||||||
|
|
||||||
|
Cleaning output files:
|
||||||
|
out/production/module/test/ConstKt.class
|
||||||
|
End of files
|
||||||
|
Compiling files:
|
||||||
|
src/const.kt
|
||||||
|
src/usage.kt
|
||||||
|
End of files
|
||||||
|
Exit code: OK
|
||||||
|
------------------------------------------
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
package test
|
package test
|
||||||
|
|
||||||
val CONST = "foo"
|
const val FOO = "foo"
|
||||||
|
const val BAR = "bar"
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
package test
|
|
||||||
|
|
||||||
val CONST = "I'm not a constant anymore:" + System.currentTimeMillis()
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
const val BAR = "bar"
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
fun dummy() {}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
fun usage() {
|
||||||
|
println(FOO)
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
fun usage() {
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
================ Step #1 =================
|
||||||
|
|
||||||
|
Cleaning output files:
|
||||||
|
out/production/module/META-INF/module.kotlin_module
|
||||||
|
out/production/module/test/ConstKt.class
|
||||||
|
End of files
|
||||||
|
Compiling files:
|
||||||
|
src/const.kt
|
||||||
|
End of files
|
||||||
|
Marked as dirty by Kotlin:
|
||||||
|
src/usage.kt
|
||||||
|
Exit code: ADDITIONAL_PASS_REQUIRED
|
||||||
|
------------------------------------------
|
||||||
|
Cleaning output files:
|
||||||
|
out/production/module/META-INF/module.kotlin_module
|
||||||
|
out/production/module/test/UsageKt.class
|
||||||
|
End of files
|
||||||
|
Compiling files:
|
||||||
|
src/usage.kt
|
||||||
|
End of files
|
||||||
|
Exit code: OK
|
||||||
|
------------------------------------------
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
const val CONST = "foo"
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
const val CONST = "bar"
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
fun dummy() {}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
fun usage() {
|
||||||
|
println(CONST)
|
||||||
|
}
|
||||||
@@ -11,12 +11,10 @@ Marked as dirty by Kotlin:
|
|||||||
Exit code: ADDITIONAL_PASS_REQUIRED
|
Exit code: ADDITIONAL_PASS_REQUIRED
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
Cleaning output files:
|
Cleaning output files:
|
||||||
out/production/module/test/Object.class
|
|
||||||
out/production/module/test/Usage.class
|
out/production/module/test/Usage.class
|
||||||
End of files
|
End of files
|
||||||
Compiling files:
|
Compiling files:
|
||||||
src/const.kt
|
|
||||||
src/usage.kt
|
src/usage.kt
|
||||||
End of files
|
End of files
|
||||||
Exit code: OK
|
Exit code: OK
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
+1
-4
@@ -12,13 +12,10 @@ Marked as dirty by Kotlin:
|
|||||||
Exit code: ADDITIONAL_PASS_REQUIRED
|
Exit code: ADDITIONAL_PASS_REQUIRED
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
Cleaning output files:
|
Cleaning output files:
|
||||||
out/production/module/META-INF/module.kotlin_module
|
|
||||||
out/production/module/test/ConstKt.class
|
|
||||||
out/production/module/test/Usage.class
|
out/production/module/test/Usage.class
|
||||||
End of files
|
End of files
|
||||||
Compiling files:
|
Compiling files:
|
||||||
src/const.kt
|
|
||||||
src/usage.kt
|
src/usage.kt
|
||||||
End of files
|
End of files
|
||||||
Exit code: OK
|
Exit code: OK
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
+1
-4
@@ -12,13 +12,10 @@ Marked as dirty by Kotlin:
|
|||||||
Exit code: ADDITIONAL_PASS_REQUIRED
|
Exit code: ADDITIONAL_PASS_REQUIRED
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
Cleaning output files:
|
Cleaning output files:
|
||||||
out/production/module/test/Trait$Companion.class
|
|
||||||
out/production/module/test/Trait.class
|
|
||||||
out/production/module/test/Usage.class
|
out/production/module/test/Usage.class
|
||||||
End of files
|
End of files
|
||||||
Compiling files:
|
Compiling files:
|
||||||
src/const.kt
|
|
||||||
src/usage.kt
|
src/usage.kt
|
||||||
End of files
|
End of files
|
||||||
Exit code: OK
|
Exit code: OK
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
+1
-5
@@ -9,14 +9,10 @@ Compiling files:
|
|||||||
src/JavaClass.java
|
src/JavaClass.java
|
||||||
End of files
|
End of files
|
||||||
Cleaning output files:
|
Cleaning output files:
|
||||||
out/production/module/JavaClass.class
|
|
||||||
out/production/module/Usage.class
|
out/production/module/Usage.class
|
||||||
End of files
|
End of files
|
||||||
Compiling files:
|
Compiling files:
|
||||||
src/usage.kt
|
src/usage.kt
|
||||||
End of files
|
End of files
|
||||||
Exit code: OK
|
Exit code: OK
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
Compiling files:
|
|
||||||
src/JavaClass.java
|
|
||||||
End of files
|
|
||||||
+2
-7
@@ -11,14 +11,9 @@ Exit code: OK
|
|||||||
------------------------------------------
|
------------------------------------------
|
||||||
Cleaning output files:
|
Cleaning output files:
|
||||||
out/production/module/Usage.class
|
out/production/module/Usage.class
|
||||||
out/production/module/test/Klass$Companion.class
|
|
||||||
out/production/module/test/Klass.class
|
|
||||||
End of files
|
End of files
|
||||||
Compiling files:
|
Exit code: NOTHING_DONE
|
||||||
src/const.kt
|
|
||||||
End of files
|
|
||||||
Exit code: OK
|
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
Compiling files:
|
Compiling files:
|
||||||
src/Usage.java
|
src/Usage.java
|
||||||
End of files
|
End of files
|
||||||
+2
-7
@@ -11,14 +11,9 @@ Exit code: OK
|
|||||||
------------------------------------------
|
------------------------------------------
|
||||||
Cleaning output files:
|
Cleaning output files:
|
||||||
out/production/module/Usage.class
|
out/production/module/Usage.class
|
||||||
out/production/module/test/Klass$Companion.class
|
|
||||||
out/production/module/test/Klass.class
|
|
||||||
End of files
|
End of files
|
||||||
Compiling files:
|
Exit code: NOTHING_DONE
|
||||||
src/const.kt
|
|
||||||
End of files
|
|
||||||
Exit code: OK
|
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
Compiling files:
|
Compiling files:
|
||||||
src/Usage.java
|
src/Usage.java
|
||||||
End of files
|
End of files
|
||||||
Reference in New Issue
Block a user