Rename compilerConfigurationForTests -> newConfiguration

This commit is contained in:
Alexander Udalov
2016-05-25 20:38:15 +03:00
parent d04624cfe9
commit 6674412079
27 changed files with 61 additions and 64 deletions
@@ -157,7 +157,7 @@ public class CodegenTestsOnAndroidGenerator extends UsefulTestCase {
ConfigurationKind configurationKind = isFullJdkAndRuntime ? ConfigurationKind.ALL : ConfigurationKind.JDK_ONLY; ConfigurationKind configurationKind = isFullJdkAndRuntime ? ConfigurationKind.ALL : ConfigurationKind.JDK_ONLY;
TestJdkKind testJdkKind = isFullJdkAndRuntime ? TestJdkKind.FULL_JDK : TestJdkKind.MOCK_JDK; TestJdkKind testJdkKind = isFullJdkAndRuntime ? TestJdkKind.FULL_JDK : TestJdkKind.MOCK_JDK;
CompilerConfiguration configuration = CompilerConfiguration configuration =
KotlinTestUtils.compilerConfigurationForTests(configurationKind, testJdkKind, KotlinTestUtils.getAnnotationsJar()); KotlinTestUtils.newConfiguration(configurationKind, testJdkKind, KotlinTestUtils.getAnnotationsJar());
configuration.put(JVMConfigurationKeys.MODULE_NAME, "android-module-" + MODULE_INDEX++); configuration.put(JVMConfigurationKeys.MODULE_NAME, "android-module-" + MODULE_INDEX++);
if (inheritMultifileParts) { if (inheritMultifileParts) {
configuration.put(JVMConfigurationKeys.INHERIT_MULTIFILE_PARTS, true); configuration.put(JVMConfigurationKeys.INHERIT_MULTIFILE_PARTS, true);
@@ -83,7 +83,7 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase {
@NotNull TestJdkKind jdkKind, @NotNull TestJdkKind jdkKind,
@NotNull List<String> javacOptions @NotNull List<String> javacOptions
) { ) {
CompilerConfiguration configuration = createCompilerConfigurationForTests( CompilerConfiguration configuration = createConfiguration(
configurationKind, jdkKind, configurationKind, jdkKind,
Collections.singletonList(getAnnotationsJar()), Collections.singletonList(getAnnotationsJar()),
ArraysKt.filterNotNull(new File[] {javaSourceDir}), ArraysKt.filterNotNull(new File[] {javaSourceDir}),
@@ -108,12 +108,14 @@ public abstract class AbstractCompileKotlinAgainstKotlinTest extends CodegenTest
@NotNull @NotNull
private ClassFileFactory compileB(@NotNull String fileName, @NotNull String content, List<TestFile> files) throws IOException { private ClassFileFactory compileB(@NotNull String fileName, @NotNull String content, List<TestFile> files) throws IOException {
CompilerConfiguration configurationWithADirInClasspath = KotlinTestUtils CompilerConfiguration configurationWithADirInClasspath = KotlinTestUtils.newConfiguration(
.compilerConfigurationForTests(ConfigurationKind.ALL, getJdkKind(files), KotlinTestUtils.getAnnotationsJar(), aDir); ConfigurationKind.ALL, getJdkKind(files), KotlinTestUtils.getAnnotationsJar(), aDir
);
Disposable compileDisposable = createDisposable("compileB"); Disposable compileDisposable = createDisposable("compileB");
KotlinCoreEnvironment environment = KotlinCoreEnvironment.createForTests( KotlinCoreEnvironment environment = KotlinCoreEnvironment.createForTests(
compileDisposable, configurationWithADirInClasspath, EnvironmentConfigFiles.JVM_CONFIG_FILES); compileDisposable, configurationWithADirInClasspath, EnvironmentConfigFiles.JVM_CONFIG_FILES
);
return compileKotlin(fileName, content, bDir, environment, compileDisposable); return compileKotlin(fileName, content, bDir, environment, compileDisposable);
} }
@@ -40,7 +40,7 @@ abstract class AbstractDumpDeclarationsTest : CodegenTestCase() {
val dumpToFile = KotlinTestUtils.tmpDirForTest(this).resolve(this.name + ".json") val dumpToFile = KotlinTestUtils.tmpDirForTest(this).resolve(this.name + ".json")
val configuration = val configuration =
KotlinTestUtils.compilerConfigurationForTests(configurationKind, TestJdkKind.MOCK_JDK, KotlinTestUtils.getAnnotationsJar()) KotlinTestUtils.newConfiguration(configurationKind, TestJdkKind.MOCK_JDK, KotlinTestUtils.getAnnotationsJar())
configuration.put(JVMConfigurationKeys.DECLARATIONS_JSON_PATH, dumpToFile.path) configuration.put(JVMConfigurationKeys.DECLARATIONS_JSON_PATH, dumpToFile.path)
myEnvironment = KotlinCoreEnvironment.createForTests(testRootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES) myEnvironment = KotlinCoreEnvironment.createForTests(testRootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
@@ -51,9 +51,11 @@ public abstract class AbstractLineNumberTest extends TestCaseWithTmpdir {
private KotlinCoreEnvironment createEnvironment() { private KotlinCoreEnvironment createEnvironment() {
return KotlinCoreEnvironment.createForTests( return KotlinCoreEnvironment.createForTests(
myTestRootDisposable, myTestRootDisposable,
KotlinTestUtils.compilerConfigurationForTests(ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK, KotlinTestUtils.newConfiguration(
KotlinTestUtils.getAnnotationsJar(), tmpdir), ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK, KotlinTestUtils.getAnnotationsJar(), tmpdir
EnvironmentConfigFiles.JVM_CONFIG_FILES); ),
EnvironmentConfigFiles.JVM_CONFIG_FILES
);
} }
@Override @Override
@@ -68,8 +68,10 @@ public abstract class AbstractTopLevelMembersInvocationTest extends AbstractByte
myEnvironment = KotlinCoreEnvironment.createForTests( myEnvironment = KotlinCoreEnvironment.createForTests(
getTestRootDisposable(), getTestRootDisposable(),
KotlinTestUtils.compilerConfigurationForTests(ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK, KotlinTestUtils.newConfiguration(
CollectionsKt.plus(classPath, KotlinTestUtils.getAnnotationsJar()), classPath), ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK,
CollectionsKt.plus(classPath, KotlinTestUtils.getAnnotationsJar()), classPath
),
EnvironmentConfigFiles.JVM_CONFIG_FILES); EnvironmentConfigFiles.JVM_CONFIG_FILES);
loadFiles(ArrayUtil.toStringArray(sourceFiles)); loadFiles(ArrayUtil.toStringArray(sourceFiles));
@@ -72,7 +72,6 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static org.jetbrains.kotlin.codegen.CodegenTestUtil.*; import static org.jetbrains.kotlin.codegen.CodegenTestUtil.*;
import static org.jetbrains.kotlin.test.KotlinTestUtils.compilerConfigurationForTests;
import static org.jetbrains.kotlin.test.KotlinTestUtils.getAnnotationsJar; import static org.jetbrains.kotlin.test.KotlinTestUtils.getAnnotationsJar;
public abstract class CodegenTestCase extends KtUsefulTestCase { public abstract class CodegenTestCase extends KtUsefulTestCase {
@@ -110,7 +109,7 @@ public abstract class CodegenTestCase extends KtUsefulTestCase {
throw new IllegalStateException("must not set up myEnvironment twice"); throw new IllegalStateException("must not set up myEnvironment twice");
} }
CompilerConfiguration configuration = createCompilerConfigurationForTests( CompilerConfiguration configuration = createConfiguration(
configurationKind, configurationKind,
TestJdkKind.MOCK_JDK, TestJdkKind.MOCK_JDK,
Collections.singletonList(getAnnotationsJar()), Collections.singletonList(getAnnotationsJar()),
@@ -124,14 +123,14 @@ public abstract class CodegenTestCase extends KtUsefulTestCase {
} }
@NotNull @NotNull
protected static CompilerConfiguration createCompilerConfigurationForTests( protected static CompilerConfiguration createConfiguration(
@NotNull ConfigurationKind kind, @NotNull ConfigurationKind kind,
@NotNull TestJdkKind jdkKind, @NotNull TestJdkKind jdkKind,
@NotNull List<File> classpath, @NotNull List<File> classpath,
@NotNull List<File> javaSource, @NotNull List<File> javaSource,
@NotNull List<TestFile> testFilesWithConfigurationDirectives @NotNull List<TestFile> testFilesWithConfigurationDirectives
) { ) {
CompilerConfiguration configuration = compilerConfigurationForTests(kind, jdkKind, classpath, javaSource); CompilerConfiguration configuration = KotlinTestUtils.newConfiguration(kind, jdkKind, classpath, javaSource);
updateConfigurationByDirectivesInTestFiles(testFilesWithConfigurationDirectives, configuration); updateConfigurationByDirectivesInTestFiles(testFilesWithConfigurationDirectives, configuration);
@@ -495,7 +494,7 @@ public abstract class CodegenTestCase extends KtUsefulTestCase {
protected void doTest(String filePath) throws Exception { protected void doTest(String filePath) throws Exception {
File file = new File(filePath); File file = new File(filePath);
String expectedText = KotlinTestUtils.doLoadFile(file); String expectedText = KotlinTestUtils.doLoadFile(file);
final Ref<File> javaFilesDir = Ref.create(); Ref<File> javaFilesDir = Ref.create();
List<TestFile> testFiles = createTestFiles(file, expectedText, javaFilesDir); List<TestFile> testFiles = createTestFiles(file, expectedText, javaFilesDir);
@@ -503,7 +502,7 @@ public abstract class CodegenTestCase extends KtUsefulTestCase {
} }
@NotNull @NotNull
public static List<TestFile> createTestFiles(File file, String expectedText, final Ref<File> javaFilesDir) { private static List<TestFile> createTestFiles(File file, String expectedText, final Ref<File> javaFilesDir) {
return KotlinTestUtils.createTestFiles(file.getName(), expectedText, new KotlinTestUtils.TestFileFactoryNoModules<TestFile>() { return KotlinTestUtils.createTestFiles(file.getName(), expectedText, new KotlinTestUtils.TestFileFactoryNoModules<TestFile>() {
@NotNull @NotNull
@Override @Override
@@ -111,7 +111,7 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
File ktFile = new File(ktFileName); File ktFile = new File(ktFileName);
File txtFile = new File(ktFileName.replaceFirst("\\.kt$", ".txt")); File txtFile = new File(ktFileName.replaceFirst("\\.kt$", ".txt"));
CompilerConfiguration configuration = compilerConfigurationForTests(configurationKind, TestJdkKind.MOCK_JDK, getAnnotationsJar()); CompilerConfiguration configuration = newConfiguration(configurationKind, TestJdkKind.MOCK_JDK, getAnnotationsJar());
if (useTypeTableInSerializer) { if (useTypeTableInSerializer) {
configuration.put(JVMConfigurationKeys.USE_TYPE_TABLE, true); configuration.put(JVMConfigurationKeys.USE_TYPE_TABLE, true);
} }
@@ -151,7 +151,7 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
} }
}); });
CompilerConfiguration configuration = KotlinTestUtils.compilerConfigurationForTests(ConfigurationKind.JDK_ONLY, getJdkKind()); CompilerConfiguration configuration = KotlinTestUtils.newConfiguration(ConfigurationKind.JDK_ONLY, getJdkKind());
ContentRootsKt.addKotlinSourceRoot(configuration, sourcesDir.getAbsolutePath()); ContentRootsKt.addKotlinSourceRoot(configuration, sourcesDir.getAbsolutePath());
JvmContentRootsKt.addJavaSourceRoot(configuration, new File("compiler/testData/loadJava/include")); JvmContentRootsKt.addJavaSourceRoot(configuration, new File("compiler/testData/loadJava/include"));
JvmContentRootsKt.addJavaSourceRoot(configuration, tmpdir); JvmContentRootsKt.addJavaSourceRoot(configuration, tmpdir);
@@ -187,8 +187,9 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
KotlinCoreEnvironment environment = KotlinCoreEnvironment.createForTests( KotlinCoreEnvironment environment = KotlinCoreEnvironment.createForTests(
getTestRootDisposable(), getTestRootDisposable(),
compilerConfigurationForTests(ConfigurationKind.JDK_ONLY, getJdkKind(), getAnnotationsJar(), libraryOut), newConfiguration(ConfigurationKind.JDK_ONLY, getJdkKind(), getAnnotationsJar(), libraryOut),
EnvironmentConfigFiles.JVM_CONFIG_FILES); EnvironmentConfigFiles.JVM_CONFIG_FILES
);
KtFile ktFile = KotlinTestUtils.createFile(kotlinSrc.getPath(), FileUtil.loadFile(kotlinSrc, true), environment.getProject()); KtFile ktFile = KotlinTestUtils.createFile(kotlinSrc.getPath(), FileUtil.loadFile(kotlinSrc, true), environment.getProject());
@@ -84,12 +84,8 @@ public class LoadDescriptorUtil {
else { else {
javaSourceRoots.add(javaRoot); javaSourceRoots.add(javaRoot);
} }
CompilerConfiguration configuration = KotlinTestUtils.compilerConfigurationForTests( CompilerConfiguration configuration =
configurationKind, KotlinTestUtils.newConfiguration(configurationKind, testJdkKind, javaBinaryRoots, javaSourceRoots);
testJdkKind,
javaBinaryRoots,
javaSourceRoots
);
KotlinCoreEnvironment environment = KotlinCoreEnvironment environment =
KotlinCoreEnvironment.createForTests(disposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES); KotlinCoreEnvironment.createForTests(disposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES);
@@ -305,9 +305,8 @@ public class KotlinTestUtils {
@NotNull TestJdkKind jdkKind @NotNull TestJdkKind jdkKind
) { ) {
return KotlinCoreEnvironment.createForTests( return KotlinCoreEnvironment.createForTests(
disposable, disposable, newConfiguration(configurationKind, jdkKind, getAnnotationsJar()), EnvironmentConfigFiles.JVM_CONFIG_FILES
compilerConfigurationForTests(configurationKind, jdkKind, getAnnotationsJar()), );
EnvironmentConfigFiles.JVM_CONFIG_FILES);
} }
@NotNull @NotNull
@@ -426,16 +425,16 @@ public class KotlinTestUtils {
} }
@NotNull @NotNull
public static CompilerConfiguration compilerConfigurationForTests( public static CompilerConfiguration newConfiguration(
@NotNull ConfigurationKind configurationKind, @NotNull ConfigurationKind configurationKind,
@NotNull TestJdkKind jdkKind, @NotNull TestJdkKind jdkKind,
@NotNull File... extraClasspath @NotNull File... extraClasspath
) { ) {
return compilerConfigurationForTests(configurationKind, jdkKind, Arrays.asList(extraClasspath), Collections.<File>emptyList()); return newConfiguration(configurationKind, jdkKind, Arrays.asList(extraClasspath), Collections.<File>emptyList());
} }
@NotNull @NotNull
public static CompilerConfiguration compilerConfigurationForTests( public static CompilerConfiguration newConfiguration(
@NotNull ConfigurationKind configurationKind, @NotNull ConfigurationKind configurationKind,
@NotNull TestJdkKind jdkKind, @NotNull TestJdkKind jdkKind,
@NotNull List<File> classpath, @NotNull List<File> classpath,
@@ -57,7 +57,7 @@ public abstract class KotlinMultiFileTestWithJava<M, F> extends KotlinTestWithEn
protected KotlinCoreEnvironment createEnvironment() throws Exception { protected KotlinCoreEnvironment createEnvironment() throws Exception {
// TODO: do not create temporary directory for tests without Java sources // TODO: do not create temporary directory for tests without Java sources
javaFilesDir = KotlinTestUtils.tmpDir("java-files"); javaFilesDir = KotlinTestUtils.tmpDir("java-files");
CompilerConfiguration configuration = KotlinTestUtils.compilerConfigurationForTests( CompilerConfiguration configuration = KotlinTestUtils.newConfiguration(
getConfigurationKind(), getConfigurationKind(),
getTestJdkKind(), getTestJdkKind(),
CollectionsKt.plus(Collections.singletonList(KotlinTestUtils.getAnnotationsJar()), getExtraClasspath()), CollectionsKt.plus(Collections.singletonList(KotlinTestUtils.getAnnotationsJar()), getExtraClasspath()),
@@ -174,15 +174,12 @@ class KotlinCliJavaFileManagerTest : KotlinTestWithEnvironment() {
TestCase.assertNull("Should not find class in empty scope", manager.findClass("foo.Test", GlobalSearchScope.EMPTY_SCOPE)) TestCase.assertNull("Should not find class in empty scope", manager.findClass("foo.Test", GlobalSearchScope.EMPTY_SCOPE))
} }
@Throws(Exception::class)
override fun createEnvironment(): KotlinCoreEnvironment { override fun createEnvironment(): KotlinCoreEnvironment {
javaFilesDir = KotlinTestUtils.tmpDir("java-file-manager-test") javaFilesDir = KotlinTestUtils.tmpDir("java-file-manager-test")
val configuration = KotlinTestUtils.compilerConfigurationForTests( val configuration = KotlinTestUtils.newConfiguration(
ConfigurationKind.MOCK_RUNTIME, ConfigurationKind.MOCK_RUNTIME, TestJdkKind.MOCK_JDK, emptyList(), listOf(javaFilesDir!!)
TestJdkKind.MOCK_JDK, )
emptyList(),
listOf<File>(javaFilesDir!!))
return KotlinCoreEnvironment.createForTests(testRootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES) return KotlinCoreEnvironment.createForTests(testRootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
} }
@@ -34,7 +34,7 @@ abstract class AbstractBlackBoxAgainstJavaCodegenTest : AbstractBlackBoxCodegenT
CodegenTestUtil.compileJava(findJavaSourcesInDirectory(directory), emptyList(), javacOptions) CodegenTestUtil.compileJava(findJavaSourcesInDirectory(directory), emptyList(), javacOptions)
} }
val configuration = createCompilerConfigurationForTests( val configuration = createConfiguration(
ConfigurationKind.ALL, jdkKind, ConfigurationKind.ALL, jdkKind,
/* classpath = */ listOf(KotlinTestUtils.getAnnotationsJar(), javaOutputDir), /* classpath = */ listOf(KotlinTestUtils.getAnnotationsJar(), javaOutputDir),
/* javaSource = */ emptyList(), /* javaSource = */ emptyList(),
@@ -48,8 +48,8 @@ public class GenerateNotNullAssertionsTest extends CodegenTestCase {
} }
private void setUpEnvironment(boolean disableCallAssertions, boolean disableParamAssertions, File... extraClassPath) { private void setUpEnvironment(boolean disableCallAssertions, boolean disableParamAssertions, File... extraClassPath) {
CompilerConfiguration configuration = KotlinTestUtils.compilerConfigurationForTests( CompilerConfiguration configuration =
ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK, extraClassPath); KotlinTestUtils.newConfiguration(ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK, extraClassPath);
configuration.put(JVMConfigurationKeys.DISABLE_CALL_ASSERTIONS, disableCallAssertions); configuration.put(JVMConfigurationKeys.DISABLE_CALL_ASSERTIONS, disableCallAssertions);
configuration.put(JVMConfigurationKeys.DISABLE_PARAM_ASSERTIONS, disableParamAssertions); configuration.put(JVMConfigurationKeys.DISABLE_PARAM_ASSERTIONS, disableParamAssertions);
@@ -50,7 +50,7 @@ public class StdlibTest extends KotlinTestWithEnvironment {
@Override @Override
protected KotlinCoreEnvironment createEnvironment() { protected KotlinCoreEnvironment createEnvironment() {
CompilerConfiguration configuration = KotlinTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.FULL_JDK); CompilerConfiguration configuration = KotlinTestUtils.newConfiguration(ConfigurationKind.ALL, TestJdkKind.FULL_JDK);
File junitJar = new File("libraries/lib/junit-4.11.jar"); File junitJar = new File("libraries/lib/junit-4.11.jar");
assertTrue(junitJar.exists()); assertTrue(junitJar.exists());
@@ -76,7 +76,7 @@ public abstract class AbstractCompileJavaAgainstKotlinTest extends TestCaseWithT
KotlinCoreEnvironment environment = KotlinCoreEnvironment.createForTests( KotlinCoreEnvironment environment = KotlinCoreEnvironment.createForTests(
getTestRootDisposable(), getTestRootDisposable(),
compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK, getAnnotationsJar(), out), newConfiguration(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK, getAnnotationsJar(), out),
EnvironmentConfigFiles.JVM_CONFIG_FILES EnvironmentConfigFiles.JVM_CONFIG_FILES
); );
@@ -123,8 +123,8 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
extras.addAll(extraClassPath); extras.addAll(extraClassPath);
extras.add(KotlinTestUtils.getAnnotationsJar()); extras.add(KotlinTestUtils.getAnnotationsJar());
CompilerConfiguration configuration = KotlinTestUtils.compilerConfigurationForTests( CompilerConfiguration configuration =
ConfigurationKind.ALL, TestJdkKind.MOCK_JDK, extras.toArray(new File[extras.size()])); KotlinTestUtils.newConfiguration(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK, extras.toArray(new File[extras.size()]));
return KotlinCoreEnvironment.createForTests(getTestRootDisposable(), configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES); return KotlinCoreEnvironment.createForTests(getTestRootDisposable(), configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES);
} }
@@ -68,7 +68,7 @@ class KotlinClassFinderTest : KotlinTestWithEnvironmentManagement() {
private fun createEnvironment(tmpdir: File?): KotlinCoreEnvironment { private fun createEnvironment(tmpdir: File?): KotlinCoreEnvironment {
return KotlinCoreEnvironment.createForTests( return KotlinCoreEnvironment.createForTests(
testRootDisposable, testRootDisposable,
KotlinTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK, tmpdir), KotlinTestUtils.newConfiguration(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK, tmpdir),
EnvironmentConfigFiles.JVM_CONFIG_FILES EnvironmentConfigFiles.JVM_CONFIG_FILES
).apply { ).apply {
// Activate Kotlin light class finder // Activate Kotlin light class finder
@@ -83,9 +83,8 @@ class MultiModuleJavaAnalysisCustomTest : KtUsefulTestCase() {
} }
private fun createEnvironment(moduleDirs: Array<File>): KotlinCoreEnvironment { private fun createEnvironment(moduleDirs: Array<File>): KotlinCoreEnvironment {
val configuration = KotlinTestUtils.compilerConfigurationForTests( val configuration =
ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK, emptyList(), moduleDirs.toList() KotlinTestUtils.newConfiguration(ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK, emptyList(), moduleDirs.toList())
)
return KotlinCoreEnvironment.createForTests(testRootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES) return KotlinCoreEnvironment.createForTests(testRootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
} }
@@ -165,15 +165,14 @@ public class ResolveDescriptorsFromExternalLibraries {
if (jar != null) { if (jar != null) {
environment = KotlinCoreEnvironment.createForTests( environment = KotlinCoreEnvironment.createForTests(
junk, junk,
KotlinTestUtils.compilerConfigurationForTests( KotlinTestUtils.newConfiguration(
ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK, KotlinTestUtils.getAnnotationsJar(), jar ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK, KotlinTestUtils.getAnnotationsJar(), jar
), ),
EnvironmentConfigFiles.JVM_CONFIG_FILES EnvironmentConfigFiles.JVM_CONFIG_FILES
); );
} }
else { else {
CompilerConfiguration configuration = CompilerConfiguration configuration = KotlinTestUtils.newConfiguration(ConfigurationKind.JDK_ONLY, TestJdkKind.FULL_JDK);
KotlinTestUtils.compilerConfigurationForTests(ConfigurationKind.JDK_ONLY, TestJdkKind.FULL_JDK);
environment = KotlinCoreEnvironment.createForTests(junk, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES); environment = KotlinCoreEnvironment.createForTests(junk, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES);
if (!findRtJar().equals(jar)) { if (!findRtJar().equals(jar)) {
throw new RuntimeException("rt.jar mismatch: " + jar + ", " + findRtJar()); throw new RuntimeException("rt.jar mismatch: " + jar + ", " + findRtJar());
@@ -80,8 +80,8 @@ abstract class AbstractReplInterpreterTest : KtUsefulTestCase() {
} }
protected fun doTest(path: String) { protected fun doTest(path: String) {
val configuration = KotlinTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK) val configuration = KotlinTestUtils.newConfiguration(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK)
val repl = ReplInterpreter(testRootDisposable!!, configuration, false, null) val repl = ReplInterpreter(testRootDisposable, configuration, false, null)
for ((code, expected) in loadLines(File(path))) { for ((code, expected) in loadLines(File(path))) {
val lineResult = repl.eval(code) val lineResult = repl.eval(code)
@@ -76,8 +76,7 @@ public class ScriptTest {
Disposable rootDisposable = Disposer.newDisposable(); Disposable rootDisposable = Disposer.newDisposable();
try { try {
CompilerConfiguration configuration = CompilerConfiguration configuration = KotlinTestUtils.newConfiguration(ConfigurationKind.JDK_ONLY, TestJdkKind.FULL_JDK);
KotlinTestUtils.compilerConfigurationForTests(ConfigurationKind.JDK_ONLY, TestJdkKind.FULL_JDK);
configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, messageCollector); configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, messageCollector);
ContentRootsKt.addKotlinSourceRoot(configuration, "compiler/testData/script/" + scriptPath); ContentRootsKt.addKotlinSourceRoot(configuration, "compiler/testData/script/" + scriptPath);
configuration.add(CommonConfigurationKeys.SCRIPT_DEFINITIONS_KEY, scriptDefinition); configuration.add(CommonConfigurationKeys.SCRIPT_DEFINITIONS_KEY, scriptDefinition);
@@ -52,7 +52,7 @@ abstract class AbstractLocalClassProtoTest : TestCaseWithTmpdir() {
val clazz = classLoader.loadClass(classFile.toRelativeString(tmpdir).substringBeforeLast(".class").replace('/', '.').replace('\\', '.')) val clazz = classLoader.loadClass(classFile.toRelativeString(tmpdir).substringBeforeLast(".class").replace('/', '.').replace('\\', '.'))
assertHasAnnotationData(clazz) assertHasAnnotationData(clazz)
val configuration = KotlinTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK, tmpdir) val configuration = KotlinTestUtils.newConfiguration(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK, tmpdir)
val environment = KotlinCoreEnvironment.createForTests(testRootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES) val environment = KotlinCoreEnvironment.createForTests(testRootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
val moduleContext = TopDownAnalyzerFacadeForJVM.createContextWithSealedModule(environment.project, configuration) val moduleContext = TopDownAnalyzerFacadeForJVM.createContextWithSealedModule(environment.project, configuration)
val providerFactory = FileBasedDeclarationProviderFactory(moduleContext.storageManager, emptyList()) val providerFactory = FileBasedDeclarationProviderFactory(moduleContext.storageManager, emptyList())
@@ -77,7 +77,9 @@ abstract class AbstractAnnotationProcessorBoxTest : KotlinTestWithEnvironment()
} }
override fun createEnvironment(): KotlinCoreEnvironment { override fun createEnvironment(): KotlinCoreEnvironment {
val configuration = KotlinTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK, listOf(KotlinTestUtils.getAnnotationsJar()), listOf(javaSourceRoot)) val configuration = KotlinTestUtils.newConfiguration(
ConfigurationKind.ALL, TestJdkKind.MOCK_JDK, listOf(KotlinTestUtils.getAnnotationsJar()), listOf(javaSourceRoot)
)
return KotlinCoreEnvironment.createForTests(testRootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES) return KotlinCoreEnvironment.createForTests(testRootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
} }
@@ -32,11 +32,11 @@ import java.util.regex.Pattern
abstract class AbstractAndroidBoxTest : AbstractBlackBoxCodegenTest() { abstract class AbstractAndroidBoxTest : AbstractBlackBoxCodegenTest() {
private fun createAndroidAPIEnvironment(path: String) { private fun createAndroidAPIEnvironment(path: String) {
return createEnvironmentForConfiguration(KotlinTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.ANDROID_API), path) return createEnvironmentForConfiguration(KotlinTestUtils.newConfiguration(ConfigurationKind.ALL, TestJdkKind.ANDROID_API), path)
} }
private fun createFakeAndroidEnvironment(path: String) { private fun createFakeAndroidEnvironment(path: String) {
return createEnvironmentForConfiguration(KotlinTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK), path) return createEnvironmentForConfiguration(KotlinTestUtils.newConfiguration(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK), path)
} }
private fun createEnvironmentForConfiguration(configuration: CompilerConfiguration, path: String) { private fun createEnvironmentForConfiguration(configuration: CompilerConfiguration, path: String) {
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.test.TestJdkKind
abstract class AbstractAndroidBytecodeShapeTest : AbstractBytecodeTextTest() { abstract class AbstractAndroidBytecodeShapeTest : AbstractBytecodeTextTest() {
private fun createAndroidAPIEnvironment(path: String) { private fun createAndroidAPIEnvironment(path: String) {
return createEnvironmentForConfiguration(KotlinTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.ANDROID_API), path) return createEnvironmentForConfiguration(KotlinTestUtils.newConfiguration(ConfigurationKind.ALL, TestJdkKind.ANDROID_API), path)
} }
private fun createEnvironmentForConfiguration(configuration: CompilerConfiguration, path: String) { private fun createEnvironmentForConfiguration(configuration: CompilerConfiguration, path: String) {
@@ -31,7 +31,7 @@ import java.io.File
abstract class AbstractAndroidSyntheticPropertyDescriptorTest : KtUsefulTestCase() { abstract class AbstractAndroidSyntheticPropertyDescriptorTest : KtUsefulTestCase() {
fun doTest(path: String) { fun doTest(path: String) {
val config = KotlinTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.ANDROID_API) val config = KotlinTestUtils.newConfiguration(ConfigurationKind.ALL, TestJdkKind.ANDROID_API)
val env = createAndroidTestEnvironment(config, getResPaths(path)) val env = createAndroidTestEnvironment(config, getResPaths(path))
val project = env.project val project = env.project