Fix explicit api mode in commonizer
^KT-57653
This commit is contained in:
committed by
Space Team
parent
d57623891d
commit
0790fef161
@@ -11,13 +11,13 @@ import org.junit.Rule
|
||||
import org.junit.rules.TemporaryFolder
|
||||
import kotlin.test.Test
|
||||
|
||||
class CliCommonizerTest {
|
||||
public class CliCommonizerTest {
|
||||
|
||||
@get:Rule
|
||||
val temporaryOutputDirectory = TemporaryFolder()
|
||||
public val temporaryOutputDirectory: TemporaryFolder = TemporaryFolder()
|
||||
|
||||
@Test
|
||||
fun invokeCliWithEmptyArguments() {
|
||||
public fun invokeCliWithEmptyArguments() {
|
||||
val commonizer = CliCommonizer(this::class.java.classLoader)
|
||||
commonizer.commonizeLibraries(
|
||||
konanHome = konanHome,
|
||||
|
||||
@@ -14,13 +14,13 @@ import kotlin.test.Test
|
||||
import kotlin.test.assertTrue
|
||||
import kotlin.test.fail
|
||||
|
||||
class CommonizeLibcurlTest {
|
||||
public class CommonizeLibcurlTest {
|
||||
|
||||
@get:Rule
|
||||
val temporaryOutputDirectory = TemporaryFolder()
|
||||
public val temporaryOutputDirectory: TemporaryFolder = TemporaryFolder()
|
||||
|
||||
@Test
|
||||
fun commonizeSuccessfully() {
|
||||
public fun commonizeSuccessfully() {
|
||||
val libraries = File("testData/libcurl").walkTopDown().filter { it.isFile && it.extension == "klib" }.toSet()
|
||||
val commonizer = CliCommonizer(this::class.java.classLoader)
|
||||
|
||||
@@ -63,7 +63,7 @@ class CommonizeLibcurlTest {
|
||||
|
||||
|
||||
@Test
|
||||
fun `commonizeSuccessfully with unsupported targets`() {
|
||||
public fun `commonizeSuccessfully with unsupported targets`() {
|
||||
val libraries = File("testData/libcurl").walkTopDown().filter { it.isFile && it.extension == "klib" }.toSet()
|
||||
val commonizer = CliCommonizer(this::class.java.classLoader)
|
||||
|
||||
|
||||
+7
-7
@@ -16,13 +16,13 @@ import org.junit.rules.TemporaryFolder
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
|
||||
class CommonizeNativeDistributionTest {
|
||||
public class CommonizeNativeDistributionTest {
|
||||
|
||||
@get:Rule
|
||||
val temporaryOutputDirectory = TemporaryFolder()
|
||||
public val temporaryOutputDirectory: TemporaryFolder = TemporaryFolder()
|
||||
|
||||
@Test
|
||||
fun `commonize - linux platforms`() {
|
||||
public fun `commonize - linux platforms`() {
|
||||
val linuxTarget1 = CommonizerTarget(LINUX_X64, LINUX_ARM64)
|
||||
val linuxTarget2 = CommonizerTarget(LINUX_X64, LINUX_ARM64, LINUX_ARM32_HFP)
|
||||
|
||||
@@ -45,7 +45,7 @@ class CommonizeNativeDistributionTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `commonize - unix platforms`() {
|
||||
public fun `commonize - unix platforms`() {
|
||||
val unixTarget = CommonizerTarget(
|
||||
LINUX_X64, LINUX_ARM64,
|
||||
MACOS_X64, MACOS_ARM64,
|
||||
@@ -68,7 +68,7 @@ class CommonizeNativeDistributionTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `commonize - apple platforms`() {
|
||||
public fun `commonize - apple platforms`() {
|
||||
assumeTrue("Test is only supported on macos", HostManager.hostIsMac)
|
||||
val iosTarget = CommonizerTarget(IOS_ARM64, IOS_X64, IOS_SIMULATOR_ARM64)
|
||||
val watchosTarget = CommonizerTarget(WATCHOS_ARM64, WATCHOS_X64, WATCHOS_SIMULATOR_ARM64, WATCHOS_DEVICE_ARM64)
|
||||
@@ -104,7 +104,7 @@ class CommonizeNativeDistributionTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `commonize - linux macos - linux macos mingw`() {
|
||||
public fun `commonize - linux macos - linux macos mingw`() {
|
||||
val unixTarget = CommonizerTarget(LINUX_X64, MACOS_X64)
|
||||
val nativeTarget = CommonizerTarget(MINGW_X64, LINUX_X64, MACOS_X64)
|
||||
CliCommonizer(this::class.java.classLoader).commonizeNativeDistribution(
|
||||
@@ -121,7 +121,7 @@ class CommonizeNativeDistributionTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `commonize - no outputTargets specified`() {
|
||||
public fun `commonize - no outputTargets specified`() {
|
||||
CliCommonizer(this::class.java.classLoader).commonizeNativeDistribution(
|
||||
konanHome = konanHome,
|
||||
outputTargets = emptySet(),
|
||||
|
||||
+3
-3
@@ -9,10 +9,10 @@ import java.io.File
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class CommonizerDependencyTest {
|
||||
public class CommonizerDependencyTest {
|
||||
|
||||
@Test
|
||||
fun `sample identityString`() {
|
||||
public fun `sample identityString`() {
|
||||
assertEquals(
|
||||
"(a, b, c)::${File("/").canonicalPath}hello.txt",
|
||||
TargetedCommonizerDependency(parseCommonizerTarget("(a, b, c)"), File("/hello.txt")).identityString
|
||||
@@ -20,7 +20,7 @@ class CommonizerDependencyTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test serialize deserialize`() {
|
||||
public fun `test serialize deserialize`() {
|
||||
assertEquals(
|
||||
parseCommonizerDependency(NonTargetedCommonizerDependency(File("hello.txt")).identityString),
|
||||
NonTargetedCommonizerDependency(File("hello.txt").canonicalFile)
|
||||
|
||||
+5
-5
@@ -13,7 +13,7 @@ import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class CommonizerTargetFileNameTest {
|
||||
public class CommonizerTargetFileNameTest {
|
||||
|
||||
private val longCommonizerTarget = parseCommonizerTarget(
|
||||
buildString {
|
||||
@@ -32,17 +32,17 @@ class CommonizerTargetFileNameTest {
|
||||
)
|
||||
|
||||
@get:Rule
|
||||
val temporaryFolder = TemporaryFolder()
|
||||
public val temporaryFolder: TemporaryFolder = TemporaryFolder()
|
||||
|
||||
@Test
|
||||
fun `small targets will use identityString`() {
|
||||
public fun `small targets will use identityString`() {
|
||||
val target = parseCommonizerTarget("((a, b), c)")
|
||||
assertEquals(target.identityString, target.fileName)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
@Test
|
||||
fun `longCommonizerTarget respect maximum fileName length`() {
|
||||
public fun `longCommonizerTarget respect maximum fileName length`() {
|
||||
assertTrue(
|
||||
longCommonizerTarget.identityString.length > maxFileNameLength,
|
||||
"Expected test target's identityString to exceed maxFileNameLength"
|
||||
@@ -55,7 +55,7 @@ class CommonizerTargetFileNameTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `longCommonizerTarget fileName can create new file`() {
|
||||
public fun `longCommonizerTarget fileName can create new file`() {
|
||||
val longCommonizerTargetFile = temporaryFolder.root.resolve(longCommonizerTarget.fileName)
|
||||
assertTrue(longCommonizerTargetFile.createNewFile(), "Expected being able to create file $longCommonizerTargetFile")
|
||||
longCommonizerTargetFile.writeText(longCommonizerTarget.identityString)
|
||||
|
||||
+16
-16
@@ -9,10 +9,10 @@ import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget.*
|
||||
import kotlin.test.*
|
||||
|
||||
class CommonizerTargetIdentityStringTest {
|
||||
public class CommonizerTargetIdentityStringTest {
|
||||
|
||||
@Test
|
||||
fun leafTargets() {
|
||||
public fun leafTargets() {
|
||||
KonanTarget.predefinedTargets.values.forEach { konanTarget ->
|
||||
assertEquals(konanTarget.name, CommonizerTarget(konanTarget).identityString)
|
||||
assertEquals(CommonizerTarget(konanTarget), parseCommonizerTarget(CommonizerTarget(konanTarget).identityString))
|
||||
@@ -20,7 +20,7 @@ class CommonizerTargetIdentityStringTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `simple shared targets are invariant under konanTarget order`() {
|
||||
public fun `simple shared targets are invariant under konanTarget order`() {
|
||||
val macosFirst = CommonizerTarget(MACOS_X64, LINUX_X64)
|
||||
val linuxFirst = CommonizerTarget(LINUX_X64, MACOS_X64)
|
||||
|
||||
@@ -33,63 +33,63 @@ class CommonizerTargetIdentityStringTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `parsing CommonizerTarget with 1 5 20 notation`() {
|
||||
public fun `parsing CommonizerTarget with 1 5 20 notation`() {
|
||||
val target = parseCommonizerTarget("(x, (x, y, (a, b), (b, c)))")
|
||||
assertEquals(SharedCommonizerTarget(setOf("x", "y", "a", "b", "c").map(::LeafCommonizerTarget).toSet()), target)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `empty shared target`() {
|
||||
public fun `empty shared target`() {
|
||||
assertEquals(SharedCommonizerTarget(emptySet<LeafCommonizerTarget>()), parseCommonizerTarget("()"))
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException::class)
|
||||
fun `fail parsing CommonizerTarget 1`() {
|
||||
public fun `fail parsing CommonizerTarget 1`() {
|
||||
parseCommonizerTarget("xxx,")
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException::class)
|
||||
fun `fail parsing CommonizerTarget 2`() {
|
||||
public fun `fail parsing CommonizerTarget 2`() {
|
||||
parseCommonizerTarget("")
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException::class)
|
||||
fun `fail parsing CommonizerTarget 4`() {
|
||||
public fun `fail parsing CommonizerTarget 4`() {
|
||||
parseCommonizerTarget("(xxx")
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException::class)
|
||||
fun `fail parsing CommonizerTarget 5`() {
|
||||
public fun `fail parsing CommonizerTarget 5`() {
|
||||
parseCommonizerTarget("xxx)")
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException::class)
|
||||
fun `fail parsing CommonizerTarget 6`() {
|
||||
public fun `fail parsing CommonizerTarget 6`() {
|
||||
parseCommonizerTarget("(xxx")
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException::class)
|
||||
fun `fail parsing CommonizerTarget 7`() {
|
||||
public fun `fail parsing CommonizerTarget 7`() {
|
||||
parseCommonizerTarget("(xxx yyy)")
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException::class)
|
||||
fun `fail parsing CommonizerTarget 8`() {
|
||||
public fun `fail parsing CommonizerTarget 8`() {
|
||||
parseCommonizerTarget(" ")
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException::class)
|
||||
fun `fail parsing CommonizerTarget 9`() {
|
||||
public fun `fail parsing CommonizerTarget 9`() {
|
||||
parseCommonizerTarget("xxx?")
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException::class)
|
||||
fun `fail parsing CommonizerTarget 10`() {
|
||||
public fun `fail parsing CommonizerTarget 10`() {
|
||||
parseCommonizerTarget("(x, (x, y)")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun isCommonizerIdentityString() {
|
||||
public fun isCommonizerIdentityString() {
|
||||
assertFalse(isCommonizerTargetIdentityString(""))
|
||||
assertTrue(isCommonizerTargetIdentityString("()"))
|
||||
assertTrue(isCommonizerTargetIdentityString("(a,b)"))
|
||||
@@ -99,7 +99,7 @@ class CommonizerTargetIdentityStringTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun parseCommonizerTargetOrNull() {
|
||||
public fun parseCommonizerTargetOrNull() {
|
||||
assertEquals(parseCommonizerTarget("((a,b),c)"), parseCommonizerTargetOrNull("((a,b),c)"))
|
||||
assertNull(parseCommonizerTargetOrNull(""))
|
||||
}
|
||||
|
||||
+4
-4
@@ -8,10 +8,10 @@ package org.jetbrains.kotlin.commonizer
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class CommonizerTargetUtilsTest {
|
||||
public class CommonizerTargetUtilsTest {
|
||||
|
||||
@Test
|
||||
fun allLeaves() {
|
||||
public fun allLeaves() {
|
||||
val target = parseCommonizerTarget("((a, b), (c, d), (e, (f, g)))")
|
||||
assertEquals(
|
||||
setOf(
|
||||
@@ -34,12 +34,12 @@ class CommonizerTargetUtilsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `withAllLeaves LeafCommonizerTarget`() {
|
||||
public fun `withAllLeaves LeafCommonizerTarget`() {
|
||||
assertEquals(setOf(LeafCommonizerTarget("a")), LeafCommonizerTarget("a").withAllLeaves())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `withAllLeaves SharedCommonizerTarget`() {
|
||||
public fun `withAllLeaves SharedCommonizerTarget`() {
|
||||
assertEquals(
|
||||
setOf(parseCommonizerTarget("(a, b)"), LeafCommonizerTarget("a"), LeafCommonizerTarget("b")),
|
||||
parseCommonizerTarget("(a, b)").withAllLeaves()
|
||||
|
||||
Reference in New Issue
Block a user