[K/JS] Fix Windows test run with a long test name
This commit is contained in:
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.js.test.converters
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.phaser.PhaseConfig
|
||||
import org.jetbrains.kotlin.backend.common.phaser.toPhaseMap
|
||||
import org.jetbrains.kotlin.backend.common.serialization.cityHash64
|
||||
import org.jetbrains.kotlin.backend.common.serialization.signature.IdSignatureDescriptor
|
||||
import org.jetbrains.kotlin.cli.common.isWindows
|
||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
||||
@@ -302,7 +303,8 @@ val TestModule.kind: ModuleKind
|
||||
get() = directives.moduleKind
|
||||
|
||||
fun String.augmentWithModuleName(moduleName: String): String {
|
||||
val normalizedName = moduleName.run { if (isWindows) minify() else this }
|
||||
val shouldMinimize = isWindows && moduleName.isPath()
|
||||
val normalizedName = moduleName.run { if (shouldMinimize) minify() else this }
|
||||
val suffix = when {
|
||||
endsWith(ESM_EXTENSION) -> ESM_EXTENSION
|
||||
endsWith(REGULAR_EXTENSION) -> REGULAR_EXTENSION
|
||||
@@ -320,8 +322,14 @@ fun String.augmentWithModuleName(moduleName: String): String {
|
||||
// The hack should be deleted when D8 fixes the bug.
|
||||
// The issue is here: https://bugs.chromium.org/p/v8/issues/detail?id=13318
|
||||
fun String.minify(): String {
|
||||
return replace("kotlin_org_jetbrains_kotlin_kotlin_", "")
|
||||
.replace("_minimal_for_test", "_min")
|
||||
if (length <= 80) return this
|
||||
|
||||
val directoryPath = substringBeforeLast('/')
|
||||
val fileFullName = substringAfterLast('/')
|
||||
val fileName = fileFullName.substringBeforeLast('.')
|
||||
val fileExtension = fileFullName.substringAfterLast('.')
|
||||
|
||||
return "$directoryPath/${fileName.cityHash64().toULong().toString(16)}.$fileExtension"
|
||||
}
|
||||
|
||||
private fun String.isPath(): Boolean = contains("/")
|
||||
|
||||
Reference in New Issue
Block a user