[kotlin-test] Enable explicit API mode KT-61969
This commit is contained in:
committed by
Space Team
parent
6c46d11d0a
commit
7a4335b087
@@ -36,6 +36,8 @@ val jvmTestFrameworks = JvmTestFramework.values().toList()
|
|||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
|
|
||||||
|
explicitApi()
|
||||||
|
|
||||||
jvm {
|
jvm {
|
||||||
compilations {
|
compilations {
|
||||||
all {
|
all {
|
||||||
@@ -58,6 +60,11 @@ kotlin {
|
|||||||
jvmTestFrameworks.forEach { framework ->
|
jvmTestFrameworks.forEach { framework ->
|
||||||
val frameworkMain = create("$framework") {
|
val frameworkMain = create("$framework") {
|
||||||
associateWith(main)
|
associateWith(main)
|
||||||
|
compileTaskProvider.configure {
|
||||||
|
compilerOptions {
|
||||||
|
freeCompilerArgs.add("-Xexplicit-api=strict")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
create("${framework}Test") {
|
create("${framework}Test") {
|
||||||
associateWith(frameworkMain)
|
associateWith(frameworkMain)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import kotlin.test.*
|
|||||||
/**
|
/**
|
||||||
* Provides [JUnitAsserter] if `org.junit.Assert` is found in the classpath.
|
* Provides [JUnitAsserter] if `org.junit.Assert` is found in the classpath.
|
||||||
*/
|
*/
|
||||||
class JUnitContributor : AsserterContributor {
|
public class JUnitContributor : AsserterContributor {
|
||||||
override fun contribute(): Asserter? {
|
override fun contribute(): Asserter? {
|
||||||
return if (hasJUnitInClassPath) JUnitAsserter else null
|
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.
|
* 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?) {
|
override fun assertEquals(message: String?, expected: Any?, actual: Any?) {
|
||||||
Assert.assertEquals(message, expected, actual)
|
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.
|
* 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? {
|
override fun contribute(): Asserter? {
|
||||||
return if (hasJUnitInClassPath) JUnit5Asserter else null
|
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.
|
* 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?) {
|
override fun assertEquals(message: String?, expected: Any?, actual: Any?) {
|
||||||
Assertions.assertEquals(expected, actual, message)
|
Assertions.assertEquals(expected, actual, message)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import kotlin.test.*
|
|||||||
/**
|
/**
|
||||||
* Provides [TestNGAsserter] if `org.testng.Assert` is found in the classpath.
|
* Provides [TestNGAsserter] if `org.testng.Assert` is found in the classpath.
|
||||||
*/
|
*/
|
||||||
class TestNGContributor : AsserterContributor {
|
public class TestNGContributor : AsserterContributor {
|
||||||
override fun contribute(): Asserter? {
|
override fun contribute(): Asserter? {
|
||||||
return if (hasTestNGInClassPath) TestNGAsserter else null
|
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.
|
* 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?) {
|
override fun assertEquals(message: String?, expected: Any?, actual: Any?) {
|
||||||
Assert.assertEquals(actual, expected, message)
|
Assert.assertEquals(actual, expected, message)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user