IC tests: make exceptions from compiler more visible in tests

otherwise they are easily swallowed by the reporting logic.
This commit was needed to ensure that the problem described in
KT-63665 is reproducible in IC test
But some JS IC logic relies on handling compiler exceptions as a signal
for scope expansions, and the newly introduced exception logging
broke a few tests. To mitigate it, the directive was introduced
to disable exception logging for particular test.
This commit is contained in:
Ilya Chernikov
2023-12-07 17:59:36 +01:00
committed by Space Team
parent 7398f9e4e0
commit 6dfcc927f4
9 changed files with 20 additions and 2 deletions
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
import org.jetbrains.kotlin.cli.common.arguments.parseCommandLineArguments
import org.jetbrains.kotlin.incremental.testingUtils.*
import org.jetbrains.kotlin.incremental.utils.TestCompilationResult
import org.jetbrains.kotlin.test.InTextDirectivesUtils
import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase
import org.junit.Assert
import java.io.File
@@ -79,6 +80,11 @@ abstract class AbstractIncrementalCompilerRunnerTestBase<Args : CommonCompilerAr
fun Iterable<File>.relativePaths() =
map { it.relativeTo(workingDir).path.replace('\\', '/') }
val reportInternalCompilerErrors =
File(testDir, InTextDirectivesUtils.DIRECTIVES_FILE_NAME).takeIf { it.exists() && it.isFile }?.let {
InTextDirectivesUtils.isDirectiveDefined(it.readText(), "// HIDE_INTERNAL_COMPILER_ERRORS")
} != true
val srcDir = File(workingDir, "src").apply { mkdirs() }
val cacheDir = File(workingDir, "incremental-data").apply { mkdirs() }
val outDir = File(workingDir, "out").apply { mkdirs() }
@@ -140,7 +146,12 @@ abstract class AbstractIncrementalCompilerRunnerTestBase<Args : CommonCompilerAr
)
)
actualSB.appendLine(stepLogAsString(step, compiledSources.relativePaths(), compileErrors))
actualSBWithoutErrors.appendLine(stepLogAsString(step, compiledSources.relativePaths(), compileErrors, includeErrors = false))
actualSBWithoutErrors.appendLine(
stepLogAsString(
step, compiledSources.relativePaths(), compileErrors,
includeErrors = reportInternalCompilerErrors && (lastExitCode == ExitCode.INTERNAL_ERROR)
)
)
step++
}
@@ -23,7 +23,7 @@ import java.util.stream.Collectors;
public final class InTextDirectivesUtils {
private static final String DIRECTIVES_FILE_NAME = "directives.txt";
public static final String DIRECTIVES_FILE_NAME = "directives.txt";
public static final String IGNORE_BACKEND_DIRECTIVE_PREFIX = "// IGNORE_BACKEND: ";
public static final String IGNORE_BACKEND_K1_DIRECTIVE_PREFIX = "// IGNORE_BACKEND_K1: ";
@@ -0,0 +1 @@
// HIDE_INTERNAL_COMPILER_ERRORS
@@ -0,0 +1 @@
// HIDE_INTERNAL_COMPILER_ERRORS
@@ -0,0 +1 @@
// HIDE_INTERNAL_COMPILER_ERRORS
@@ -0,0 +1 @@
// HIDE_INTERNAL_COMPILER_ERRORS
@@ -0,0 +1 @@
// HIDE_INTERNAL_COMPILER_ERRORS
@@ -0,0 +1 @@
// HIDE_INTERNAL_COMPILER_ERRORS
@@ -0,0 +1 @@
// HIDE_INTERNAL_COMPILER_ERRORS