Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/kotlin/api/klib/KlibAbiDumpFileMerger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ internal class KlibAbiDumpMerger {
// then try to parse a manifest
while (hasNext()) {
val next = peek()!!
if (!next.startsWith(COMMENT_PREFIX)) break
if (!next.startsWith(COMMENT_PREFIX) || next.startsWith(TARGETS_LIST_PREFIX)) break
next()
// There's no manifest in merged files
check(!isMergedFile) { "Unexpected header line: $next" }
Expand Down
24 changes: 24 additions & 0 deletions src/test/kotlin/tests/KlibAbiMergingTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -336,4 +336,28 @@ class KlibAbiMergingTest {
KlibAbiDumpMerger().merge(file("/merge/stdlib_native_common.abi"), "target")
}
}

@Test
fun mergeDumpsWithNonOverlappingDeclarations() {
val dump = dumpToFile(KlibAbiDumpMerger().apply {
merge(file("/merge/non-overlapping/linux-arm64.klib.abi"))
merge(file("/merge/non-overlapping/linux-x64.klib.abi"))
})

assertContentEquals(
lines("/merge/non-overlapping/merged.klib.abi"),
Files.readAllLines(dump.toPath()).asSequence()
)
}

@Test
fun loadMergedDumpWithNonOverlappingDeclarations() {
val dump = dumpToFile(KlibAbiDumpMerger().apply {
merge(file("/merge/non-overlapping/merged.klib.abi"))
})
assertContentEquals(
lines("/merge/non-overlapping/merged.klib.abi"),
Files.readAllLines(dump.toPath()).asSequence()
)
}
}
9 changes: 9 additions & 0 deletions src/test/resources/merge/non-overlapping/linux-arm64.klib.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Klib ABI Dump
// Targets: [linuxArm64]
// Rendering settings:
// - Signature version: 2
// - Show manifest properties: false
// - Show declarations: true

// Library unique name: <org.example:bcv-klib-test>
final fun org.example/add(kotlin/Long, kotlin/Long): kotlin/Long // org.example/add|add(kotlin.Long;kotlin.Long){}[0]
9 changes: 9 additions & 0 deletions src/test/resources/merge/non-overlapping/linux-x64.klib.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Klib ABI Dump
// Targets: [linuxX64]
// Rendering settings:
// - Signature version: 2
// - Show manifest properties: false
// - Show declarations: true

// Library unique name: <org.example:bcv-klib-test>
final fun org.example/sub(kotlin/Long, kotlin/Long): kotlin/Long // org.example/sub|sub(kotlin.Long;kotlin.Long){}[0]
12 changes: 12 additions & 0 deletions src/test/resources/merge/non-overlapping/merged.klib.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Klib ABI Dump
// Targets: [linuxArm64, linuxX64]
// Rendering settings:
// - Signature version: 2
// - Show manifest properties: false
// - Show declarations: true

// Library unique name: <org.example:bcv-klib-test>
// Targets: [linuxArm64]
final fun org.example/add(kotlin/Long, kotlin/Long): kotlin/Long // org.example/add|add(kotlin.Long;kotlin.Long){}[0]
// Targets: [linuxX64]
final fun org.example/sub(kotlin/Long, kotlin/Long): kotlin/Long // org.example/sub|sub(kotlin.Long;kotlin.Long){}[0]