[Commonizer] Gracefully handle absent targets for hierarchical commonization
This commit is contained in:
@@ -28,8 +28,13 @@ class CommonizeLibcurlTest {
|
||||
commonizer.commonizeLibraries(
|
||||
konanHome = konanHome,
|
||||
inputLibraries = libraries,
|
||||
dependencyLibraries = KonanDistribution(konanHome).platformLibsDir.resolve(LINUX_X64.name).listFiles().orEmpty().toSet() +
|
||||
KonanDistribution(konanHome).platformLibsDir.resolve(LINUX_ARM64.name).listFiles().orEmpty().toSet(),
|
||||
dependencyLibraries = emptySet<CommonizerDependency>() +
|
||||
KonanDistribution(konanHome).platformLibsDir.resolve(LINUX_X64.name).listFiles().orEmpty()
|
||||
.map { TargetedCommonizerDependency(LeafCommonizerTarget(LINUX_X64), it) }.toSet() +
|
||||
|
||||
KonanDistribution(konanHome).platformLibsDir.resolve(LINUX_ARM64.name).listFiles().orEmpty()
|
||||
.map { TargetedCommonizerDependency(LeafCommonizerTarget(LINUX_ARM64), it) }
|
||||
.toSet(),
|
||||
outputCommonizerTarget = CommonizerTarget(LINUX_ARM64, LINUX_X64),
|
||||
outputDirectory = temporaryOutputDirectory.root
|
||||
)
|
||||
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.commonizer
|
||||
|
||||
import java.io.File
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class CommonizerDependencyTest {
|
||||
|
||||
@Test
|
||||
fun `sample identityString`() {
|
||||
assertEquals(
|
||||
"((a, b), c)::/hello.txt",
|
||||
TargetedCommonizerDependency(parseCommonizerTarget("((a,b), c)"), File("/hello.txt")).identityString
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test serialize deserialize`() {
|
||||
assertEquals(
|
||||
parseCommonizerDependency(NonTargetedCommonizerDependency(File("hello.txt")).identityString),
|
||||
NonTargetedCommonizerDependency(File("hello.txt").canonicalFile)
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
parseCommonizerDependency(TargetedCommonizerDependency(parseCommonizerTarget("((a,b), c)"), File("hello.txt")).identityString),
|
||||
TargetedCommonizerDependency(parseCommonizerTarget("((a,b), c)"), File("hello.txt").canonicalFile)
|
||||
)
|
||||
}
|
||||
}
|
||||
+17
-2
@@ -7,8 +7,7 @@ package org.jetbrains.kotlin.commonizer
|
||||
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget.*
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.*
|
||||
|
||||
class CommonizerTargetIdentityStringTest {
|
||||
|
||||
@@ -134,4 +133,20 @@ class CommonizerTargetIdentityStringTest {
|
||||
fun `fail parsing CommonizerTarget 10`() {
|
||||
parseCommonizerTarget("(x, (x, y)")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun isCommonizerIdentityString() {
|
||||
assertFalse(isCommonizerTargetIdentityString(""))
|
||||
assertTrue(isCommonizerTargetIdentityString("()"))
|
||||
assertTrue(isCommonizerTargetIdentityString("(a,b)"))
|
||||
assertFalse(isCommonizerTargetIdentityString("..."))
|
||||
assertTrue(isCommonizerTargetIdentityString("x"))
|
||||
assertFalse(isCommonizerTargetIdentityString("((a)"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun parseCommonizerTargetOrNull() {
|
||||
assertEquals(parseCommonizerTarget("((a,b),c)"), parseCommonizerTargetOrNull("((a,b),c)"))
|
||||
assertNull(parseCommonizerTargetOrNull(""))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user