[kotlin-test] Enable explicit API mode KT-61969

This commit is contained in:
Ilya Gorbunov
2023-11-24 05:07:06 +01:00
committed by Space Team
parent 6c46d11d0a
commit 7a4335b087
4 changed files with 13 additions and 6 deletions
+7
View File
@@ -36,6 +36,8 @@ val jvmTestFrameworks = JvmTestFramework.values().toList()
kotlin {
explicitApi()
jvm {
compilations {
all {
@@ -58,6 +60,11 @@ kotlin {
jvmTestFrameworks.forEach { framework ->
val frameworkMain = create("$framework") {
associateWith(main)
compileTaskProvider.configure {
compilerOptions {
freeCompilerArgs.add("-Xexplicit-api=strict")
}
}
}
create("${framework}Test") {
associateWith(frameworkMain)
@@ -11,7 +11,7 @@ import kotlin.test.*
/**
* Provides [JUnitAsserter] if `org.junit.Assert` is found in the classpath.
*/
class JUnitContributor : AsserterContributor {
public class JUnitContributor : AsserterContributor {
override fun contribute(): Asserter? {
return if (hasJUnitInClassPath) JUnitAsserter else null
}
@@ -27,7 +27,7 @@ class JUnitContributor : AsserterContributor {
/**
* Implements `kotlin.test` assertions by delegating them to `org.junit.Assert` class.
*/
object JUnitAsserter : Asserter {
public object JUnitAsserter : Asserter {
override fun assertEquals(message: String?, expected: Any?, actual: Any?) {
Assert.assertEquals(message, expected, actual)
}
@@ -11,7 +11,7 @@ import kotlin.test.*
/**
* Provides [JUnit5Asserter] if `org.junit.jupiter.api.Assertions` class is found in the classpath.
*/
class JUnit5Contributor : AsserterContributor {
public class JUnit5Contributor : AsserterContributor {
override fun contribute(): Asserter? {
return if (hasJUnitInClassPath) JUnit5Asserter else null
}
@@ -27,7 +27,7 @@ class JUnit5Contributor : AsserterContributor {
/**
* Implements `kotlin.test` assertions by delegating them to `org.junit.jupiter.api.Assertions` class.
*/
object JUnit5Asserter : Asserter {
public object JUnit5Asserter : Asserter {
override fun assertEquals(message: String?, expected: Any?, actual: Any?) {
Assertions.assertEquals(expected, actual, message)
}
@@ -11,7 +11,7 @@ import kotlin.test.*
/**
* Provides [TestNGAsserter] if `org.testng.Assert` is found in the classpath.
*/
class TestNGContributor : AsserterContributor {
public class TestNGContributor : AsserterContributor {
override fun contribute(): Asserter? {
return if (hasTestNGInClassPath) TestNGAsserter else null
}
@@ -27,7 +27,7 @@ class TestNGContributor : AsserterContributor {
/**
* Implements `kotlin.test` assertions by delegating them to `org.testng.Assert` class.
*/
object TestNGAsserter : Asserter {
public object TestNGAsserter : Asserter {
override fun assertEquals(message: String?, expected: Any?, actual: Any?) {
Assert.assertEquals(actual, expected, message)
}