From 6d888e8e31a8c5621cf130d3b23d8dbd623e5782 Mon Sep 17 00:00:00 2001 From: Artem Kobzar Date: Fri, 14 Oct 2022 13:29:36 +0000 Subject: [PATCH] [K/JS] Fix stdlib long path problem on Windows for ES modules tests --- .../kotlin/js/test/converters/JsIrBackendFacade.kt | 8 ++++---- .../kotlin/js/test/converters/JsIrModuleToPath.kt | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/converters/JsIrBackendFacade.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/converters/JsIrBackendFacade.kt index e0c72b12318..7390ace4605 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/converters/JsIrBackendFacade.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/converters/JsIrBackendFacade.kt @@ -310,16 +310,16 @@ val TestModule.kind: ModuleKind get() = directives.moduleKind fun String.augmentWithModuleName(moduleName: String): String { - return if (moduleName.isPath()) { - replaceAfterLast(File.separator, moduleName.replace("./", "")) + val normalizedName = moduleName.run { if (isWindows) minify() else this } + + return if (normalizedName.isPath()) { + replaceAfterLast(File.separator, normalizedName.replace("./", "")) } else { val suffix = when { endsWith(ESM_EXTENSION) -> ESM_EXTENSION endsWith(REGULAR_EXTENSION) -> REGULAR_EXTENSION else -> error("Unexpected file '$this' extension") } - val normalizedName = moduleName.run { if (isWindows) minify() else this } - return removeSuffix("_v5$suffix") + "-${normalizedName}_v5$suffix" } } diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/converters/JsIrModuleToPath.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/converters/JsIrModuleToPath.kt index 546ff67cc4d..fe1527b471c 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/converters/JsIrModuleToPath.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/converters/JsIrModuleToPath.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.js.test.converters +import org.jetbrains.kotlin.cli.common.isWindows import org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.safeName import org.jetbrains.kotlin.ir.declarations.IrModuleFragment import org.jetbrains.kotlin.test.services.TestServices @@ -26,7 +27,9 @@ class JsIrModuleToPath(val testServices: TestServices, shouldProvidePaths: Boole override operator fun get(key: K): V? { return runIf(!isEmpty()) { - "./${getJsArtifactSimpleName(testServices, key.safeName)}_v5.mjs" + "./${getJsArtifactSimpleName(testServices, key.safeName)}_v5.mjs".run { + if (isWindows) minify() else this + } } } } \ No newline at end of file