Tests: minor, slightly move JDK path substitution logic

It will be used in other CLI tests in subsequent commits.
This commit is contained in:
Alexander Udalov
2024-02-14 15:21:48 +01:00
committed by Space Team
parent 60071cbb54
commit cdcb65c749
3 changed files with 5 additions and 5 deletions
@@ -1,3 +1,3 @@
error: can't find modules signatures in `ct.sym` file for `-Xjdk-release=12` in $JDK11/lib/ct.sym
error: can't find modules signatures in `ct.sym` file for `-Xjdk-release=12` in $JDK_11/lib/ct.sym
error: module java.base cannot be found in the module graph
COMPILATION_ERROR
@@ -113,12 +113,15 @@ public abstract class AbstractCliTest extends TestCaseWithTmpdir {
.replace(PathUtil.getKotlinPathsForDistDirectory().getHomePath().getParentFile().getAbsolutePath(), "$DIST_DIR$")
.replace(org.jetbrains.kotlin.konan.file.File.Companion.getUserDir().getAbsolutePath(), "$USER_DIR$")
.replace(tmpDirAbsoluteDir, "$TMP_DIR$")
.replace("\\", "/")
.replace(KtTestUtil.getJdk8Home().getAbsolutePath().replace("\\", "/"), "$JDK_1_8")
.replace(KtTestUtil.getJdk11Home().getAbsolutePath().replace("\\", "/"), "$JDK_11")
.replace(KtTestUtil.getJdk17Home().getAbsolutePath().replace("\\", "/"), "$JDK_17")
.replaceAll("info: executable production duration: \\d+ms", "info: executable production duration: [time]")
.replace(KotlinCompilerVersion.VERSION, "$VERSION$")
.replace(" " + JvmMetadataVersion.INSTANCE, " $ABI_VERSION$")
.replace(" " + JsMetadataVersion.INSTANCE, " $ABI_VERSION$")
.replace(" " + JvmMetadataVersion.INSTANCE_NEXT, " $ABI_VERSION_NEXT$")
.replace("\\", "/")
.replace("\n" + Usage.BAT_DELIMITER_CHARACTERS_NOTE + "\n", "")
.replaceAll("log4j:WARN.*\n", "");
@@ -70,15 +70,12 @@ abstract class AbstractJavaModulesIntegrationTest(
)
}
private fun checkKotlinOutput(moduleName: String): (String) -> Unit {
val expectedFirFile = File(testDataDirectory, "$moduleName.fir.txt")
return { actual ->
KotlinTestUtils.assertEqualsToFile(
if (languageVersion.usesK2 && expectedFirFile.exists()) expectedFirFile else File(testDataDirectory, "$moduleName.txt"),
getNormalizedCompilerOutput(actual, null, testDataPath, tmpdir.absolutePath)
.replace((System.getenv("JDK_11_0") ?: System.getenv("JDK_11")).replace("\\", "/"), "\$JDK11")
.replace((System.getenv("JDK_17_0") ?: System.getenv("JDK_17")).replace("\\", "/"), "\$JDK17")
)
}
}