Skip to content

Commit c695677

Browse files
authored
Correctly handle dumps starting with Targets-list (#202)
Fixes #201
1 parent 10f8e7e commit c695677

File tree

5 files changed

+55
-1
lines changed

5 files changed

+55
-1
lines changed

src/main/kotlin/api/klib/KlibAbiDumpFileMerger.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ internal class KlibAbiDumpMerger {
254254
// then try to parse a manifest
255255
while (hasNext()) {
256256
val next = peek()!!
257-
if (!next.startsWith(COMMENT_PREFIX)) break
257+
if (!next.startsWith(COMMENT_PREFIX) || next.startsWith(TARGETS_LIST_PREFIX)) break
258258
next()
259259
// There's no manifest in merged files
260260
check(!isMergedFile) { "Unexpected header line: $next" }

src/test/kotlin/tests/KlibAbiMergingTest.kt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,4 +336,28 @@ class KlibAbiMergingTest {
336336
KlibAbiDumpMerger().merge(file("/merge/stdlib_native_common.abi"), "target")
337337
}
338338
}
339+
340+
@Test
341+
fun mergeDumpsWithNonOverlappingDeclarations() {
342+
val dump = dumpToFile(KlibAbiDumpMerger().apply {
343+
merge(file("/merge/non-overlapping/linux-arm64.klib.abi"))
344+
merge(file("/merge/non-overlapping/linux-x64.klib.abi"))
345+
})
346+
347+
assertContentEquals(
348+
lines("/merge/non-overlapping/merged.klib.abi"),
349+
Files.readAllLines(dump.toPath()).asSequence()
350+
)
351+
}
352+
353+
@Test
354+
fun loadMergedDumpWithNonOverlappingDeclarations() {
355+
val dump = dumpToFile(KlibAbiDumpMerger().apply {
356+
merge(file("/merge/non-overlapping/merged.klib.abi"))
357+
})
358+
assertContentEquals(
359+
lines("/merge/non-overlapping/merged.klib.abi"),
360+
Files.readAllLines(dump.toPath()).asSequence()
361+
)
362+
}
339363
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Klib ABI Dump
2+
// Targets: [linuxArm64]
3+
// Rendering settings:
4+
// - Signature version: 2
5+
// - Show manifest properties: false
6+
// - Show declarations: true
7+
8+
// Library unique name: <org.example:bcv-klib-test>
9+
final fun org.example/add(kotlin/Long, kotlin/Long): kotlin/Long // org.example/add|add(kotlin.Long;kotlin.Long){}[0]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Klib ABI Dump
2+
// Targets: [linuxX64]
3+
// Rendering settings:
4+
// - Signature version: 2
5+
// - Show manifest properties: false
6+
// - Show declarations: true
7+
8+
// Library unique name: <org.example:bcv-klib-test>
9+
final fun org.example/sub(kotlin/Long, kotlin/Long): kotlin/Long // org.example/sub|sub(kotlin.Long;kotlin.Long){}[0]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Klib ABI Dump
2+
// Targets: [linuxArm64, linuxX64]
3+
// Rendering settings:
4+
// - Signature version: 2
5+
// - Show manifest properties: false
6+
// - Show declarations: true
7+
8+
// Library unique name: <org.example:bcv-klib-test>
9+
// Targets: [linuxArm64]
10+
final fun org.example/add(kotlin/Long, kotlin/Long): kotlin/Long // org.example/add|add(kotlin.Long;kotlin.Long){}[0]
11+
// Targets: [linuxX64]
12+
final fun org.example/sub(kotlin/Long, kotlin/Long): kotlin/Long // org.example/sub|sub(kotlin.Long;kotlin.Long){}[0]

0 commit comments

Comments
 (0)