Convert KotlinMultiFileTestWithJava.java to Kotlin
This commit is contained in:
+1
-1
@@ -13,7 +13,7 @@ abstract class AbstractFirDiagnosticsWithStdlibTest : AbstractFirDiagnosticsTest
|
||||
return ConfigurationKind.ALL
|
||||
}
|
||||
|
||||
override fun getTestJdkKind(testFiles: MutableList<TestFile>): TestJdkKind {
|
||||
override fun getTestJdkKind(files: List<TestFile>): TestJdkKind {
|
||||
return TestJdkKind.FULL_JDK
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -50,8 +50,8 @@ abstract class AbstractCompilerLightClassTest : KotlinMultiFileTestWithJava<Kotl
|
||||
|
||||
override fun createTestModule(
|
||||
name: String,
|
||||
dependencies: MutableList<String>,
|
||||
friends: MutableList<String>
|
||||
dependencies: List<String>,
|
||||
friends: List<String>
|
||||
): TestModule? = null
|
||||
|
||||
override fun createTestFile(
|
||||
|
||||
+10
-18
@@ -13,26 +13,18 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.kotlin.cfg
|
||||
|
||||
package org.jetbrains.kotlin.cfg;
|
||||
import org.jetbrains.kotlin.checkers.AbstractDiagnosticsTest
|
||||
import org.jetbrains.kotlin.test.ConfigurationKind
|
||||
import org.jetbrains.kotlin.test.TestJdkKind
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.checkers.AbstractDiagnosticsTest;
|
||||
import org.jetbrains.kotlin.test.ConfigurationKind;
|
||||
import org.jetbrains.kotlin.test.TestJdkKind;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AbstractDiagnosticsWithModifiedMockJdkTest extends AbstractDiagnosticsTest {
|
||||
@NotNull
|
||||
@Override
|
||||
protected ConfigurationKind getConfigurationKind() {
|
||||
return ConfigurationKind.ALL;
|
||||
abstract class AbstractDiagnosticsWithModifiedMockJdkTest : AbstractDiagnosticsTest() {
|
||||
override fun getConfigurationKind(): ConfigurationKind {
|
||||
return ConfigurationKind.ALL
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected TestJdkKind getTestJdkKind(@NotNull List<TestFile> testFiles) {
|
||||
return TestJdkKind.MODIFIED_MOCK_JDK;
|
||||
override fun getTestJdkKind(files: List<TestFile>): TestJdkKind {
|
||||
return TestJdkKind.MODIFIED_MOCK_JDK
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -30,7 +30,7 @@ abstract class AbstractDiagnosticsTestWithStdLibUsingJavac : AbstractDiagnostics
|
||||
return isJavacSkipTest(wholeFile, files)
|
||||
}
|
||||
|
||||
override fun setupEnvironment(environment: KotlinCoreEnvironment, testDataFile: File, files: MutableList<TestFile>) {
|
||||
override fun setupEnvironment(environment: KotlinCoreEnvironment, testDataFile: File, files: List<TestFile>) {
|
||||
val testDataFileText = testDataFile.readText()
|
||||
|
||||
val groupedByModule = files.groupBy(TestFile::module)
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ import java.io.File
|
||||
|
||||
abstract class AbstractJavacForeignAnnotationsTest : AbstractForeignAnnotationsTest() {
|
||||
|
||||
override fun setupEnvironment(environment: KotlinCoreEnvironment, testDataFile: File, files: MutableList<TestFile>) {
|
||||
override fun setupEnvironment(environment: KotlinCoreEnvironment, testDataFile: File, files: List<TestFile>) {
|
||||
val groupedByModule = files.groupBy(TestFile::module)
|
||||
val allKtFiles = groupedByModule.values.flatMap { getKtFiles(it, true) }
|
||||
environment.registerJavac(kotlinFiles = allKtFiles)
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ abstract class AbstractJavacForeignJava8AnnotationsTest : AbstractForeignJava8An
|
||||
return isSkipJavacTest(wholeFile, files)
|
||||
}
|
||||
|
||||
override fun setupEnvironment(environment: KotlinCoreEnvironment, testDataFile: File, files: MutableList<TestFile>) {
|
||||
override fun setupEnvironment(environment: KotlinCoreEnvironment, testDataFile: File, files: List<TestFile>) {
|
||||
val groupedByModule = files.groupBy(TestFile::module)
|
||||
val allKtFiles = groupedByModule.values.flatMap { getKtFiles(it, true) }
|
||||
environment.registerJavac(kotlinFiles = allKtFiles)
|
||||
|
||||
+8
-18
@@ -13,25 +13,15 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.kotlin.checkers
|
||||
|
||||
package org.jetbrains.kotlin.checkers;
|
||||
import org.jetbrains.kotlin.test.ConfigurationKind
|
||||
import org.jetbrains.kotlin.test.TestJdkKind
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.test.ConfigurationKind;
|
||||
import org.jetbrains.kotlin.test.TestJdkKind;
|
||||
abstract class AbstractDiagnosticsWithJdk9Test : AbstractDiagnosticsTest() {
|
||||
override fun getConfigurationKind(): ConfigurationKind = ConfigurationKind.ALL
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AbstractDiagnosticsWithJdk9Test extends AbstractDiagnosticsTest {
|
||||
@NotNull
|
||||
@Override
|
||||
protected ConfigurationKind getConfigurationKind() {
|
||||
return ConfigurationKind.ALL;
|
||||
override fun getTestJdkKind(files: List<TestFile>): TestJdkKind {
|
||||
return TestJdkKind.FULL_JDK_9
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected TestJdkKind getTestJdkKind(@NotNull List<TestFile> testFiles) {
|
||||
return TestJdkKind.FULL_JDK_9;
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -54,7 +54,7 @@ abstract class AbstractForeignAnnotationsTest : AbstractDiagnosticsTest() {
|
||||
|
||||
override fun getConfigurationKind(): ConfigurationKind = ConfigurationKind.ALL
|
||||
|
||||
override fun getTestJdkKind(testFiles: MutableList<TestFile>): TestJdkKind = TestJdkKind.FULL_JDK
|
||||
override fun getTestJdkKind(testFiles: List<TestFile>): TestJdkKind = TestJdkKind.FULL_JDK
|
||||
|
||||
open protected val annotationsPath: String
|
||||
get() = FOREIGN_ANNOTATIONS_SOURCES_PATH
|
||||
|
||||
+114
-151
@@ -2,203 +2,166 @@
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
package org.jetbrains.kotlin.checkers
|
||||
|
||||
package org.jetbrains.kotlin.checkers;
|
||||
import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoot
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.Companion.createForTests
|
||||
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.JVMConfigurationKeys
|
||||
import org.jetbrains.kotlin.parsing.KotlinParserDefinition
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.script.loadScriptingPlugin
|
||||
import org.jetbrains.kotlin.test.*
|
||||
import org.jetbrains.kotlin.test.TestFiles.TestFileFactory
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
import kotlin.io.FilesKt;
|
||||
import kotlin.text.Charsets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.cli.common.config.ContentRootsKt;
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles;
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment;
|
||||
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime;
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration;
|
||||
import org.jetbrains.kotlin.config.JVMConfigurationKeys;
|
||||
import org.jetbrains.kotlin.parsing.KotlinParserDefinition;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
import org.jetbrains.kotlin.test.*;
|
||||
import org.jetbrains.kotlin.test.KotlinBaseTest;
|
||||
abstract class KotlinMultiFileTestWithJava<M : KotlinBaseTest.TestModule, F : KotlinBaseTest.TestFile> :
|
||||
KotlinBaseTest<F>() {
|
||||
protected lateinit var javaFilesDir: File
|
||||
private var kotlinSourceRoot: File? = null
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.kotlin.script.ScriptTestUtilKt.loadScriptingPlugin;
|
||||
|
||||
public abstract class KotlinMultiFileTestWithJava<M extends KotlinBaseTest.TestModule, F extends KotlinBaseTest.TestFile> extends KotlinBaseTest<F> {
|
||||
protected File javaFilesDir;
|
||||
private File kotlinSourceRoot;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
@Throws(Exception::class)
|
||||
public override fun setUp() {
|
||||
super.setUp()
|
||||
// TODO: do not create temporary directory for tests without Java sources
|
||||
javaFilesDir = KotlinTestUtils.tmpDir("java-files");
|
||||
javaFilesDir = KotlinTestUtils.tmpDir("java-files")
|
||||
if (isKotlinSourceRootNeeded()) {
|
||||
kotlinSourceRoot = KotlinTestUtils.tmpDir("kotlin-src");
|
||||
kotlinSourceRoot = KotlinTestUtils.tmpDir("kotlin-src")
|
||||
}
|
||||
}
|
||||
|
||||
public class ModuleAndDependencies {
|
||||
final M module;
|
||||
final List<String> dependencies;
|
||||
final List<String> friends;
|
||||
inner class ModuleAndDependencies internal constructor(val module: M?, val dependencies: List<String>, val friends: List<String>)
|
||||
|
||||
ModuleAndDependencies(M module, List<String> dependencies, List<String> friends) {
|
||||
this.module = module;
|
||||
this.dependencies = dependencies;
|
||||
this.friends = friends;
|
||||
}
|
||||
override fun createTestFilesFromFile(file: File, expectedText: String): List<F> {
|
||||
return createTestFiles(file, expectedText, HashMap())
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Boolean isScriptingNeeded(@NotNull File file) {
|
||||
return file.getName().endsWith(KotlinParserDefinition.STD_SCRIPT_EXT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<F> createTestFilesFromFile(@NotNull File file, String expectedText) {
|
||||
return createTestFiles(file, expectedText, new HashMap<>());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected KotlinCoreEnvironment createEnvironment(
|
||||
@NotNull File file,
|
||||
@NotNull List<TestFile> files
|
||||
) {
|
||||
CompilerConfiguration configuration = KotlinTestUtils.newConfiguration(
|
||||
getConfigurationKind(),
|
||||
getTestJdkKind(files),
|
||||
getClasspath(file),
|
||||
isJavaSourceRootNeeded() ? Collections.singletonList(javaFilesDir) : Collections.emptyList()
|
||||
);
|
||||
protected fun createEnvironment(
|
||||
file: File,
|
||||
files: List<F>
|
||||
): KotlinCoreEnvironment {
|
||||
val configuration = KotlinTestUtils.newConfiguration(
|
||||
getConfigurationKind(),
|
||||
getTestJdkKind(files),
|
||||
getClasspath(file),
|
||||
if (isJavaSourceRootNeeded()) listOf(javaFilesDir) else emptyList()
|
||||
)
|
||||
if (isScriptingNeeded(file)) {
|
||||
loadScriptingPlugin(configuration);
|
||||
loadScriptingPlugin(configuration)
|
||||
}
|
||||
if (isKotlinSourceRootNeeded()) {
|
||||
ContentRootsKt.addKotlinSourceRoot(configuration, kotlinSourceRoot.getPath());
|
||||
configuration.addKotlinSourceRoot(kotlinSourceRoot!!.path)
|
||||
}
|
||||
|
||||
// Currently, we're testing IDE behavior when generating the .txt files for comparison, but this can be changed.
|
||||
// The main difference is the fact that the new class file reading implementation doesn't load parameter names from JDK classes.
|
||||
configuration.put(JVMConfigurationKeys.USE_PSI_CLASS_FILES_READING, true);
|
||||
configuration.put(JVMConfigurationKeys.USE_PSI_CLASS_FILES_READING, true)
|
||||
|
||||
performCustomConfiguration(configuration);
|
||||
return KotlinCoreEnvironment.createForTests(getTestRootDisposable(), configuration, getEnvironmentConfigFiles());
|
||||
performCustomConfiguration(configuration)
|
||||
return createForTests(testRootDisposable, configuration, getEnvironmentConfigFiles())
|
||||
}
|
||||
|
||||
protected boolean isJavaSourceRootNeeded() {
|
||||
return true;
|
||||
protected open fun isJavaSourceRootNeeded(): Boolean = true
|
||||
|
||||
protected open fun performCustomConfiguration(configuration: CompilerConfiguration) {}
|
||||
|
||||
protected open fun setupEnvironment(environment: KotlinCoreEnvironment) {}
|
||||
|
||||
protected open fun setupEnvironment(
|
||||
environment: KotlinCoreEnvironment,
|
||||
testDataFile: File,
|
||||
files: List<BaseDiagnosticsTest.TestFile>
|
||||
) {
|
||||
setupEnvironment(environment)
|
||||
}
|
||||
|
||||
protected void performCustomConfiguration(@NotNull CompilerConfiguration configuration) {
|
||||
|
||||
}
|
||||
|
||||
protected void setupEnvironment(@NotNull KotlinCoreEnvironment environment) {
|
||||
|
||||
}
|
||||
|
||||
protected void setupEnvironment(@NotNull KotlinCoreEnvironment environment,@NotNull File testDataFile, @NotNull List<BaseDiagnosticsTest.TestFile> files) {
|
||||
setupEnvironment(environment);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected ConfigurationKind getConfigurationKind() {
|
||||
return ConfigurationKind.JDK_ONLY;
|
||||
}
|
||||
|
||||
private List<File> getClasspath(File file) {
|
||||
List<File> result = new ArrayList<>();
|
||||
result.add(KotlinTestUtils.getAnnotationsJar());
|
||||
result.addAll(getExtraClasspath());
|
||||
|
||||
String fileText = FilesKt.readText(file, Charsets.UTF_8);
|
||||
protected open fun getConfigurationKind() = ConfigurationKind.JDK_ONLY
|
||||
|
||||
private fun getClasspath(file: File): List<File> {
|
||||
val result: MutableList<File> = ArrayList()
|
||||
result.add(KotlinTestUtils.getAnnotationsJar())
|
||||
result.addAll(getExtraClasspath())
|
||||
val fileText = file.readText(Charsets.UTF_8)
|
||||
if (InTextDirectivesUtils.isDirectiveDefined(fileText, "ANDROID_ANNOTATIONS")) {
|
||||
result.add(ForTestCompileRuntime.androidAnnotationsForTests());
|
||||
result.add(ForTestCompileRuntime.androidAnnotationsForTests())
|
||||
}
|
||||
if (InTextDirectivesUtils.isDirectiveDefined(fileText, "STDLIB_JDK8")) {
|
||||
result.add(ForTestCompileRuntime.runtimeJarForTestsWithJdk8());
|
||||
result.add(ForTestCompileRuntime.runtimeJarForTestsWithJdk8())
|
||||
}
|
||||
|
||||
if (DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString().equals(coroutinesPackage) ||
|
||||
fileText.contains(DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString())) {
|
||||
result.add(ForTestCompileRuntime.coroutinesCompatForTests());
|
||||
if (DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString() == coroutinesPackage ||
|
||||
fileText.contains(DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.asString())
|
||||
) {
|
||||
result.add(ForTestCompileRuntime.coroutinesCompatForTests())
|
||||
}
|
||||
|
||||
return result;
|
||||
return result
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected List<File> getExtraClasspath() {
|
||||
return Collections.emptyList();
|
||||
protected open fun getExtraClasspath(): List<File> = emptyList()
|
||||
|
||||
protected open fun getEnvironmentConfigFiles(): EnvironmentConfigFiles = EnvironmentConfigFiles.JVM_CONFIG_FILES
|
||||
|
||||
protected open fun isKotlinSourceRootNeeded(): Boolean = false
|
||||
|
||||
protected open fun createTestFileFromPath(filePath: String): File {
|
||||
return File(filePath)
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected EnvironmentConfigFiles getEnvironmentConfigFiles() {
|
||||
return EnvironmentConfigFiles.JVM_CONFIG_FILES;
|
||||
}
|
||||
|
||||
protected boolean isKotlinSourceRootNeeded() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected File createTestFileFromPath(@NotNull String filePath) {
|
||||
return new File(filePath);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doTest(@NotNull String filePath) throws Exception {
|
||||
File file = createTestFileFromPath(filePath);
|
||||
String expectedText = KotlinTestUtils.doLoadFile(file);
|
||||
@Throws(Exception::class)
|
||||
public override fun doTest(filePath: String) {
|
||||
val file = createTestFileFromPath(filePath)
|
||||
val expectedText = KotlinTestUtils.doLoadFile(file)
|
||||
//TODO: move to proper tests
|
||||
if (InTextDirectivesUtils.isDirectiveDefined(expectedText, "// SKIP_JAVAC")) return;
|
||||
|
||||
super.doTest(file.getPath());
|
||||
if (InTextDirectivesUtils.isDirectiveDefined(expectedText, "// SKIP_JAVAC")) return
|
||||
super.doTest(file.path)
|
||||
}
|
||||
|
||||
protected abstract M createTestModule(@NotNull String name, List<String> dependencies, List<String> friends);
|
||||
protected abstract fun createTestModule(name: String, dependencies: List<String>, friends: List<String>): M?
|
||||
|
||||
protected abstract F createTestFile(M module, String fileName, String text, Map<String, String> directives);
|
||||
protected abstract fun createTestFile(module: M?, fileName: String, text: String, directives: Map<String, String>): F?
|
||||
|
||||
protected List<F> createTestFiles(File file, String expectedText, Map<String, ModuleAndDependencies> modules) {
|
||||
return TestFiles.createTestFiles(file.getName(), expectedText, new TestFiles.TestFileFactory<M, F>() {
|
||||
@Override
|
||||
public F createFile(
|
||||
@Nullable M module,
|
||||
@NotNull String fileName,
|
||||
@NotNull String text,
|
||||
@NotNull Map<String, String> directives
|
||||
) {
|
||||
protected open fun createTestFiles(
|
||||
file: File,
|
||||
expectedText: String,
|
||||
modules: MutableMap<String?, ModuleAndDependencies>
|
||||
): List<F> {
|
||||
return TestFiles.createTestFiles(file.name, expectedText, object : TestFileFactory<M, F> {
|
||||
override fun createFile(
|
||||
module: M?,
|
||||
fileName: String,
|
||||
text: String,
|
||||
directives: Map<String, String>
|
||||
): F? {
|
||||
if (fileName.endsWith(".java")) {
|
||||
writeSourceFile(fileName, text, javaFilesDir);
|
||||
writeSourceFile(fileName, text, javaFilesDir!!)
|
||||
}
|
||||
|
||||
if ((fileName.endsWith(".kt") || fileName.endsWith(".kts")) && kotlinSourceRoot != null) {
|
||||
writeSourceFile(fileName, text, kotlinSourceRoot);
|
||||
writeSourceFile(fileName, text, kotlinSourceRoot!!)
|
||||
}
|
||||
|
||||
return createTestFile(module, fileName, text, directives);
|
||||
return createTestFile(module, fileName, text, directives)
|
||||
}
|
||||
|
||||
@Override
|
||||
public M createModule(@NotNull String name, @NotNull List<String> dependencies, @NotNull List<String> friends) {
|
||||
M module = createTestModule(name, dependencies, friends);
|
||||
ModuleAndDependencies oldValue = modules.put(name, new ModuleAndDependencies(module, dependencies, friends));
|
||||
assert oldValue == null : "Module " + name + " declared more than once";
|
||||
|
||||
return module;
|
||||
override fun createModule(name: String, dependencies: List<String>, friends: List<String>): M? {
|
||||
val module = createTestModule(name, dependencies, friends)
|
||||
val oldValue = modules.put(name, ModuleAndDependencies(module, dependencies, friends))
|
||||
assert(oldValue == null) { "Module $name declared more than once" }
|
||||
return module
|
||||
}
|
||||
|
||||
private void writeSourceFile(@NotNull String fileName, @NotNull String content, @NotNull File targetDir) {
|
||||
File file = new File(targetDir, fileName);
|
||||
KotlinTestUtils.mkdirs(file.getParentFile());
|
||||
FilesKt.writeText(file, content, Charsets.UTF_8);
|
||||
private fun writeSourceFile(fileName: String, content: String, targetDir: File) {
|
||||
val file = File(targetDir, fileName)
|
||||
KotlinTestUtils.mkdirs(file.parentFile)
|
||||
file.writeText(content, Charsets.UTF_8)
|
||||
}
|
||||
}, coroutinesPackage);
|
||||
}, coroutinesPackage)
|
||||
}
|
||||
|
||||
}
|
||||
companion object {
|
||||
private fun isScriptingNeeded(file: File): Boolean {
|
||||
return file.name.endsWith(KotlinParserDefinition.STD_SCRIPT_EXT)
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -29,7 +29,7 @@ abstract class AbstractDiagnosticsUsingJavacTest : AbstractDiagnosticsTest() {
|
||||
return isJavacSkipTest(wholeFile, files)
|
||||
}
|
||||
|
||||
override fun setupEnvironment(environment: KotlinCoreEnvironment, testDataFile: File, files: MutableList<TestFile>) {
|
||||
override fun setupEnvironment(environment: KotlinCoreEnvironment, testDataFile: File, files: List<TestFile>) {
|
||||
val testDataFileText = testDataFile.readText()
|
||||
val groupedByModule = files.groupBy(TestFile::module)
|
||||
val allKtFiles = groupedByModule.values.flatMap { getKtFiles(it, true) }
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ abstract class AbstractJavacDiagnosticsTest : AbstractDiagnosticsTest() {
|
||||
|
||||
private var useJavac = true
|
||||
|
||||
override fun setupEnvironment(environment: KotlinCoreEnvironment, testDataFile: File, files: MutableList<TestFile>) {
|
||||
override fun setupEnvironment(environment: KotlinCoreEnvironment, testDataFile: File, files: List<TestFile>) {
|
||||
if (useJavac) {
|
||||
val groupedByModule = files.groupBy(TestFile::module)
|
||||
val allKtFiles = groupedByModule.values.flatMap { getKtFiles(it, true) }
|
||||
@@ -46,7 +46,7 @@ abstract class AbstractJavacDiagnosticsTest : AbstractDiagnosticsTest() {
|
||||
return specialFile.takeIf { it.exists() } ?: super.getExpectedDiagnosticsFile(testDataFile)
|
||||
}
|
||||
|
||||
override fun createTestFiles(file: File, expectedText: String, modules: MutableMap<String, ModuleAndDependencies>?): List<TestFile> {
|
||||
override fun createTestFiles(file: File, expectedText: String, modules: MutableMap<String?, ModuleAndDependencies>): List<TestFile> {
|
||||
val specialFile = getExpectedDiagnosticsFile(file)
|
||||
if (file.path == specialFile.path) {
|
||||
return super.createTestFiles(file, expectedText, modules)
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ abstract class AbstractJavacFieldResolutionTest : AbstractDiagnosticsTest() {
|
||||
|
||||
private var useJavac = true
|
||||
|
||||
override fun setupEnvironment(environment: KotlinCoreEnvironment, testDataFile: File, files: MutableList<TestFile>) {
|
||||
override fun setupEnvironment(environment: KotlinCoreEnvironment, testDataFile: File, files: List<TestFile>) {
|
||||
if (useJavac) {
|
||||
val groupedByModule = files.groupBy(TestFile::module)
|
||||
val allKtFiles = groupedByModule.values.flatMap { getKtFiles(it, true) }
|
||||
|
||||
@@ -36,7 +36,7 @@ abstract class KotlinBaseTest<F : KotlinBaseTest.TestFile> : KtUsefulTestCase()
|
||||
doMultiFileTest(file, createTestFilesFromFile(file, expectedText))
|
||||
}
|
||||
|
||||
protected abstract fun createTestFilesFromFile(file: File, expectedText: String?): List<F>
|
||||
protected abstract fun createTestFilesFromFile(file: File, expectedText: String): List<F>
|
||||
|
||||
@Throws(java.lang.Exception::class)
|
||||
protected open fun doMultiFileTest(
|
||||
|
||||
@@ -12,23 +12,23 @@ import org.jetbrains.kotlin.test.ConfigurationKind
|
||||
import org.jetbrains.kotlin.test.TestJdkKind
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractVisualizer : KotlinMultiFileTestWithJava<KotlinBaseTest.TestModule?, KotlinBaseTest.TestFile>() {
|
||||
abstract class AbstractVisualizer : KotlinMultiFileTestWithJava<KotlinBaseTest.TestModule, KotlinBaseTest.TestFile>() {
|
||||
lateinit var replacement: Pair<String, String>
|
||||
|
||||
override fun createTestModule(
|
||||
name: String,
|
||||
dependencies: MutableList<String>,
|
||||
friends: MutableList<String>
|
||||
dependencies: List<String>,
|
||||
friends: List<String>
|
||||
): TestModule? = null
|
||||
|
||||
|
||||
override fun createTestFile(module: TestModule?, fileName: String?, text: String?, directives: MutableMap<String, String>?): TestFile? =
|
||||
override fun createTestFile(module: TestModule?, fileName: String, text: String, directives: Map<String, String>): TestFile? =
|
||||
null
|
||||
|
||||
|
||||
override fun doMultiFileTest(file: File, files: List<TestFile>) {
|
||||
val environment = createEnvironment(file, files)
|
||||
doVisualizerTest(file, environment)
|
||||
override fun doMultiFileTest(wholeFile: File, files: List<TestFile>) {
|
||||
val environment = createEnvironment(wholeFile, files)
|
||||
doVisualizerTest(wholeFile, environment)
|
||||
}
|
||||
|
||||
abstract fun doVisualizerTest(file: File, environment: KotlinCoreEnvironment)
|
||||
@@ -37,7 +37,7 @@ abstract class AbstractVisualizer : KotlinMultiFileTestWithJava<KotlinBaseTest.T
|
||||
return true
|
||||
}
|
||||
|
||||
override fun getTestJdkKind(testFiles: MutableList<TestFile>): TestJdkKind {
|
||||
override fun getTestJdkKind(files: List<TestFile>): TestJdkKind {
|
||||
return TestJdkKind.FULL_JDK
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user