diff --git a/compiler/build.gradle.kts b/compiler/build.gradle.kts index e8884755e6f..02f386d7d7e 100644 --- a/compiler/build.gradle.kts +++ b/compiler/build.gradle.kts @@ -92,7 +92,6 @@ projectTest { dependsOn(*testDistProjects.map { "$it:dist" }.toTypedArray()) workingDir = rootDir systemProperty("kotlin.test.script.classpath", testSourceSet.output.classesDirs.joinToString(File.pathSeparator)) - systemProperty("kotlin.suppress.expected.test.failures", project.findProperty("kotlin.suppress.expected.test.failures") ?: false) doFirst { systemProperty("kotlin.ant.classpath", antLauncherJar.asPath) systemProperty("kotlin.ant.launcher.class", "org.apache.tools.ant.Main") diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractAsmLikeInstructionListingTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractAsmLikeInstructionListingTest.kt index 77dbebfe750..a52a37244b4 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractAsmLikeInstructionListingTest.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractAsmLikeInstructionListingTest.kt @@ -23,7 +23,7 @@ abstract class AbstractAsmLikeInstructionListingTest : CodegenTestCase() { val LOCAL_VARIABLE_TABLE_DIRECTIVE = "// LOCAL_VARIABLE_TABLE" } - override fun doMultiFileTest(wholeFile: File, files: List, javaFilesDir: File?, reportFailures: Boolean) { + override fun doMultiFileTest(wholeFile: File, files: List, javaFilesDir: File?) { val txtFile = File(wholeFile.parentFile, wholeFile.nameWithoutExtension + ".txt") compile(files, javaFilesDir) diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxAgainstJavaCodegenTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxAgainstJavaCodegenTest.kt index 7045c226a31..57649a593fb 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxAgainstJavaCodegenTest.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxAgainstJavaCodegenTest.kt @@ -22,12 +22,12 @@ import org.jetbrains.kotlin.test.ConfigurationKind import java.io.File abstract class AbstractBlackBoxAgainstJavaCodegenTest : AbstractBlackBoxCodegenTest() { - override fun doMultiFileTest(wholeFile: File, files: MutableList, javaFilesDir: File?, reportFailures: Boolean) { + override fun doMultiFileTest(wholeFile: File, files: MutableList, javaFilesDir: File?) { javaClassesOutputDirectory = javaFilesDir!!.let { directory -> CodegenTestUtil.compileJava(CodegenTestUtil.findJavaSourcesInDirectory(directory), emptyList(), extractJavacOptions(files)) } - super.doMultiFileTest(wholeFile, files, null, reportFailures) + super.doMultiFileTest(wholeFile, files, null) } override fun updateConfiguration(configuration: CompilerConfiguration) { diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxCodegenTest.java b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxCodegenTest.java index 20a1f8b9515..cecc37b7344 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxCodegenTest.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxCodegenTest.java @@ -31,21 +31,18 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase { protected void doMultiFileTest( @NotNull File wholeFile, @NotNull List files, - @Nullable File javaFilesDir, - boolean reportFailures + @Nullable File javaFilesDir ) throws Exception { try { - compile(files, javaFilesDir, reportFailures); - blackBox(reportFailures); + compile(files, javaFilesDir); + blackBox(); } catch (Throwable t) { - if (reportFailures) { - try { - // To create .txt file in case of failure - doBytecodeListingTest(wholeFile); - } - catch (Throwable ignored) { - } + try { + // To create .txt file in case of failure + doBytecodeListingTest(wholeFile); + } + catch (Throwable ignored) { } throw t; @@ -92,9 +89,9 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase { assertEqualsToFile(expectedFile, text, s -> s.replace("COROUTINES_PACKAGE", coroutinesPackage)); } - protected void blackBox(boolean reportProblems) { + protected void blackBox() { // If there are many files, the first 'box(): String' function will be executed. - GeneratedClassLoader generatedClassLoader = generateAndCreateClassLoader(reportProblems); + GeneratedClassLoader generatedClassLoader = generateAndCreateClassLoader(); for (KtFile firstFile : myFiles.getPsiFiles()) { String className = getFacadeFqName(firstFile, classFileFactory.getGenerationState().getBindingContext()); if (className == null) continue; @@ -107,9 +104,7 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase { } } catch (Throwable e) { - if (reportProblems) { - System.out.println(generateToText()); - } + System.out.println(generateToText()); throw ExceptionUtilsKt.rethrow(e); } finally { diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxInlineCodegenTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxInlineCodegenTest.kt index 897854edcdb..130c69a815b 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxInlineCodegenTest.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxInlineCodegenTest.kt @@ -19,17 +19,15 @@ package org.jetbrains.kotlin.codegen import java.io.File abstract class AbstractBlackBoxInlineCodegenTest : AbstractBlackBoxCodegenTest() { - override fun doMultiFileTest(wholeFile: File, files: List, javaFilesDir: File?, reportFailures: Boolean) { - super.doMultiFileTest(wholeFile, files, javaFilesDir, reportFailures) + override fun doMultiFileTest(wholeFile: File, files: List, javaFilesDir: File?) { + super.doMultiFileTest(wholeFile, files, javaFilesDir) try { InlineTestUtil.checkNoCallsToInline(initializedClassLoader.allGeneratedFiles.filterClassFiles(), myFiles.psiFiles) SMAPTestUtil.checkSMAP(files, generateClassesInFile().getClassFiles(), false) } catch (e: Throwable) { - if (reportFailures) { - println(generateToText()) - throw e - } + println(generateToText()) + throw e } } } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBytecodeListingTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBytecodeListingTest.kt index 7e91976ecf6..b0f9262a72c 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBytecodeListingTest.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBytecodeListingTest.kt @@ -14,7 +14,7 @@ import org.jetbrains.org.objectweb.asm.Opcodes.* import java.io.File abstract class AbstractBytecodeListingTest : CodegenTestCase() { - override fun doMultiFileTest(wholeFile: File, files: List, javaFilesDir: File?, reportFailures: Boolean) { + override fun doMultiFileTest(wholeFile: File, files: List, javaFilesDir: File?) { compile(files, javaFilesDir) val actualTxt = BytecodeListingTextCollectingVisitor.getText(classFileFactory, withSignatures = isWithSignatures(wholeFile)) diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBytecodeTextTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBytecodeTextTest.kt index 3ff4ca76156..4cda4b8488c 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBytecodeTextTest.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBytecodeTextTest.kt @@ -20,7 +20,7 @@ import java.util.regex.Pattern abstract class AbstractBytecodeTextTest : CodegenTestCase() { @Throws(Exception::class) - override fun doMultiFileTest(wholeFile: File, files: List, javaFilesDir: File?, reportFailures: Boolean) { + override fun doMultiFileTest(wholeFile: File, files: List, javaFilesDir: File?) { createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.ALL, files, TestJdkKind.MOCK_JDK, javaFilesDir) loadMultiFiles(files) diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractCheckLocalVariablesTableTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractCheckLocalVariablesTableTest.kt index 393f8112afb..5f3db3b09b7 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractCheckLocalVariablesTableTest.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractCheckLocalVariablesTableTest.kt @@ -32,7 +32,7 @@ import java.util.regex.Pattern abstract class AbstractCheckLocalVariablesTableTest : CodegenTestCase() { - override fun doMultiFileTest(wholeFile: File, files: List, javaFilesDir: File?, reportFailures: Boolean) { + override fun doMultiFileTest(wholeFile: File, files: List, javaFilesDir: File?) { compile(files, javaFilesDir) try { @@ -52,10 +52,8 @@ abstract class AbstractCheckLocalVariablesTableTest : CodegenTestCase() { doCompare(wholeFile, files.single().content, actualLocalVariables) } catch (e: Throwable) { - if (reportFailures) { - println(classFileFactory.createText()) - throw e - } + println(classFileFactory.createText()) + throw e } } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractCompileKotlinAgainstInlineKotlinTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractCompileKotlinAgainstInlineKotlinTest.kt index c4319ea8709..77f3934bb16 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractCompileKotlinAgainstInlineKotlinTest.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractCompileKotlinAgainstInlineKotlinTest.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.codegen import java.io.File abstract class AbstractCompileKotlinAgainstInlineKotlinTest : AbstractCompileKotlinAgainstKotlinTest() { - override fun doMultiFileTest(wholeFile: File, files: List, javaFilesDir: File?, reportFailures: Boolean) { + override fun doMultiFileTest(wholeFile: File, files: List, javaFilesDir: File?) { val (factory1, factory2) = doTwoFileTest(files.filter { it.name.endsWith(".kt") }) try { val allGeneratedFiles = factory1.asList() + factory2.asList() @@ -28,10 +28,8 @@ abstract class AbstractCompileKotlinAgainstInlineKotlinTest : AbstractCompileKot SMAPTestUtil.checkSMAP(files, allGeneratedFiles.filterClassFiles(), true) } catch (e: Throwable) { - if (reportFailures) { - println("FIRST:\n\n${factory1.createText()}\n\nSECOND:\n\n${factory2.createText()}") - throw e - } + println("FIRST:\n\n${factory1.createText()}\n\nSECOND:\n\n${factory2.createText()}") + throw e } } } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractCompileKotlinAgainstKotlinTest.java b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractCompileKotlinAgainstKotlinTest.java index db8836a479b..6290e51ec30 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractCompileKotlinAgainstKotlinTest.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractCompileKotlinAgainstKotlinTest.java @@ -49,12 +49,7 @@ public abstract class AbstractCompileKotlinAgainstKotlinTest extends CodegenTest } @Override - protected void doMultiFileTest( - @NotNull File wholeFile, - @NotNull List files, - @Nullable File javaFilesDir, - boolean reportFailures - ) throws Exception { + protected void doMultiFileTest(@NotNull File wholeFile, @NotNull List files, @Nullable File javaFilesDir) throws Exception { assert javaFilesDir == null : ".java files are not supported yet in this test"; doTwoFileTest(files); } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractDumpDeclarationsTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractDumpDeclarationsTest.kt index bd83cb9bb60..f0b82b62605 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractDumpDeclarationsTest.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractDumpDeclarationsTest.kt @@ -15,7 +15,7 @@ abstract class AbstractDumpDeclarationsTest : CodegenTestCase() { private lateinit var dumpToFile: File - override fun doMultiFileTest(wholeFile: File, files: List, javaFilesDir: File?, reportFailures: Boolean) { + override fun doMultiFileTest(wholeFile: File, files: List, javaFilesDir: File?) { val expectedResult = KotlinTestUtils.replaceExtension(wholeFile, "json") dumpToFile = KotlinTestUtils.tmpDirForTest(this).resolve(name + ".json") compile(files, null) diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractKapt3BuilderModeBytecodeShapeTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractKapt3BuilderModeBytecodeShapeTest.kt index cd46aadb5ef..2108021ee75 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractKapt3BuilderModeBytecodeShapeTest.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractKapt3BuilderModeBytecodeShapeTest.kt @@ -29,7 +29,7 @@ abstract class AbstractKapt3BuilderModeBytecodeShapeTest : CodegenTestCase() { } } - override fun doMultiFileTest(wholeFile: File, files: MutableList, javaFilesDir: File?, reportFailures: Boolean) { + override fun doMultiFileTest(wholeFile: File, files: MutableList, javaFilesDir: File?) { val txtFile = File(wholeFile.parentFile, wholeFile.nameWithoutExtension + ".txt") compile(files, javaFilesDir) KotlinTestUtils.assertEqualsToFile(txtFile, BytecodeListingTextCollectingVisitor.getText(classFileFactory)) diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractLightAnalysisModeTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractLightAnalysisModeTest.kt index 0aa9f85ea10..825211b4dda 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractLightAnalysisModeTest.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractLightAnalysisModeTest.kt @@ -26,7 +26,7 @@ abstract class AbstractLightAnalysisModeTest : CodegenTestCase() { } } - override fun doMultiFileTest(wholeFile: File, files: List, javaFilesDir: File?, reportFailures: Boolean) { + override fun doMultiFileTest(wholeFile: File, files: List, javaFilesDir: File?) { for (file in files) { if (file.content.contains("// IGNORE_LIGHT_ANALYSIS")) { return diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractLineNumberTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractLineNumberTest.kt index 4cadf20a00a..eef08db4788 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractLineNumberTest.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractLineNumberTest.kt @@ -29,7 +29,7 @@ import kotlin.collections.ArrayList abstract class AbstractLineNumberTest : CodegenTestCase() { override fun doMultiFileTest( - wholeFile: File, files: MutableList, javaFilesDir: File?, reportFailures: Boolean + wholeFile: File, files: MutableList, javaFilesDir: File? ) { val isCustomTest = wholeFile.parentFile.name.equals("custom", ignoreCase = true) if (!isCustomTest) { @@ -49,10 +49,8 @@ abstract class AbstractLineNumberTest : CodegenTestCase() { KtUsefulTestCase.assertSameElements(actualLineNumbers, expectedLineNumbers) } } catch (e: Throwable) { - if (reportFailures) { - println(classFileFactory.createText()) - throw e - } + println(classFileFactory.createText()) + throw e } } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractScriptCodegenTest.java b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractScriptCodegenTest.java index ee0e7e51dc2..75257a2a7a4 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractScriptCodegenTest.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractScriptCodegenTest.java @@ -20,7 +20,6 @@ import com.intellij.openapi.util.Pair; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.test.ConfigurationKind; -import org.jetbrains.kotlin.test.TargetBackend; import org.jetbrains.kotlin.utils.ExceptionUtilsKt; import java.lang.reflect.Constructor; @@ -34,7 +33,7 @@ public abstract class AbstractScriptCodegenTest extends CodegenTestCase { } @Override - protected void doTest(@NotNull String filename, TargetBackend targetBackend, boolean reportFailures) { + protected void doTest(@NotNull String filename) { loadFileByFullPath(filename); try { diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractTopLevelMembersInvocationTest.java b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractTopLevelMembersInvocationTest.java index 0bde76c0d45..b531acccacf 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractTopLevelMembersInvocationTest.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractTopLevelMembersInvocationTest.java @@ -23,7 +23,10 @@ import kotlin.sequences.SequencesKt; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles; import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment; -import org.jetbrains.kotlin.test.*; +import org.jetbrains.kotlin.test.CompilerTestUtil; +import org.jetbrains.kotlin.test.ConfigurationKind; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.TestJdkKind; import java.io.File; import java.util.Collections; @@ -31,7 +34,7 @@ import java.util.List; public abstract class AbstractTopLevelMembersInvocationTest extends AbstractBytecodeTextTest { @Override - public void doTest(@NotNull String filename, TargetBackend targetBackend, boolean reportFailures) throws Exception { + public void doTest(@NotNull String filename) throws Exception { File root = new File(filename); List sourceFiles = SequencesKt.toList(SequencesKt.map( SequencesKt.filter(FilesKt.walkTopDown(root).maxDepth(1), File::isFile), diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java index e06fcf70e1d..d848b1810fc 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java @@ -34,7 +34,10 @@ import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil; import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.psi.KtFile; import org.jetbrains.kotlin.script.ScriptDependenciesProvider; -import org.jetbrains.kotlin.test.*; +import org.jetbrains.kotlin.test.ConfigurationKind; +import org.jetbrains.kotlin.test.InTextDirectivesUtils; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.TestJdkKind; import org.jetbrains.kotlin.test.clientserver.TestProxy; import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase; import org.jetbrains.kotlin.utils.ExceptionUtilsKt; @@ -394,18 +397,13 @@ public abstract class CodegenTestCase extends KtUsefulTestCase { @NotNull protected GeneratedClassLoader generateAndCreateClassLoader() { - return generateAndCreateClassLoader(true); - } - - @NotNull - protected GeneratedClassLoader generateAndCreateClassLoader(boolean reportProblems) { if (initializedClassLoader != null) { fail("Double initialization of class loader in same test"); } initializedClassLoader = createClassLoader(); - if (!verifyAllFilesWithAsm(generateClassesInFile(reportProblems), initializedClassLoader, reportProblems)) { + if (!verifyAllFilesWithAsm(generateClassesInFile(), initializedClassLoader)) { fail("Verification failed: see exceptions above"); } @@ -488,16 +486,11 @@ public abstract class CodegenTestCase extends KtUsefulTestCase { FqName facadeClassFqName = JvmFileClassUtil.getFileClassInfoNoResolve(myFiles.getPsiFile()).getFacadeClassFqName(); return generateClass(facadeClassFqName.asString()); } - - @NotNull - protected Class generateClass(@NotNull String name) { - return generateClass(name, true); - } @NotNull - protected Class generateClass(@NotNull String name, boolean reportProblems) { + protected Class generateClass(@NotNull String name) { try { - return generateAndCreateClassLoader(reportProblems).loadClass(name); + return generateAndCreateClassLoader().loadClass(name); } catch (ClassNotFoundException e) { fail("No class file was generated for: " + name); @@ -507,11 +500,6 @@ public abstract class CodegenTestCase extends KtUsefulTestCase { @NotNull protected ClassFileFactory generateClassesInFile() { - return generateClassesInFile(true); - } - - @NotNull - protected ClassFileFactory generateClassesInFile(boolean reportProblems) { if (classFileFactory == null) { try { GenerationState generationState = GenerationUtils.compileFiles( @@ -525,26 +513,22 @@ public abstract class CodegenTestCase extends KtUsefulTestCase { } } catch (Throwable e) { - if (reportProblems) { - e.printStackTrace(); - System.err.println("Generating instructions as text..."); - try { - if (classFileFactory == null) { - System.err.println("Cannot generate text: exception was thrown during generation"); - } - else { - System.err.println(classFileFactory.createText()); - } + e.printStackTrace(); + System.err.println("Generating instructions as text..."); + try { + if (classFileFactory == null) { + System.err.println("Cannot generate text: exception was thrown during generation"); } - catch (Throwable e1) { - System.err.println("Exception thrown while trying to generate text, the actual exception follows:"); - e1.printStackTrace(); - System.err.println("-----------------------------------------------------------------------------"); + else { + System.err.println(classFileFactory.createText()); } - fail("See exceptions above"); - } else { - fail("Compilation failure"); } + catch (Throwable e1) { + System.err.println("Exception thrown while trying to generate text, the actual exception follows:"); + e1.printStackTrace(); + System.err.println("-----------------------------------------------------------------------------"); + } + fail("See exceptions above"); } } return classFileFactory; @@ -554,15 +538,15 @@ public abstract class CodegenTestCase extends KtUsefulTestCase { return true; } - protected static boolean verifyAllFilesWithAsm(ClassFileFactory factory, ClassLoader loader, boolean reportProblems) { + protected static boolean verifyAllFilesWithAsm(ClassFileFactory factory, ClassLoader loader) { boolean noErrors = true; for (OutputFile file : ClassFileUtilsKt.getClassFiles(factory)) { - noErrors &= verifyWithAsm(file, loader, reportProblems); + noErrors &= verifyWithAsm(file, loader); } return noErrors; } - private static boolean verifyWithAsm(@NotNull OutputFile file, ClassLoader loader, boolean reportProblems) { + private static boolean verifyWithAsm(@NotNull OutputFile file, ClassLoader loader) { ClassNode classNode = new ClassNode(); new ClassReader(file.asByteArray()).accept(classNode, 0); @@ -576,22 +560,20 @@ public abstract class CodegenTestCase extends KtUsefulTestCase { analyzer.analyze(classNode.name, method); } catch (Throwable e) { - if (reportProblems) { - System.err.println(file.asText()); - System.err.println(classNode.name + "::" + method.name + method.desc); + System.err.println(file.asText()); + System.err.println(classNode.name + "::" + method.name + method.desc); - //noinspection InstanceofCatchParameter - if (e instanceof AnalyzerException) { - // Print the erroneous instruction - TraceMethodVisitor tmv = new TraceMethodVisitor(new Textifier()); - ((AnalyzerException) e).node.accept(tmv); - PrintWriter pw = new PrintWriter(System.err); - tmv.p.print(pw); - pw.flush(); - } - - e.printStackTrace(); + //noinspection InstanceofCatchParameter + if (e instanceof AnalyzerException) { + // Print the erroneous instruction + TraceMethodVisitor tmv = new TraceMethodVisitor(new Textifier()); + ((AnalyzerException) e).node.accept(tmv); + PrintWriter pw = new PrintWriter(System.err); + tmv.p.print(pw); + pw.flush(); } + + e.printStackTrace(); noErrors = false; } } @@ -649,14 +631,6 @@ public abstract class CodegenTestCase extends KtUsefulTestCase { protected void compile( @NotNull List files, @Nullable File javaSourceDir - ) { - compile(files, javaSourceDir, true); - } - - protected void compile( - @NotNull List files, - @Nullable File javaSourceDir, - boolean reportProblems ) { configurationKind = extractConfigurationKind(files); boolean loadAndroidAnnotations = files.stream().anyMatch(it -> @@ -685,7 +659,7 @@ public abstract class CodegenTestCase extends KtUsefulTestCase { loadMultiFiles(files); - generateClassesInFile(reportProblems); + generateClassesInFile(); if (javaSourceDir != null) { // If there are Java files, they should be compiled against the class files produced by Kotlin, so we dump them to the disk @@ -785,14 +759,14 @@ public abstract class CodegenTestCase extends KtUsefulTestCase { } } - protected void doTest(String filePath, TargetBackend targetBackend, boolean reportFailures) throws Exception { + protected void doTest(String filePath) throws Exception { File file = new File(filePath); String expectedText = KotlinTestUtils.doLoadFile(file); Ref javaFilesDir = Ref.create(); List testFiles = createTestFiles(file, expectedText, javaFilesDir, ""); - doMultiFileTest(file, testFiles, javaFilesDir.get(), reportFailures); + doMultiFileTest(file, testFiles, javaFilesDir.get()); } protected void doTestWithCoroutinesPackageReplacement(String filePath, String packageName) throws Exception { @@ -804,7 +778,7 @@ public abstract class CodegenTestCase extends KtUsefulTestCase { List testFiles = createTestFiles(file, expectedText, javaFilesDir, coroutinesPackage); - doMultiFileTest(file, testFiles, javaFilesDir.get(), true); + doMultiFileTest(file, testFiles, javaFilesDir.get()); } @NotNull @@ -839,8 +813,7 @@ public abstract class CodegenTestCase extends KtUsefulTestCase { protected void doMultiFileTest( @NotNull File wholeFile, @NotNull List files, - @Nullable File javaFilesDir, - boolean reportFailures + @Nullable File javaFilesDir ) throws Exception { throw new UnsupportedOperationException("Multi-file test cases are not supported in this test"); } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/defaultConstructor/AbstractDefaultArgumentsReflectionTest.java b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/defaultConstructor/AbstractDefaultArgumentsReflectionTest.java index 7f74bfc8b57..fa035ec3997 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/defaultConstructor/AbstractDefaultArgumentsReflectionTest.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/defaultConstructor/AbstractDefaultArgumentsReflectionTest.java @@ -19,7 +19,6 @@ package org.jetbrains.kotlin.codegen.defaultConstructor; import com.intellij.openapi.util.io.FileUtil; import org.jetbrains.kotlin.codegen.CodegenTestCase; import org.jetbrains.kotlin.test.ConfigurationKind; -import org.jetbrains.kotlin.test.TargetBackend; import java.io.File; import java.io.IOException; @@ -36,7 +35,7 @@ public abstract class AbstractDefaultArgumentsReflectionTest extends CodegenTest } @Override - protected void doTest(String path, TargetBackend targetBackend, boolean reportFailures) throws IOException { + protected void doTest(String path) throws IOException { loadFileByFullPath(path); String fileText = FileUtil.loadFile(new File(path), true); diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/flags/AbstractWriteFlagsTest.java b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/flags/AbstractWriteFlagsTest.java index 6fd59983a7f..30c23f13606 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/flags/AbstractWriteFlagsTest.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/flags/AbstractWriteFlagsTest.java @@ -52,7 +52,7 @@ public abstract class AbstractWriteFlagsTest extends CodegenTestCase { @Override protected void doMultiFileTest( - @NotNull File wholeFile, @NotNull List files, @Nullable File javaFilesDir, boolean reportFailures + @NotNull File wholeFile, @NotNull List files, @Nullable File javaFilesDir ) throws Exception { compile(files, null); diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/ir/AbstractIrBlackBoxAgainstJavaCodegenTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/ir/AbstractIrBlackBoxAgainstJavaCodegenTest.kt index 225af934cee..614fee05553 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/ir/AbstractIrBlackBoxAgainstJavaCodegenTest.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/ir/AbstractIrBlackBoxAgainstJavaCodegenTest.kt @@ -10,6 +10,7 @@ import org.jetbrains.kotlin.codegen.AbstractBlackBoxAgainstJavaCodegenTest import org.jetbrains.kotlin.config.CompilerConfiguration import org.jetbrains.kotlin.config.JVMConfigurationKeys import org.jetbrains.kotlin.test.ConfigurationKind +import java.io.File abstract class AbstractIrBlackBoxAgainstJavaCodegenTest : AbstractBlackBoxAgainstJavaCodegenTest() { diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/ir/AbstractIrGeneratorTestCase.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/ir/AbstractIrGeneratorTestCase.kt index 8f3c6137daf..358e54402b8 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/ir/AbstractIrGeneratorTestCase.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/ir/AbstractIrGeneratorTestCase.kt @@ -42,7 +42,7 @@ import java.io.PrintWriter import java.util.* abstract class AbstractIrGeneratorTestCase : CodegenTestCase() { - override fun doMultiFileTest(wholeFile: File, files: List, javaFilesDir: File?, reportFailures: Boolean) { + override fun doMultiFileTest(wholeFile: File, files: List, javaFilesDir: File?) { setupEnvironment(files, javaFilesDir) loadMultiFiles(files) diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/jvm/compiler/AbstractWriteSignatureTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/jvm/compiler/AbstractWriteSignatureTest.kt index c6c4342ecb2..9abcc957510 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/jvm/compiler/AbstractWriteSignatureTest.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/jvm/compiler/AbstractWriteSignatureTest.kt @@ -16,15 +16,13 @@ import java.util.regex.MatchResult abstract class AbstractWriteSignatureTest : CodegenTestCase() { - override fun doMultiFileTest(wholeFile: File, files: MutableList, javaFilesDir: File?, reportFailures: Boolean) { + override fun doMultiFileTest(wholeFile: File, files: MutableList, javaFilesDir: File?) { compile(files, javaFilesDir) try { parseExpectations(wholeFile).check() } catch (e: Throwable) { - if (reportFailures) { - println(classFileFactory.createText()) - throw e - } + println(classFileFactory.createText()) + throw e } } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java index 456a8db2ddf..673fa64e1b3 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java @@ -106,9 +106,6 @@ public class KotlinTestUtils { private static final boolean DONT_IGNORE_TESTS_WORKING_ON_COMPATIBLE_BACKEND = Boolean.getBoolean("org.jetbrains.kotlin.dont.ignore.tests.working.on.compatible.backend"); - public static final boolean SUPPRESS_EXPECTED_FAILURES = - Boolean.getBoolean("kotlin.suppress.expected.test.failures"); - private static final boolean AUTOMATICALLY_UNMUTE_PASSED_TESTS = false; private static final boolean AUTOMATICALLY_MUTE_FAILED_TESTS = false; @@ -1025,26 +1022,12 @@ public class KotlinTestUtils { void invoke(String filePath) throws Exception; } - // Sometimes we need to pass additional parameters to the test. - // A two-argument function conflicts with ParsingTestGenerated, so let's have three. - public interface DoTest3 { - void invoke(String filePath, TargetBackend targetBackend, boolean reportFailures) throws Exception; - } - // In this test runner version the `testDataFile` parameter is annotated by `TestDataFile`. // So only file paths passed to this parameter will be used in navigation actions, like "Navigate to testdata" and "Related Symbol..." public static void runTest(DoTest test, TargetBackend targetBackend, @TestDataFile String testDataFile) throws Exception { runTest0(test, targetBackend, testDataFile); } - public static void runTest(DoTest3 test, TargetBackend targetBackend, @TestDataFile String testDataFile) throws Exception { - runTest3(test, targetBackend, testDataFile); - } - - public static void runTest0(DoTest test, TargetBackend targetBackend, String testDataFilePath) throws Exception { - runTest3((filePath, targetBackend2, reportFailures) -> test.invoke(filePath), targetBackend, testDataFilePath); - } - // In this test runner version, NONE of the parameters are annotated by `TestDataFile`. // So DevKit will use test name to determine related files in navigation actions, like "Navigate to testdata" and "Related Symbol..." // @@ -1053,7 +1036,7 @@ public class KotlinTestUtils { // Cons: // * sometimes, for too common/general names, it shows many variants to navigate // * it adds an additional step for navigation -- you must choose an exact file to navigate - private static void runTest3(DoTest3 test, TargetBackend targetBackend, String testDataFilePath) throws Exception { + public static void runTest0(DoTest test, TargetBackend targetBackend, String testDataFilePath) throws Exception { File testDataFile = new File(testDataFilePath); boolean isIgnored = isIgnoredTarget(targetBackend, testDataFile); @@ -1065,10 +1048,8 @@ public class KotlinTestUtils { isIgnored &= isIgnoredTarget(targetBackend.getCompatibleWith(), testDataFile); } - boolean reportFailures = !isIgnored || !SUPPRESS_EXPECTED_FAILURES; - try { - test.invoke(testDataFilePath, targetBackend, reportFailures); + test.invoke(testDataFilePath); } catch (Throwable e) { diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxCodegenTestSpec.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxCodegenTestSpec.kt index c9e23f97652..6b202b94ea4 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxCodegenTestSpec.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxCodegenTestSpec.kt @@ -45,7 +45,7 @@ abstract class AbstractBlackBoxCodegenTestSpec : AbstractBlackBoxCodegenTest() { } } - override fun doMultiFileTest(wholeFile: File, files: MutableList, javaFilesDir: File?, reportFailures: Boolean) { + override fun doMultiFileTest(wholeFile: File, files: MutableList, javaFilesDir: File?) { val (specTest, _) = CommonParser.parseSpecTest( wholeFile.canonicalPath, mapOf("main.kt" to FileUtil.loadFile(wholeFile, true)) @@ -55,6 +55,6 @@ abstract class AbstractBlackBoxCodegenTestSpec : AbstractBlackBoxCodegenTest() { includeHelpers(wholeFile, files) - super.doMultiFileTest(wholeFile, files, javaFilesDir, reportFailures) + super.doMultiFileTest(wholeFile, files, javaFilesDir) } } diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/AbstractCustomScriptCodegenTest.kt b/compiler/tests/org/jetbrains/kotlin/codegen/AbstractCustomScriptCodegenTest.kt index cd7ed67f6a3..d816a86a2e0 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/AbstractCustomScriptCodegenTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/codegen/AbstractCustomScriptCodegenTest.kt @@ -41,7 +41,7 @@ abstract class AbstractCustomScriptCodegenTest : CodegenTestCase() { configuration.addJvmClasspathRoots(additionalDependencies.orEmpty()) } - override fun doMultiFileTest(wholeFile: File, files: MutableList, javaFilesDir: File?, reportFailures: Boolean) { + override fun doMultiFileTest(wholeFile: File, files: MutableList, javaFilesDir: File?) { if (files.size > 1) { throw UnsupportedOperationException("Multiple files are not yet supported in this test") } @@ -78,10 +78,8 @@ abstract class AbstractCustomScriptCodegenTest : CodegenTestCase() { val expectedFields = extractAllKeyValPairs(content, "expected:") checkExpectedFields(expectedFields, scriptClass, scriptInstance) } catch (e: Throwable) { - if (reportFailures) { - println(generateToText()) - throw e - } + println(generateToText()) + throw e } } diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/Java9CodegenTest.kt b/compiler/tests/org/jetbrains/kotlin/codegen/Java9CodegenTest.kt index b925f20fe35..41ebc617ccd 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/Java9CodegenTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/codegen/Java9CodegenTest.kt @@ -25,7 +25,7 @@ class Java9CodegenTest : AbstractBlackBoxCodegenTest() { override fun getPrefix(): String = "java9/box" - override fun blackBox(reportFailures: Boolean) { + override fun blackBox() { val tmpdir = KotlinTestUtils.tmpDirForTest(this) generateClassesInFile().writeAll(tmpdir, null) @@ -49,6 +49,6 @@ class Java9CodegenTest : AbstractBlackBoxCodegenTest() { fun testVarHandle() { loadFile() - blackBox(true) + blackBox() } }