From 9de6df61047b37195185bc3c52bdbad0e8c5e017 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Fri, 11 Aug 2023 23:21:40 +0200 Subject: [PATCH] Tests: improve logic of replacing versions with templates To slightly reduce the number of test data that needs to be changed when Kotlin switches to a new language version. --- .../output.txt | 10 +++++----- .../org/jetbrains/kotlin/cli/AbstractCliTest.java | 8 +++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/strictMetadataVersionSemanticsOldVersion/output.txt b/compiler/testData/compileKotlinAgainstCustomBinaries/strictMetadataVersionSemanticsOldVersion/output.txt index dde593cbc07..07421b80919 100644 --- a/compiler/testData/compileKotlinAgainstCustomBinaries/strictMetadataVersionSemanticsOldVersion/output.txt +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/strictMetadataVersionSemanticsOldVersion/output.txt @@ -1,6 +1,6 @@ error: incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors -$TMP_DIR$/library.jar!/META-INF/main.kotlin_module: error: module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.0.0, expected version is $ABI_VERSION$. -compiler/testData/compileKotlinAgainstCustomBinaries/strictMetadataVersionSemanticsOldVersion/source.kt:3:13: error: class 'a.C' was compiled with an incompatible version of Kotlin. The actual metadata version is 2.0.0, but the compiler version $ABI_VERSION$ can read versions up to $ABI_VERSION$. +$TMP_DIR$/library.jar!/META-INF/main.kotlin_module: error: module was compiled with an incompatible version of Kotlin. The binary version of its metadata is $ABI_VERSION_NEXT$, expected version is $ABI_VERSION$. +compiler/testData/compileKotlinAgainstCustomBinaries/strictMetadataVersionSemanticsOldVersion/source.kt:3:13: error: class 'a.C' was compiled with an incompatible version of Kotlin. The actual metadata version is $ABI_VERSION_NEXT$, but the compiler version $ABI_VERSION$ can read versions up to $ABI_VERSION$. The class is loaded from $TMP_DIR$/library.jar!/a/C.class fun test(c: C) { ^ @@ -10,15 +10,15 @@ compiler/testData/compileKotlinAgainstCustomBinaries/strictMetadataVersionSemant compiler/testData/compileKotlinAgainstCustomBinaries/strictMetadataVersionSemanticsOldVersion/source.kt:5:5: error: unresolved reference: v v ^ -compiler/testData/compileKotlinAgainstCustomBinaries/strictMetadataVersionSemanticsOldVersion/source.kt:6:5: error: class 'a.C' was compiled with an incompatible version of Kotlin. The actual metadata version is 2.0.0, but the compiler version $ABI_VERSION$ can read versions up to $ABI_VERSION$. +compiler/testData/compileKotlinAgainstCustomBinaries/strictMetadataVersionSemanticsOldVersion/source.kt:6:5: error: class 'a.C' was compiled with an incompatible version of Kotlin. The actual metadata version is $ABI_VERSION_NEXT$, but the compiler version $ABI_VERSION$ can read versions up to $ABI_VERSION$. The class is loaded from $TMP_DIR$/library.jar!/a/C.class c.let { C() } ^ -compiler/testData/compileKotlinAgainstCustomBinaries/strictMetadataVersionSemanticsOldVersion/source.kt:6:7: error: class 'a.C' was compiled with an incompatible version of Kotlin. The actual metadata version is 2.0.0, but the compiler version $ABI_VERSION$ can read versions up to $ABI_VERSION$. +compiler/testData/compileKotlinAgainstCustomBinaries/strictMetadataVersionSemanticsOldVersion/source.kt:6:7: error: class 'a.C' was compiled with an incompatible version of Kotlin. The actual metadata version is $ABI_VERSION_NEXT$, but the compiler version $ABI_VERSION$ can read versions up to $ABI_VERSION$. The class is loaded from $TMP_DIR$/library.jar!/a/C.class c.let { C() } ^ -compiler/testData/compileKotlinAgainstCustomBinaries/strictMetadataVersionSemanticsOldVersion/source.kt:6:13: error: class 'a.C' was compiled with an incompatible version of Kotlin. The actual metadata version is 2.0.0, but the compiler version $ABI_VERSION$ can read versions up to $ABI_VERSION$. +compiler/testData/compileKotlinAgainstCustomBinaries/strictMetadataVersionSemanticsOldVersion/source.kt:6:13: error: class 'a.C' was compiled with an incompatible version of Kotlin. The actual metadata version is $ABI_VERSION_NEXT$, but the compiler version $ABI_VERSION$ can read versions up to $ABI_VERSION$. The class is loaded from $TMP_DIR$/library.jar!/a/C.class c.let { C() } ^ 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 337c9c32923..32ad065b02f 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/cli/AbstractCliTest.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/cli/AbstractCliTest.java @@ -102,11 +102,9 @@ public abstract class AbstractCliTest extends TestCaseWithTmpdir { .replace(org.jetbrains.kotlin.konan.file.File.Companion.getUserDir().getAbsolutePath(), "$USER_DIR$") .replace(tmpDirAbsoluteDir, "$TMP_DIR$") .replaceAll("info: executable production duration: \\d+ms", "info: executable production duration: [time]") - .replace("expected version is " + JvmMetadataVersion.INSTANCE, "expected version is $ABI_VERSION$") - .replace("expected version is " + JsMetadataVersion.INSTANCE, "expected version is $ABI_VERSION$") - .replace("compiler version " + JvmMetadataVersion.INSTANCE, "compiler version $ABI_VERSION$") - .replace("up to " + JvmMetadataVersion.INSTANCE, "up to $ABI_VERSION$") - .replace("up to " + JvmMetadataVersion.INSTANCE_NEXT, "up to $ABI_VERSION_NEXT$") + .replace(" " + JvmMetadataVersion.INSTANCE, " $ABI_VERSION$") + .replace(" " + JsMetadataVersion.INSTANCE, " $ABI_VERSION$") + .replace(" " + JvmMetadataVersion.INSTANCE_NEXT, " $ABI_VERSION_NEXT$") .replace("\\", "/") .replace(KotlinCompilerVersion.VERSION, "$VERSION$") .replace("\n" + Usage.BAT_DELIMITER_CHARACTERS_NOTE + "\n", "")