Extract JVM lookup tracker tests
This commit is contained in:
@@ -1194,8 +1194,9 @@ fun main(args: Array<String>) {
|
|||||||
model("incremental/classHierarchyAffected", extension = null, excludeParentDirs = true)
|
model("incremental/classHierarchyAffected", extension = null, excludeParentDirs = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
testClass<AbstractLookupTrackerTest> {
|
testClass<AbstractJvmLookupTrackerTest> {
|
||||||
model("incremental/lookupTracker", extension = null, recursive = false)
|
model("incremental/lookupTracker/jvm", extension = null, recursive = false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
testClass(AbstractIncrementalLazyCachesTest::class.java) {
|
testClass(AbstractIncrementalLazyCachesTest::class.java) {
|
||||||
|
|||||||
+35
-29
@@ -40,6 +40,39 @@ import org.jetbrains.kotlin.test.KotlinTestUtils
|
|||||||
import java.io.*
|
import java.io.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
abstract class AbstractJvmLookupTrackerTest : AbstractLookupTrackerTest() {
|
||||||
|
override fun runCompiler(filesToCompile: Iterable<File>, env: JpsCompilerEnvironment): Any? {
|
||||||
|
val moduleFile = makeModuleFile(
|
||||||
|
name = "test",
|
||||||
|
isTest = true,
|
||||||
|
outputDir = outDir,
|
||||||
|
sourcesToCompile = filesToCompile.toList(),
|
||||||
|
javaSourceRoots = listOf(srcDir),
|
||||||
|
classpath = listOf(outDir).filter { it.exists() },
|
||||||
|
friendDirs = emptyList()
|
||||||
|
)
|
||||||
|
|
||||||
|
val args = K2JVMCompilerArguments().apply {
|
||||||
|
buildFile = moduleFile.canonicalPath
|
||||||
|
reportOutputFiles = true
|
||||||
|
}
|
||||||
|
val argsArray = ArgumentUtils.convertArgumentsToStringList(args).toTypedArray()
|
||||||
|
|
||||||
|
try {
|
||||||
|
val stream = ByteArrayOutputStream()
|
||||||
|
val out = PrintStream(stream)
|
||||||
|
val exitCode = CompilerRunnerUtil.invokeExecMethod(K2JVMCompiler::class.java.name, argsArray, env, out)
|
||||||
|
val reader = BufferedReader(StringReader(stream.toString()))
|
||||||
|
CompilerOutputParser.parseCompilerMessagesFromReader(env.messageCollector, reader, env.outputItemsCollector)
|
||||||
|
|
||||||
|
return exitCode
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
moduleFile.delete()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
abstract class AbstractLookupTrackerTest : TestWithWorkingDir() {
|
abstract class AbstractLookupTrackerTest : TestWithWorkingDir() {
|
||||||
private val DECLARATION_KEYWORDS = listOf("interface", "class", "enum class", "object", "fun", "operator fun", "val", "var")
|
private val DECLARATION_KEYWORDS = listOf("interface", "class", "enum class", "object", "fun", "operator fun", "val", "var")
|
||||||
@@ -71,6 +104,8 @@ abstract class AbstractLookupTrackerTest : TestWithWorkingDir() {
|
|||||||
super.tearDown()
|
super.tearDown()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected abstract fun runCompiler(filesToCompile: Iterable<File>, env: JpsCompilerEnvironment): Any?
|
||||||
|
|
||||||
fun doTest(path: String) {
|
fun doTest(path: String) {
|
||||||
val sb = StringBuilder()
|
val sb = StringBuilder()
|
||||||
fun StringBuilder.indentln(string: String) {
|
fun StringBuilder.indentln(string: String) {
|
||||||
@@ -159,35 +194,6 @@ abstract class AbstractLookupTrackerTest : TestWithWorkingDir() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun runCompiler(filesToCompile: Iterable<File>, env: JpsCompilerEnvironment): Any? {
|
|
||||||
val moduleFile = makeModuleFile(name = "test",
|
|
||||||
isTest = true,
|
|
||||||
outputDir = outDir,
|
|
||||||
sourcesToCompile = filesToCompile.toList(),
|
|
||||||
javaSourceRoots = listOf(srcDir),
|
|
||||||
classpath = listOf(outDir).filter { it.exists() },
|
|
||||||
friendDirs = emptyList())
|
|
||||||
outDir.mkdirs()
|
|
||||||
val args = K2JVMCompilerArguments().apply {
|
|
||||||
buildFile = moduleFile.canonicalPath
|
|
||||||
reportOutputFiles = true
|
|
||||||
}
|
|
||||||
val argsArray = ArgumentUtils.convertArgumentsToStringList(args).toTypedArray()
|
|
||||||
|
|
||||||
try {
|
|
||||||
val stream = ByteArrayOutputStream()
|
|
||||||
val out = PrintStream(stream)
|
|
||||||
val exitCode = CompilerRunnerUtil.invokeExecMethod(K2JVMCompiler::class.java.name, argsArray, env, out)
|
|
||||||
val reader = BufferedReader(StringReader(stream.toString()))
|
|
||||||
CompilerOutputParser.parseCompilerMessagesFromReader(env.messageCollector, reader, env.outputItemsCollector)
|
|
||||||
|
|
||||||
return exitCode
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
moduleFile.delete()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun checkLookups(
|
private fun checkLookups(
|
||||||
compiledFiles: Iterable<File>,
|
compiledFiles: Iterable<File>,
|
||||||
lookupTracker: TestLookupTracker,
|
lookupTracker: TestLookupTracker,
|
||||||
|
|||||||
+12
-12
@@ -28,59 +28,59 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
@TestMetadata("jps-plugin/testData/incremental/lookupTracker")
|
@TestMetadata("jps-plugin/testData/incremental/lookupTracker/jvm")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
public class LookupTrackerTestGenerated extends AbstractLookupTrackerTest {
|
public class JvmLookupTrackerTestGenerated extends AbstractJvmLookupTrackerTest {
|
||||||
public void testAllFilesPresentInLookupTracker() throws Exception {
|
public void testAllFilesPresentInJvm() throws Exception {
|
||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("jps-plugin/testData/incremental/lookupTracker"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, false);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("jps-plugin/testData/incremental/lookupTracker/jvm"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("classifierMembers")
|
@TestMetadata("classifierMembers")
|
||||||
public void testClassifierMembers() throws Exception {
|
public void testClassifierMembers() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/lookupTracker/classifierMembers/");
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/lookupTracker/jvm/classifierMembers/");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("conventions")
|
@TestMetadata("conventions")
|
||||||
public void testConventions() throws Exception {
|
public void testConventions() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/lookupTracker/conventions/");
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/lookupTracker/jvm/conventions/");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("expressionType")
|
@TestMetadata("expressionType")
|
||||||
public void testExpressionType() throws Exception {
|
public void testExpressionType() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/lookupTracker/expressionType/");
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/lookupTracker/jvm/expressionType/");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("java")
|
@TestMetadata("java")
|
||||||
public void testJava() throws Exception {
|
public void testJava() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/lookupTracker/java/");
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/lookupTracker/jvm/java/");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("localDeclarations")
|
@TestMetadata("localDeclarations")
|
||||||
public void testLocalDeclarations() throws Exception {
|
public void testLocalDeclarations() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/lookupTracker/localDeclarations/");
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/lookupTracker/jvm/localDeclarations/");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("packageDeclarations")
|
@TestMetadata("packageDeclarations")
|
||||||
public void testPackageDeclarations() throws Exception {
|
public void testPackageDeclarations() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/lookupTracker/packageDeclarations/");
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/lookupTracker/jvm/packageDeclarations/");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("simple")
|
@TestMetadata("simple")
|
||||||
public void testSimple() throws Exception {
|
public void testSimple() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/lookupTracker/simple/");
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/lookupTracker/jvm/simple/");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("syntheticProperties")
|
@TestMetadata("syntheticProperties")
|
||||||
public void testSyntheticProperties() throws Exception {
|
public void testSyntheticProperties() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/lookupTracker/syntheticProperties/");
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/lookupTracker/jvm/syntheticProperties/");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user