diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxCodegenTest.java b/compiler/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxCodegenTest.java index 50ce7e037ce..b3c7b2f0cef 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxCodegenTest.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxCodegenTest.java @@ -21,7 +21,6 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.util.Processor; import kotlin.collections.ArraysKt; import kotlin.io.FilesKt; -import kotlin.text.Charsets; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.cli.common.output.outputUtils.OutputUtilsKt; @@ -57,30 +56,22 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase { TestJdkKind jdkKind = TestJdkKind.MOCK_JDK; List javacOptions = new ArrayList(0); for (TestFile file : files) { - if (isFullJdkDirectiveDefined(file.content)) { + if (InTextDirectivesUtils.isDirectiveDefined(file.content, "FULL_JDK")) { jdkKind = TestJdkKind.FULL_JDK; - break; } + if (InTextDirectivesUtils.isDirectiveDefined(file.content, "NO_KOTLIN_REFLECT")) { + configurationKind = ConfigurationKind.NO_KOTLIN_REFLECT; + } + javacOptions.addAll(InTextDirectivesUtils.findListWithPrefixes(file.content, "// JAVAC_OPTIONS:")); } compileAndRun(files, javaFilesDir, jdkKind, javacOptions); } - protected void doTestWithStdlib(@NotNull String filename) { - configurationKind = InTextDirectivesUtils.isDirectiveDefined( - FilesKt.readText(new File(filename), Charsets.UTF_8), "NO_KOTLIN_REFLECT" - ) ? ConfigurationKind.NO_KOTLIN_REFLECT : ConfigurationKind.ALL; - - TestJdkKind jdkKind = isFullJdkDirectiveDefined(FilesKt.readText(new File(filename), Charsets.UTF_8)) - ? TestJdkKind.FULL_JDK - : TestJdkKind.MOCK_JDK; - - myEnvironment = KotlinTestUtils.createEnvironmentWithJdkAndNullabilityAnnotationsFromIdea( - getTestRootDisposable(), configurationKind, jdkKind - ); - - blackBoxFileByFullPath(filename); + protected void doTestWithStdlib(@NotNull String filename) throws Exception { + configurationKind = ConfigurationKind.ALL; + doTest(filename); } protected void compileAndRun( @@ -90,7 +81,7 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase { @NotNull List javacOptions ) { CompilerConfiguration configuration = compilerConfigurationForTests( - ConfigurationKind.ALL, jdkKind, Collections.singletonList(getAnnotationsJar()), + configurationKind, jdkKind, Collections.singletonList(getAnnotationsJar()), ArraysKt.filterNotNull(new File[] {javaSourceDir}) ); @@ -143,15 +134,6 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase { return javaFilePaths; } - private static boolean isFullJdkDirectiveDefined(@NotNull String content) { - return InTextDirectivesUtils.isDirectiveDefined(content, "FULL_JDK"); - } - - private void blackBoxFileByFullPath(@NotNull String filename) { - loadFileByFullPath(filename); - blackBox(); - } - protected void blackBox() { // If there are many files, the first 'box(): String' function will be executed. GeneratedClassLoader generatedClassLoader = generateAndCreateClassLoader(); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java b/compiler/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java index 734d45ef811..9a4a82aab50 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java @@ -73,7 +73,7 @@ public abstract class CodegenTestCase extends UsefulTestCase { protected CodegenTestFiles myFiles; protected ClassFileFactory classFileFactory; protected GeneratedClassLoader initializedClassLoader; - protected ConfigurationKind configurationKind; + protected ConfigurationKind configurationKind = ConfigurationKind.JDK_ONLY; protected final void createEnvironmentWithMockJdkAndIdeaAnnotations( @NotNull ConfigurationKind configurationKind,