Skip to content

Commit 0f6d84c

Browse files
homurollSpace Team
authored and
Space Team
committed
[K/N][tests] Added a reproducer for #KT-60371
1 parent d3b8607 commit 0f6d84c

File tree

1 file changed

+36
-15
lines changed

1 file changed

+36
-15
lines changed

native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/CachesAutoBuildTest.kt

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class CachesAutoBuildTest : AbstractNativeSimpleTest() {
4040
fun testSimple() {
4141
val rootDir = File("$TEST_SUITE_PATH/simple")
4242
val lib = compileToLibrary(rootDir.resolve("lib"), buildDir)
43-
val main = compileToExecutable(rootDir.resolve("main"), autoCacheFrom = buildDir, emptyList(), lib)
43+
val main = compileToExecutable(rootDir.resolve("main"), autoCacheFrom = buildDir, emptyList(), emptyList(), lib)
4444

4545
assertTrue(main.executableFile.exists())
4646
assertTrue(autoCacheDir.resolve(cacheFlavor).resolve("lib").exists())
@@ -54,7 +54,7 @@ class CachesAutoBuildTest : AbstractNativeSimpleTest() {
5454
val userLib = compileToLibrary(rootDir.resolve("userLib"), buildDir.resolve("user"), externalLib)
5555
val main = compileToExecutable(
5656
rootDir.resolve("main"),
57-
autoCacheFrom = buildDir.resolve("external"), emptyList(),
57+
autoCacheFrom = buildDir.resolve("external"), emptyList(), emptyList(),
5858
externalLib, userLib
5959
)
6060

@@ -73,24 +73,45 @@ class CachesAutoBuildTest : AbstractNativeSimpleTest() {
7373
compileToStaticCache(lib, cacheDir)
7474
val makePerFileCache = testRunSettings.get<CacheMode>().makePerFileCaches
7575
assertTrue(cacheDir.resolve("lib-${if (makePerFileCache) "per-file-cache" else "cache"}").exists())
76-
val main = compileToExecutable(rootDir.resolve("main"), autoCacheFrom = buildDir, listOf(cacheDir), lib)
76+
val main = compileToExecutable(rootDir.resolve("main"), autoCacheFrom = buildDir, listOf(cacheDir), emptyList(), lib)
7777

7878
assertTrue(main.executableFile.exists())
7979
assertFalse(autoCacheDir.resolve(cacheFlavor).resolve("lib").exists())
8080
}
8181

82-
private fun compileToExecutable(sourcesDir: File, autoCacheFrom: File, cacheDirectories: List<File>, vararg dependencies: KLIB) =
83-
compileToExecutable(
84-
sourcesDir,
85-
tryPassSystemCacheDirectory = false, // With auto-cache mode, the compiler chooses the system cache directory itself.
86-
freeCompilerArgs = TestCompilerArgs(
87-
listOf(
88-
"-Xauto-cache-from=${autoCacheFrom.absolutePath}",
89-
"-Xauto-cache-dir=${autoCacheDir.absolutePath}",
90-
) + cacheDirectories.map { "-Xcache-directory=${it.absolutePath}" }
91-
),
92-
*dependencies
93-
).assertSuccess().resultingArtifact
82+
@Test
83+
@TestMetadata("testCustomBinaryOptions")
84+
fun testCustomBinaryOptions() {
85+
val rootDir = File("$TEST_SUITE_PATH/simple")
86+
val lib = compileToLibrary(rootDir.resolve("lib"), buildDir)
87+
val main = compileToExecutable(rootDir.resolve("main"), autoCacheFrom = buildDir, emptyList(), emptyList(), lib)
88+
89+
assertTrue(main.executableFile.exists())
90+
assertTrue(autoCacheDir.resolve(cacheFlavor).resolve("lib").exists())
91+
92+
val customRuntimeAsserts = "-Xbinary=runtimeAssertionsMode=log"
93+
val main2 = compileToExecutable(rootDir.resolve("main"), autoCacheFrom = buildDir, emptyList(), listOf(customRuntimeAsserts), lib)
94+
95+
assertTrue(main2.executableFile.exists())
96+
}
97+
98+
private fun compileToExecutable(
99+
sourcesDir: File,
100+
autoCacheFrom: File,
101+
cacheDirectories: List<File>,
102+
additionalArgs: List<String>,
103+
vararg dependencies: KLIB
104+
) = compileToExecutable(
105+
sourcesDir,
106+
tryPassSystemCacheDirectory = false, // With auto-cache mode, the compiler chooses the system cache directory itself.
107+
freeCompilerArgs = TestCompilerArgs(
108+
listOf(
109+
"-Xauto-cache-from=${autoCacheFrom.absolutePath}",
110+
"-Xauto-cache-dir=${autoCacheDir.absolutePath}",
111+
) + cacheDirectories.map { "-Xcache-directory=${it.absolutePath}" } + additionalArgs
112+
),
113+
*dependencies
114+
).assertSuccess().resultingArtifact
94115

95116
private val autoCacheDir: File get() = buildDir.resolve("__auto_cache__")
96117
private val cacheFlavor: String

0 commit comments

Comments
 (0)