-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- introduce new configuration option to ignore by pattern
- introduce tests to verify excluding by pattern works
- Loading branch information
Showing
8 changed files
with
143 additions
and
2 deletions.
There are no files selected for viewing
99 changes: 99 additions & 0 deletions
99
src/functionalTest/kotlin/kotlinx/validation/test/IgnoredTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
* 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 kotlinx.validation.test | ||
|
||
import kotlinx.validation.api.* | ||
import kotlinx.validation.api.BaseKotlinGradleTest | ||
import kotlinx.validation.api.assertTaskSuccess | ||
import kotlinx.validation.api.buildGradleKts | ||
import kotlinx.validation.api.kotlin | ||
import kotlinx.validation.api.readFileList | ||
import kotlinx.validation.api.resolve | ||
import kotlinx.validation.api.runner | ||
import kotlinx.validation.api.test | ||
import org.assertj.core.api.Assertions | ||
import org.junit.Test | ||
import kotlin.test.assertTrue | ||
|
||
internal class IgnoredTests : BaseKotlinGradleTest() { | ||
|
||
@Test | ||
fun `apiCheck should succeed, when given class is not in api-File, but is ignored via ignored pattern`() { | ||
val runner = test { | ||
buildGradleKts { | ||
resolve("/examples/gradle/base/withPlugin.gradle.kts") | ||
resolve("/examples/gradle/configuration/ignored/oneValidPattern.gradle.kts") | ||
} | ||
|
||
kotlin("BuildConfig.kt") { | ||
resolve("/examples/classes/BuildConfig.kt") | ||
} | ||
|
||
emptyApiFile(projectName = rootProjectDir.name) | ||
|
||
runner { | ||
arguments.add(":apiCheck") | ||
} | ||
} | ||
|
||
runner.build().apply { | ||
assertTaskSuccess(":apiCheck") | ||
} | ||
} | ||
|
||
@Test | ||
fun `apiCheck should succeed, when given class is not in api-File, but is ignored via ignored pattern (based on package)`() { | ||
val runner = test { | ||
buildGradleKts { | ||
resolve("/examples/gradle/base/withPlugin.gradle.kts") | ||
resolve("/examples/gradle/configuration/ignored/oneValidPackagePattern.gradle.kts") | ||
} | ||
|
||
kotlin("BuildConfig.kt") { | ||
resolve("/examples/classes/BuildConfig.kt") | ||
} | ||
|
||
emptyApiFile(projectName = rootProjectDir.name) | ||
|
||
runner { | ||
arguments.add(":apiCheck") | ||
} | ||
} | ||
|
||
runner.build().apply { | ||
assertTaskSuccess(":apiCheck") | ||
} | ||
} | ||
|
||
@Test | ||
fun `apiDump should not dump ignored classes, when class is excluded via ignored pattern`() { | ||
val runner = test { | ||
buildGradleKts { | ||
resolve("/examples/gradle/base/withPlugin.gradle.kts") | ||
resolve("/examples/gradle/configuration/ignored/oneValidPatternPackageClass.gradle.kts") | ||
} | ||
kotlin("BuildConfig.kt") { | ||
resolve("/examples/classes/BuildConfig.kt") | ||
} | ||
kotlin("AnotherBuildConfig.kt") { | ||
resolve("/examples/classes/AnotherBuildConfig.kt") | ||
} | ||
|
||
runner { | ||
arguments.add(":apiDump") | ||
} | ||
} | ||
|
||
runner.build().apply { | ||
assertTaskSuccess(":apiDump") | ||
|
||
assertTrue(rootProjectApiDump.exists(), "api dump file should exist") | ||
|
||
val expected = readFileList("/examples/classes/AnotherBuildConfig.dump") | ||
Assertions.assertThat(rootProjectApiDump.readText()).isEqualToIgnoringNewLines(expected) | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...nalTest/resources/examples/gradle/configuration/ignored/oneValidPackagePattern.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* Copyright 2016-2024 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. | ||
*/ | ||
|
||
configure<kotlinx.validation.ApiValidationExtension> { | ||
ignored.add("com\\/company\\/.+") | ||
} |
3 changes: 3 additions & 0 deletions
3
...functionalTest/resources/examples/gradle/configuration/ignored/oneValidPattern.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
configure<kotlinx.validation.ApiValidationExtension> { | ||
ignored.add(".+\\/BuildConfig") | ||
} |
3 changes: 3 additions & 0 deletions
3
...st/resources/examples/gradle/configuration/ignored/oneValidPatternPackageClass.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
configure<kotlinx.validation.ApiValidationExtension> { | ||
ignored.add(".+\\/company\\/BuildConfig") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters