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)
|
||||
}
|
||||
|
||||
testClass<AbstractLookupTrackerTest> {
|
||||
model("incremental/lookupTracker", extension = null, recursive = false)
|
||||
testClass<AbstractJvmLookupTrackerTest> {
|
||||
model("incremental/lookupTracker/jvm", extension = null, recursive = false)
|
||||
}
|
||||
}
|
||||
|
||||
testClass(AbstractIncrementalLazyCachesTest::class.java) {
|
||||
|
||||
+35
-29
@@ -40,6 +40,39 @@ import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import java.io.*
|
||||
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() {
|
||||
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()
|
||||
}
|
||||
|
||||
protected abstract fun runCompiler(filesToCompile: Iterable<File>, env: JpsCompilerEnvironment): Any?
|
||||
|
||||
fun doTest(path: String) {
|
||||
val sb = StringBuilder()
|
||||
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(
|
||||
compiledFiles: Iterable<File>,
|
||||
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 */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("jps-plugin/testData/incremental/lookupTracker")
|
||||
@TestMetadata("jps-plugin/testData/incremental/lookupTracker/jvm")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class LookupTrackerTestGenerated extends AbstractLookupTrackerTest {
|
||||
public void testAllFilesPresentInLookupTracker() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("jps-plugin/testData/incremental/lookupTracker"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, false);
|
||||
public class JvmLookupTrackerTestGenerated extends AbstractJvmLookupTrackerTest {
|
||||
public void testAllFilesPresentInJvm() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("jps-plugin/testData/incremental/lookupTracker/jvm"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, false);
|
||||
}
|
||||
|
||||
@TestMetadata("classifierMembers")
|
||||
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);
|
||||
}
|
||||
|
||||
@TestMetadata("conventions")
|
||||
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);
|
||||
}
|
||||
|
||||
@TestMetadata("expressionType")
|
||||
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);
|
||||
}
|
||||
|
||||
@TestMetadata("java")
|
||||
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);
|
||||
}
|
||||
|
||||
@TestMetadata("localDeclarations")
|
||||
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);
|
||||
}
|
||||
|
||||
@TestMetadata("packageDeclarations")
|
||||
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);
|
||||
}
|
||||
|
||||
@TestMetadata("simple")
|
||||
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);
|
||||
}
|
||||
|
||||
@TestMetadata("syntheticProperties")
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user