Skip to content

Commit

Permalink
Fix and test cases (Kotlin#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanlogan authored Sep 18, 2023
1 parent 8fbc5ef commit 0dc8cd9
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,33 @@ internal class IgnoredClassesTests : BaseKotlinGradleTest() {
Assertions.assertThat(rootProjectApiDump.readText()).isEqualToIgnoringNewLines(expected)
}
}

@Test
fun `apiDump should dump class whose name is a subsset of another class that is excluded via ignoredClasses`() {
val runner = test {
buildGradleKts {
resolve("examples/gradle/base/withPlugin.gradle.kts")
resolve("examples/gradle/configuration/ignoredClasses/oneValidFullyQualifiedClass.gradle.kts")
}
kotlin("BuildConfig.kt") {
resolve("examples/classes/BuildConfig.kt")
}
kotlin("BuildCon.kt") {
resolve("examples/classes/BuildCon.kt")
}

runner {
arguments.add(":apiDump")
}
}

runner.build().apply {
assertTaskSuccess(":apiDump")

assertTrue(rootProjectApiDump.exists(), "api dump file should exist")

val expected = readFileList("examples/classes/BuildCon.dump")
Assertions.assertThat(rootProjectApiDump.readText()).isEqualToIgnoringNewLines(expected)
}
}
}
6 changes: 6 additions & 0 deletions src/functionalTest/resources/examples/classes/BuildCon.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public final class com/company/BuildCon {
public fun <init> ()V
public final fun f1 ()I
public final fun getP1 ()I
}

12 changes: 12 additions & 0 deletions src/functionalTest/resources/examples/classes/BuildCon.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright 2016-2020 JetBrains s.r.o.
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file.
*/

package com.company

public class BuildCon {
public val p1 = 1

public fun f1() = p1
}
2 changes: 1 addition & 1 deletion src/main/kotlin/api/KotlinSignaturesLoading.kt
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ private fun ClassBinarySignature.isInPackages(packageNames: Collection<String>):
packageNames.any { packageName -> name.startsWith(packageName) }

private fun ClassBinarySignature.isInClasses(classNames: Collection<String>): Boolean =
classNames.any { className -> className.startsWith(name) }
classNames.any { className -> className.startsWith("$name/") }

private fun JarFile.classEntries() = Sequence { entries().iterator() }.filter {
!it.isDirectory && it.name.endsWith(".class") && !it.name.startsWith("META-INF/")
Expand Down

0 comments on commit 0dc8cd9

Please sign in to comment.