diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionJs/output.txt b/compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionJs/output.txt index f5558cfe828..c994a64d06d 100644 --- a/compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionJs/output.txt +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionJs/output.txt @@ -1,2 +1,2 @@ -error: file '$TMP_DIR$/library.meta.js' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 42.0.0, expected version is 1.0.0 -COMPILATION_ERROR \ No newline at end of file +error: file '$TMP_DIR$/library.meta.js' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 42.0.0, expected version is $ABI_VERSION$ +COMPILATION_ERROR diff --git a/compiler/tests/org/jetbrains/kotlin/cli/AbstractCliTest.java b/compiler/tests/org/jetbrains/kotlin/cli/AbstractCliTest.java index 0b2f022b883..f26ce3676e9 100644 --- a/compiler/tests/org/jetbrains/kotlin/cli/AbstractCliTest.java +++ b/compiler/tests/org/jetbrains/kotlin/cli/AbstractCliTest.java @@ -31,7 +31,6 @@ import org.jetbrains.kotlin.cli.js.K2JSCompiler; import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler; import org.jetbrains.kotlin.config.KotlinCompilerVersion; import org.jetbrains.kotlin.load.kotlin.JvmMetadataVersion; -import org.jetbrains.kotlin.serialization.deserialization.BinaryVersion; import org.jetbrains.kotlin.test.InTextDirectivesUtils; import org.jetbrains.kotlin.test.KotlinTestUtils; import org.jetbrains.kotlin.test.TestCaseWithTmpdir; @@ -67,18 +66,14 @@ public abstract class AbstractCliTest extends TestCaseWithTmpdir { } @NotNull - public static String getNormalizedCompilerOutput( - @NotNull String pureOutput, - @NotNull ExitCode exitCode, - @NotNull String testDataDir, - @NotNull BinaryVersion version - ) { + public static String getNormalizedCompilerOutput(@NotNull String pureOutput, @NotNull ExitCode exitCode, @NotNull String testDataDir) { String testDataAbsoluteDir = new File(testDataDir).getAbsolutePath(); String normalizedOutputWithoutExitCode = StringUtil.convertLineSeparators(pureOutput) .replace(testDataAbsoluteDir, "$TESTDATA_DIR$") .replace(FileUtil.toSystemIndependentName(testDataAbsoluteDir), "$TESTDATA_DIR$") .replace(PathUtil.getKotlinPathsForDistDirectory().getHomePath().getAbsolutePath(), "$PROJECT_DIR$") - .replace("expected version is " + version, "expected version is $ABI_VERSION$") + .replace("expected version is " + JvmMetadataVersion.INSTANCE, "expected version is $ABI_VERSION$") + .replace("expected version is " + JsMetadataVersion.INSTANCE, "expected version is $ABI_VERSION$") .replace("\\", "/") .replaceAll("^.+running the Kotlin compiler under Java 6 or 7 is unsupported and will no longer be possible in a future update\\.\n", "") .replace(KotlinCompilerVersion.VERSION, "$VERSION$"); @@ -86,11 +81,11 @@ public abstract class AbstractCliTest extends TestCaseWithTmpdir { return normalizedOutputWithoutExitCode + exitCode; } - private void doTest(@NotNull String fileName, @NotNull CLICompiler compiler, BinaryVersion version) throws Exception { + private void doTest(@NotNull String fileName, @NotNull CLICompiler compiler) throws Exception { System.setProperty("java.awt.headless", "true"); Pair outputAndExitCode = executeCompilerGrabOutput(compiler, readArgs(fileName, tmpdir.getPath())); String actual = getNormalizedCompilerOutput( - outputAndExitCode.getFirst(), outputAndExitCode.getSecond(), new File(fileName).getParent(), version + outputAndExitCode.getFirst(), outputAndExitCode.getSecond(), new File(fileName).getParent() ); File outFile = new File(fileName.replaceFirst("\\.args$", ".out")); @@ -156,11 +151,11 @@ public abstract class AbstractCliTest extends TestCaseWithTmpdir { } protected void doJvmTest(@NotNull String fileName) throws Exception { - doTest(fileName, new K2JVMCompiler(), JvmMetadataVersion.INSTANCE); + doTest(fileName, new K2JVMCompiler()); } protected void doJsTest(@NotNull String fileName) throws Exception { - doTest(fileName, new K2JSCompiler(), JsMetadataVersion.INSTANCE); + doTest(fileName, new K2JSCompiler()); } public static String removePerfOutput(String output) { diff --git a/compiler/tests/org/jetbrains/kotlin/cli/WrongBytecodeVersionTest.kt b/compiler/tests/org/jetbrains/kotlin/cli/WrongBytecodeVersionTest.kt index 2d47ba92894..2ce63466b6b 100644 --- a/compiler/tests/org/jetbrains/kotlin/cli/WrongBytecodeVersionTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/cli/WrongBytecodeVersionTest.kt @@ -22,6 +22,7 @@ import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler import org.jetbrains.kotlin.jvm.compiler.LoadDescriptorUtil import org.jetbrains.kotlin.load.java.JvmAnnotationNames import org.jetbrains.kotlin.load.java.JvmBytecodeBinaryVersion +import org.jetbrains.kotlin.load.kotlin.JvmMetadataVersion import org.jetbrains.kotlin.test.KotlinTestUtils import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase import org.jetbrains.org.objectweb.asm.* @@ -54,7 +55,8 @@ class WrongBytecodeVersionTest : KtUsefulTestCase() { assertEquals("Compilation error expected", ExitCode.COMPILATION_ERROR, exitCode) - val normalized = AbstractCliTest.getNormalizedCompilerOutput(output, exitCode, tmpdir.path, JvmBytecodeBinaryVersion.INSTANCE) + val normalized = AbstractCliTest.getNormalizedCompilerOutput(output, exitCode, tmpdir.path) + .replace("expected version is ${JvmBytecodeBinaryVersion.INSTANCE}", "expected version is \$ABI_VERSION\$") KotlinTestUtils.assertEqualsToFile(File(directory, "output.txt"), normalized) } diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.java b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.java index 7963821cda0..88af79c3d0f 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.java +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.java @@ -109,9 +109,8 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir { @NotNull private String normalizeOutput(@NotNull Pair output) { - return AbstractCliTest.getNormalizedCompilerOutput( - output.getFirst(), output.getSecond(), getTestDataDirectory().getPath(), JvmMetadataVersion.INSTANCE - ).replace(FileUtil.toSystemIndependentName(tmpdir.getAbsolutePath()), "$TMP_DIR$"); + return AbstractCliTest.getNormalizedCompilerOutput(output.getFirst(), output.getSecond(), getTestDataDirectory().getPath()) + .replace(FileUtil.toSystemIndependentName(tmpdir.getAbsolutePath()), "$TMP_DIR$"); } private void doTestWithTxt(@NotNull File... extraClassPath) throws Exception {