Support test directives in inline tests

This commit is contained in:
Michael Bogdanov
2016-04-03 15:25:36 +03:00
parent d319811101
commit f5166b7aef
61 changed files with 77 additions and 72 deletions
@@ -55,12 +55,10 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase {
@Override
protected void doMultiFileTest(@NotNull File wholeFile, @NotNull List<TestFile> files, @Nullable File javaFilesDir) throws Exception {
TestJdkKind jdkKind = TestJdkKind.MOCK_JDK;
TestJdkKind jdkKind = getJdkKind(files);
List<String> javacOptions = new ArrayList<String>(0);
for (TestFile file : files) {
if (InTextDirectivesUtils.isDirectiveDefined(file.content, "FULL_JDK")) {
jdkKind = TestJdkKind.FULL_JDK;
}
if (InTextDirectivesUtils.isDirectiveDefined(file.content, "WITH_RUNTIME")) {
addRuntime = true;
}
@@ -16,15 +16,11 @@
package org.jetbrains.kotlin.codegen
import org.jetbrains.kotlin.test.ConfigurationKind
import java.io.File
abstract class AbstractBlackBoxInlineCodegenTest : AbstractBlackBoxCodegenTest() {
override fun doMultiFileTest(file: File, files: List<TestFile>, javaFilesDir: File?) {
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.ALL, files)
loadMultiFiles(files)
blackBox()
override fun doMultiFileTest(wholeFile: File, files: List<TestFile>, javaFilesDir: File?) {
super.doMultiFileTest(wholeFile, files, javaFilesDir)
try {
InlineTestUtil.checkNoCallsToInline(initializedClassLoader.allGeneratedFiles.filterClassFiles(), myFiles.psiFiles)
SMAPTestUtil.checkSMAP(files, generateClassesInFile().getClassFiles())
@@ -69,10 +69,10 @@ public abstract class AbstractCompileKotlinAgainstKotlinTest extends CodegenTest
assert files.size() == 2 : "There should be exactly two files in this test";
TestFile fileA = files.get(0);
TestFile fileB = files.get(1);
ClassFileFactory factoryA = compileA(fileA.name, fileA.content);
ClassFileFactory factoryA = compileA(fileA.name, fileA.content, files);
ClassFileFactory factoryB = null;
try {
factoryB = compileB(fileB.name, fileB.content);
factoryB = compileB(fileB.name, fileB.content, files);
invokeBox(PackagePartClassUtils.getFilePartShortName(new File(fileB.name).getName()));
}
catch (Throwable e) {
@@ -101,16 +101,16 @@ public abstract class AbstractCompileKotlinAgainstKotlinTest extends CodegenTest
}
@NotNull
protected ClassFileFactory compileA(@NotNull String fileName, @NotNull String content) throws IOException {
protected ClassFileFactory compileA(@NotNull String fileName, @NotNull String content, List<TestFile> files) throws IOException {
KotlinCoreEnvironment environment =
KotlinTestUtils.createEnvironmentWithMockJdkAndIdeaAnnotations(getTestRootDisposable(), ConfigurationKind.ALL);
KotlinTestUtils.createEnvironmentWithJdkAndNullabilityAnnotationsFromIdea(getTestRootDisposable(), ConfigurationKind.ALL, getJdkKind(files));
return compileKotlin(fileName, content, aDir, environment, getTestRootDisposable());
}
@NotNull
protected ClassFileFactory compileB(@NotNull String fileName, @NotNull String content) throws IOException {
protected ClassFileFactory compileB(@NotNull String fileName, @NotNull String content, List<TestFile> files) throws IOException {
CompilerConfiguration configurationWithADirInClasspath = KotlinTestUtils
.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK, KotlinTestUtils.getAnnotationsJar(), aDir);
.compilerConfigurationForTests(ConfigurationKind.ALL, getJdkKind(files), KotlinTestUtils.getAnnotationsJar(), aDir);
KotlinCoreEnvironment environment =
KotlinCoreEnvironment.createForTests(getTestRootDisposable(), configurationWithADirInClasspath, EnvironmentConfigFiles.JVM_CONFIG_FILES);
@@ -91,6 +91,16 @@ public abstract class CodegenTestCase extends UsefulTestCase {
createEnvironmentWithMockJdkAndIdeaAnnotations(configurationKind, Collections.<TestFile>emptyList(), javaSourceRoots);
}
@NotNull
protected static TestJdkKind getJdkKind(@NotNull List<TestFile> files) {
for (TestFile file : files) {
if (InTextDirectivesUtils.isDirectiveDefined(file.content, "FULL_JDK")) {
return TestJdkKind.FULL_JDK;
}
}
return TestJdkKind.MOCK_JDK;
}
protected final void createEnvironmentWithMockJdkAndIdeaAnnotations(
@NotNull ConfigurationKind configurationKind,
@NotNull List<TestFile> testFilesWithConfigurationDirectives,