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.
This commit is contained in:
Alexander Udalov
2023-08-11 23:21:40 +02:00
committed by Space Team
parent a58a1a3398
commit 9de6df6104
2 changed files with 8 additions and 10 deletions
@@ -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() }
^
@@ -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", "")