From f05c972efb1a101357bef360e4776b462020ea9b Mon Sep 17 00:00:00 2001 From: "Evgeniy.Zhelenskiy" Date: Fri, 12 Jan 2024 03:08:09 +0100 Subject: [PATCH] [K2, CLI] Support endOffset in Kotlin CLI Duplicated messages in testdata appeared because default renderer renders diagnostic spans ambiguously. It shows only start position. In fact, there are 3 failures, 2 of them distinguish only by the diagnostic end offset. See youtrack for more information. The issue about inconvenient rendering is KT-64989. #KT-64608 --- .../FirDiagnosticsCompilerResultsReporter.kt | 32 ++++++-- .../againstFirWithUnstableAbi/output.fir.txt | 3 + .../againstUnstable/output.fir.txt | 3 + .../wrongMetadataVersion/output.fir.txt | 4 + .../output.fir.txt | 4 + .../jetbrains/kotlin/cli/AbstractCliTest.java | 16 +++- .../jetbrains/kotlin/test/CompilerTestUtil.kt | 19 +++-- .../cli/AnalysisHandlerExtensionTest.kt | 4 +- .../org/jetbrains/kotlin/cli/CustomCliTest.kt | 74 ++++++++++++++++++- .../jetbrains/kotlin/cli/FriendPathsTest.kt | 8 +- .../kotlin/codegen/JvmModuleProtoBufTest.kt | 7 +- .../JsIrAnalysisHandlerExtensionTest.kt | 8 +- 12 files changed, 154 insertions(+), 28 deletions(-) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/common/fir/FirDiagnosticsCompilerResultsReporter.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/common/fir/FirDiagnosticsCompilerResultsReporter.kt index ee7d882c19d..1249b313eb3 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/common/fir/FirDiagnosticsCompilerResultsReporter.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/common/fir/FirDiagnosticsCompilerResultsReporter.kt @@ -16,6 +16,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors import java.io.Closeable import java.io.File import java.io.InputStreamReader +import java.util.TreeSet object FirDiagnosticsCompilerResultsReporter { fun reportToMessageCollector( @@ -54,7 +55,23 @@ object FirDiagnosticsCompilerResultsReporter { } try { - for (diagnostic in diagnosticsCollector.diagnosticsByFilePath[filePath].orEmpty().sortedWith(InFileDiagnosticsComparator)) { + val diagnosticList = diagnosticsCollector.diagnosticsByFilePath[filePath].orEmpty() + + // Precomputing positions of the offsets in the ascending order of the offsets + val offsetsToPositions = positionFinder.value?.let { finder -> + val sortedOffsets = TreeSet().apply { + for (diagnostic in diagnosticList) { + if (diagnostic !is KtPsiDiagnostic) { + val range = DiagnosticUtils.firstRange(diagnostic.textRanges) + add(range.startOffset) + add(range.endOffset) + } + } + } + sortedOffsets.associateWith { finder.findNextPosition(it) } + } + + for (diagnostic in diagnosticList.sortedWith(InFileDiagnosticsComparator)) { when (diagnostic) { is KtPsiDiagnostic -> { val file = diagnostic.element.psi.containingFile @@ -68,11 +85,14 @@ object FirDiagnosticsCompilerResultsReporter { // TODO: bring KtSourceFile and KtSourceFileLinesMapping here and rewrite reporting via it to avoid code duplication // NOTE: SequentialPositionFinder relies on the ascending order of the input offsets, so the code relies // on the the appropriate sorting above - // Also the end offset is ignored, as it is irrelevant for the CLI reporting - positionFinder.value?.findNextPosition(DiagnosticUtils.firstRange(diagnostic.textRanges).startOffset) - ?.let { pos -> - MessageUtil.createMessageLocation(filePath, pos.lineContent, pos.line, pos.column, -1, -1) - } + offsetsToPositions?.let { + val range = DiagnosticUtils.firstRange(diagnostic.textRanges) + val start = offsetsToPositions[range.startOffset]!! + val end = offsetsToPositions[range.endOffset]!! + MessageUtil.createMessageLocation( + filePath, start.lineContent, start.line, start.column, end.line, end.column + ) + } } }?.let { location -> report(diagnostic, location) diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/againstFirWithUnstableAbi/output.fir.txt b/compiler/testData/compileKotlinAgainstCustomBinaries/againstFirWithUnstableAbi/output.fir.txt index e716bd0bacb..5de5d66710d 100644 --- a/compiler/testData/compileKotlinAgainstCustomBinaries/againstFirWithUnstableAbi/output.fir.txt +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/againstFirWithUnstableAbi/output.fir.txt @@ -5,4 +5,7 @@ compiler/testData/compileKotlinAgainstCustomBinaries/againstFirWithUnstableAbi/s compiler/testData/compileKotlinAgainstCustomBinaries/againstFirWithUnstableAbi/source.kt:4:11: error: class 'lib.Box' is compiled by an unstable version of the Kotlin compiler and cannot be loaded by this compiler. get { Box("OK").value } ^ +compiler/testData/compileKotlinAgainstCustomBinaries/againstFirWithUnstableAbi/source.kt:4:11: error: class 'lib.Box' is compiled by an unstable version of the Kotlin compiler and cannot be loaded by this compiler. + get { Box("OK").value } + ^ COMPILATION_ERROR diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/againstUnstable/output.fir.txt b/compiler/testData/compileKotlinAgainstCustomBinaries/againstUnstable/output.fir.txt index f7228ced1e0..e5b5a5a7d34 100644 --- a/compiler/testData/compileKotlinAgainstCustomBinaries/againstUnstable/output.fir.txt +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/againstUnstable/output.fir.txt @@ -5,4 +5,7 @@ compiler/testData/compileKotlinAgainstCustomBinaries/againstUnstable/source.kt:4 compiler/testData/compileKotlinAgainstCustomBinaries/againstUnstable/source.kt:4:11: error: class 'lib.Box' is compiled by an unstable version of the Kotlin compiler and cannot be loaded by this compiler. get { Box("OK").value } ^ +compiler/testData/compileKotlinAgainstCustomBinaries/againstUnstable/source.kt:4:11: error: class 'lib.Box' is compiled by an unstable version of the Kotlin compiler and cannot be loaded by this compiler. + get { Box("OK").value } + ^ COMPILATION_ERROR diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersion/output.fir.txt b/compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersion/output.fir.txt index 3aa27a636b8..c8b51b84162 100644 --- a/compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersion/output.fir.txt +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersion/output.fir.txt @@ -17,6 +17,10 @@ The class is loaded from $TMP_DIR$/library-after.jar!/a/A$Nested.class val nested = A.Nested() ^ compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersion/source.kt:8:22: error: class 'a.A' was compiled with an incompatible version of Kotlin. The actual metadata version is 42.0.0, but the compiler version $ABI_VERSION$ can read versions up to $ABI_VERSION_NEXT$. +The class is loaded from $TMP_DIR$/library-after.jar!/a/A.class + val methodCall = param.method() + ^ +compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersion/source.kt:8:22: error: class 'a.A' was compiled with an incompatible version of Kotlin. The actual metadata version is 42.0.0, but the compiler version $ABI_VERSION$ can read versions up to $ABI_VERSION_NEXT$. The class is loaded from $TMP_DIR$/library-after.jar!/a/A.class val methodCall = param.method() ^ diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionSkipPrereleaseCheckHasNoEffect/output.fir.txt b/compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionSkipPrereleaseCheckHasNoEffect/output.fir.txt index 8c48d1d372a..d4af4526a4a 100644 --- a/compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionSkipPrereleaseCheckHasNoEffect/output.fir.txt +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionSkipPrereleaseCheckHasNoEffect/output.fir.txt @@ -17,6 +17,10 @@ The class is loaded from $TMP_DIR$/library-after.jar!/a/A$Nested.class val nested = A.Nested() ^ compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionSkipPrereleaseCheckHasNoEffect/source.kt:8:22: error: class 'a.A' was compiled with an incompatible version of Kotlin. The actual metadata version is 42.0.0, but the compiler version $ABI_VERSION$ can read versions up to $ABI_VERSION_NEXT$. +The class is loaded from $TMP_DIR$/library-after.jar!/a/A.class + val methodCall = param.method() + ^ +compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionSkipPrereleaseCheckHasNoEffect/source.kt:8:22: error: class 'a.A' was compiled with an incompatible version of Kotlin. The actual metadata version is 42.0.0, but the compiler version $ABI_VERSION$ can read versions up to $ABI_VERSION_NEXT$. The class is loaded from $TMP_DIR$/library-after.jar!/a/A.class val methodCall = param.method() ^ diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/cli/AbstractCliTest.java b/compiler/tests-common/tests/org/jetbrains/kotlin/cli/AbstractCliTest.java index 5679c3e98fd..2b83e136c99 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/cli/AbstractCliTest.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/cli/AbstractCliTest.java @@ -30,6 +30,7 @@ import org.jetbrains.kotlin.cli.common.CLITool; import org.jetbrains.kotlin.cli.common.CompilerSystemProperties; import org.jetbrains.kotlin.cli.common.ExitCode; import org.jetbrains.kotlin.cli.common.Usage; +import org.jetbrains.kotlin.cli.common.messages.MessageRenderer; import org.jetbrains.kotlin.cli.js.K2JSCompiler; import org.jetbrains.kotlin.cli.js.dce.K2JSDce; import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler; @@ -62,7 +63,18 @@ public abstract class AbstractCliTest extends TestCaseWithTmpdir { private static final String BUILD_FILE_ARGUMENT_PREFIX = "-Xbuild-file="; - public static Pair executeCompilerGrabOutput(@NotNull CLITool compiler, @NotNull List args) { + public static Pair executeCompilerGrabOutput( + @NotNull CLITool compiler, + @NotNull List args + ) { + return executeCompilerGrabOutput(compiler, args, null); + } + + public static Pair executeCompilerGrabOutput( + @NotNull CLITool compiler, + @NotNull List args, + @Nullable MessageRenderer messageRenderer + ) { StringBuilder output = new StringBuilder(); int index = 0; @@ -73,7 +85,7 @@ public abstract class AbstractCliTest extends TestCaseWithTmpdir { } else { next = index + next; } - Pair pair = CompilerTestUtil.executeCompiler(compiler, args.subList(index, next)); + Pair pair = CompilerTestUtil.executeCompiler(compiler, args.subList(index, next), messageRenderer); output.append(pair.getFirst()); if (pair.getSecond() != ExitCode.OK) { return new Pair<>(output.toString(), pair.getSecond()); diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/CompilerTestUtil.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/test/CompilerTestUtil.kt index 9f368d1db1d..bfec02f3306 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/CompilerTestUtil.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/CompilerTestUtil.kt @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.test import org.jetbrains.kotlin.cli.common.CLITool import org.jetbrains.kotlin.cli.common.ExitCode +import org.jetbrains.kotlin.cli.common.messages.MessageRenderer import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler import org.jetbrains.kotlin.test.util.KtTestUtil import java.io.ByteArrayOutputStream @@ -27,21 +28,22 @@ import kotlin.test.assertEquals object CompilerTestUtil { @JvmStatic - fun executeCompilerAssertSuccessful(compiler: CLITool<*>, args: List) { - val (output, exitCode) = executeCompiler(compiler, args) + fun executeCompilerAssertSuccessful(compiler: CLITool<*>, args: List, messageRenderer: MessageRenderer? = null) { + val (output, exitCode) = executeCompiler(compiler, args, messageRenderer) assertEquals(ExitCode.OK, exitCode, output) } @JvmStatic - fun executeCompiler(compiler: CLITool<*>, args: List): Pair { + fun executeCompiler(compiler: CLITool<*>, args: List, messageRenderer: MessageRenderer? = null): Pair { val bytes = ByteArrayOutputStream() val origErr = System.err try { System.setErr(PrintStream(bytes)) - val exitCode = CLITool.doMainNoExit(compiler, args.toTypedArray()) + val exitCode = + if (messageRenderer == null) CLITool.doMainNoExit(compiler, args.toTypedArray()) + else CLITool.doMainNoExit(compiler, args.toTypedArray(), messageRenderer) return Pair(String(bytes.toByteArray()), exitCode) - } - finally { + } finally { System.setErr(origErr) } } @@ -52,7 +54,8 @@ object CompilerTestUtil { src: File, libraryName: String = "library", extraOptions: List = emptyList(), - extraClasspath: List = emptyList() + extraClasspath: List = emptyList(), + messageRenderer: MessageRenderer? = null, ): File { val destination = File(KtTestUtil.tmpDir("testLibrary"), "$libraryName.jar") val args = mutableListOf().apply { @@ -65,7 +68,7 @@ object CompilerTestUtil { } addAll(extraOptions) } - executeCompilerAssertSuccessful(K2JVMCompiler(), args) + executeCompilerAssertSuccessful(K2JVMCompiler(), args, messageRenderer) return destination } } diff --git a/compiler/tests/org/jetbrains/kotlin/cli/AnalysisHandlerExtensionTest.kt b/compiler/tests/org/jetbrains/kotlin/cli/AnalysisHandlerExtensionTest.kt index 17d50449c5c..c2842700ce7 100644 --- a/compiler/tests/org/jetbrains/kotlin/cli/AnalysisHandlerExtensionTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/cli/AnalysisHandlerExtensionTest.kt @@ -12,6 +12,7 @@ import com.intellij.openapi.project.Project import org.jetbrains.kotlin.analyzer.AnalysisResult import org.jetbrains.kotlin.cli.common.CLITool import org.jetbrains.kotlin.cli.common.ExitCode +import org.jetbrains.kotlin.cli.common.messages.MessageRenderer import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler import org.jetbrains.kotlin.cli.metadata.K2MetadataCompiler import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar @@ -59,6 +60,7 @@ class AnalysisHandlerExtensionTest : TestCaseWithTmpdir() { klass: KClass, expectedExitCode: ExitCode = ExitCode.OK, extras: List = emptyList(), + messageRenderer: MessageRenderer? = null, ) { val mainKt = tmpdir.resolve(src.name).apply { writeText(src.content) @@ -70,7 +72,7 @@ class AnalysisHandlerExtensionTest : TestCaseWithTmpdir() { "-d", tmpdir.resolve("out").absolutePath ) - val (output, exitCode) = CompilerTestUtil.executeCompiler(compiler, args + outputPath + extras) + val (output, exitCode) = CompilerTestUtil.executeCompiler(compiler, args + outputPath + extras, messageRenderer) assertEquals(expectedExitCode, exitCode, output) } diff --git a/compiler/tests/org/jetbrains/kotlin/cli/CustomCliTest.kt b/compiler/tests/org/jetbrains/kotlin/cli/CustomCliTest.kt index 1c7201ff2ec..11150bb9cfa 100644 --- a/compiler/tests/org/jetbrains/kotlin/cli/CustomCliTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/cli/CustomCliTest.kt @@ -5,6 +5,9 @@ package org.jetbrains.kotlin.cli +import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity +import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSourceLocation +import org.jetbrains.kotlin.cli.common.messages.MessageRenderer import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler import org.jetbrains.kotlin.test.CompilerTestUtil import org.jetbrains.kotlin.test.TestCaseWithTmpdir @@ -104,15 +107,78 @@ class CustomCliTest : TestCaseWithTmpdir() { compileAndCheckMainClass(listOf(mainKt), expectedMainClass = null) } - private fun compileAndCheckMainClass(sourceFiles: List, expectedMainClass: String?) { + private fun makeCompilerArgs(sourceFiles: List, jarFile: File): List { + // TODO: remove explicit version after implementing main fun detector (KT-44557) + return listOf("-language-version", "1.9", "-include-runtime", "-d", jarFile.absolutePath) + sourceFiles.map { it.absolutePath } + } + + private fun compileAndCheckMainClass(sourceFiles: List, expectedMainClass: String?, messageRenderer: MessageRenderer? = null) { val jarFile = tmpdir.resolve("output.jar") - // TODO: remove explicit verion after implementing main fun detector (KT-44557) - val args = listOf("-language-version", "1.9", "-include-runtime", "-d", jarFile.absolutePath) + sourceFiles.map { it.absolutePath } - CompilerTestUtil.executeCompilerAssertSuccessful(K2JVMCompiler(), args) + val args = makeCompilerArgs(sourceFiles, jarFile) + CompilerTestUtil.executeCompilerAssertSuccessful(K2JVMCompiler(), args, messageRenderer) JarFile(jarFile).use { val mainClassAttr = it.manifest.mainAttributes.getValue("Main-Class") Assert.assertEquals(expectedMainClass, mainClassAttr) } } + + private fun compileAndGetDiagnostics(sourceFiles: List): List { + val jarFile = tmpdir.resolve("output.jar") + val args = makeCompilerArgs(sourceFiles, jarFile) + val diagnostics = mutableListOf() + CompilerTestUtil.executeCompiler(K2JVMCompiler(), args, LoggingMessageRenderer(diagnostics)) + return diagnostics + } + + + private data class Diagnostic( + val severity: CompilerMessageSeverity, + val message: String, + val location: CompilerMessageSourceLocation? + ) + + private class LoggingMessageRenderer(val diagnostics: MutableList) : MessageRenderer { + override fun renderPreamble(): String = "" + + override fun render( + severity: CompilerMessageSeverity, + message: String, + location: CompilerMessageSourceLocation? + ): String { + diagnostics.add(Diagnostic(severity, message, location)) + return "" + } + + override fun renderUsage(usage: String): String = + render(CompilerMessageSeverity.STRONG_WARNING, usage, null) + + override fun renderConclusion(): String = "" + + override fun getName(): String = "Redirector" + } + + fun testDiagnosticRanges() { + val mainKt = tmpdir.resolve("main.kt").apply { + val quotes = "\"".repeat(3) + writeText( + """ + |fun main(args: Array) { + | val x: Int = $quotes + | some + | multiline + | string + | $quotes + |}""".trimMargin() + ) + } + + val diagnostics = compileAndGetDiagnostics(listOf(mainKt)) + require(diagnostics.size == 1) { "Expected 1 diagnostic, but found ${diagnostics.size}:\n${diagnostics.joinToString("\n")}" } + val diagnostic = diagnostics.single() + assertEquals(2, diagnostic.location?.line) + assertEquals(18, diagnostic.location?.column) + assertEquals(6, diagnostic.location?.lineEnd) + assertEquals(8, diagnostic.location?.columnEnd) + } } diff --git a/compiler/tests/org/jetbrains/kotlin/cli/FriendPathsTest.kt b/compiler/tests/org/jetbrains/kotlin/cli/FriendPathsTest.kt index 543f0771901..433b7f959bc 100644 --- a/compiler/tests/org/jetbrains/kotlin/cli/FriendPathsTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/cli/FriendPathsTest.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.cli +import org.jetbrains.kotlin.cli.common.messages.MessageRenderer import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler import org.jetbrains.kotlin.test.CompilerTestUtil import org.jetbrains.kotlin.test.TestCaseWithTmpdir @@ -42,16 +43,17 @@ class FriendPathsTest : TestCaseWithTmpdir() { doTestFriendPaths(File(tmpdir, "lib").relativeTo(File("").absoluteFile)) } - private fun doTestFriendPaths(libDest: File) { + private fun doTestFriendPaths(libDest: File, messageRenderer: MessageRenderer? = null) { val libSrc = File(getTestDataDirectory(), "lib.kt") - CompilerTestUtil.executeCompilerAssertSuccessful(K2JVMCompiler(), listOf("-d", libDest.path, libSrc.path)) + CompilerTestUtil.executeCompilerAssertSuccessful(K2JVMCompiler(), listOf("-d", libDest.path, libSrc.path), messageRenderer) CompilerTestUtil.executeCompilerAssertSuccessful( K2JVMCompiler(), listOf( "-d", tmpdir.path, "-cp", libDest.path, File(getTestDataDirectory(), "usage.kt").path, "-Xfriend-paths=${libDest.path}" - ) + ), + messageRenderer, ) } } diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/JvmModuleProtoBufTest.kt b/compiler/tests/org/jetbrains/kotlin/codegen/JvmModuleProtoBufTest.kt index be4deadbc3a..6c4cdc06079 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/JvmModuleProtoBufTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/codegen/JvmModuleProtoBufTest.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.codegen +import org.jetbrains.kotlin.cli.common.messages.MessageRenderer import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler import org.jetbrains.kotlin.config.ApiVersion import org.jetbrains.kotlin.config.LanguageVersion @@ -34,7 +35,8 @@ class JvmModuleProtoBufTest : KtUsefulTestCase() { relativeDirectory: String, compileWith: LanguageVersion = LanguageVersion.LATEST_STABLE, loadWith: LanguageVersion = LanguageVersion.LATEST_STABLE, - extraOptions: List = emptyList() + extraOptions: List = emptyList(), + messageRenderer: MessageRenderer? = null, ) { val directory = KtTestUtil.getTestDataPathBase() + relativeDirectory val tmpdir = KtTestUtil.tmpDir(this::class.simpleName) @@ -46,7 +48,8 @@ class JvmModuleProtoBufTest : KtUsefulTestCase() { "-d", tmpdir.path, "-module-name", moduleName, "-language-version", compileWith.versionString - ) + extraOptions + ) + extraOptions, + messageRenderer ) val mapping = ModuleMapping.loadModuleMapping( diff --git a/js/js.tests/test/org/jetbrains/kotlin/integration/JsIrAnalysisHandlerExtensionTest.kt b/js/js.tests/test/org/jetbrains/kotlin/integration/JsIrAnalysisHandlerExtensionTest.kt index 44ec191a892..b1464f4dfed 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/integration/JsIrAnalysisHandlerExtensionTest.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/integration/JsIrAnalysisHandlerExtensionTest.kt @@ -11,6 +11,7 @@ import com.intellij.mock.MockProject import com.intellij.openapi.project.Project import org.jetbrains.kotlin.analyzer.AnalysisResult import org.jetbrains.kotlin.cli.common.CLITool +import org.jetbrains.kotlin.cli.common.messages.MessageRenderer import org.jetbrains.kotlin.cli.js.K2JSCompiler import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar import org.jetbrains.kotlin.config.CompilerConfiguration @@ -60,7 +61,10 @@ class JsIrAnalysisHandlerExtensionTest : TestCaseWithTmpdir() { private val outklib: String get() = tmpdir.resolve("out.klib").absolutePath - private fun runTest(compiler: CLITool<*>, src: TestKtFile, libs: String, outFile: String, extras: List = emptyList()) { + private fun runTest( + compiler: CLITool<*>, src: TestKtFile, libs: String, outFile: String, extras: List = emptyList(), + messageRenderer: MessageRenderer? = null, + ) { val mainKt = tmpdir.resolve(src.name).apply { writeText(src.content) } @@ -74,7 +78,7 @@ class JsIrAnalysisHandlerExtensionTest : TestCaseWithTmpdir() { "-language-version", "1.9", mainKt.absolutePath ) - CompilerTestUtil.executeCompilerAssertSuccessful(compiler, args + extras) + CompilerTestUtil.executeCompilerAssertSuccessful(compiler, args + extras, messageRenderer) } fun testShouldNotGenerateCodeJs() {