Tests to check kotlin stdlib dependencies and some improvements in gradle
This commit is contained in:
parent
758bc31a85
commit
529508bf74
@ -41,10 +41,14 @@ xomrk {
|
||||
compileTaskProvider.configure {
|
||||
compilerOptions {
|
||||
jvmTarget = JvmTarget.JVM_1_8
|
||||
freeCompilerArgs.addAll("-Xallow-kotlin-package")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named { t -> t == "${this@jvm.name}Test" }.configureEach {
|
||||
this as Test
|
||||
useTestNG()
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
@ -66,7 +70,13 @@ xomrk {
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets.configureEach {
|
||||
jvmTest {
|
||||
dependencies {
|
||||
implementation("org.testng:testng:7.5.1")
|
||||
}
|
||||
}
|
||||
|
||||
configureEach {
|
||||
when {
|
||||
// commonMain !in dependsOn -> return@configureEach
|
||||
!name.endsWith("Main") -> return@configureEach
|
||||
|
@ -1,3 +1,5 @@
|
||||
kotlin.code.style=official
|
||||
kotlin.stdlib.default.dependency=false
|
||||
kotlin.mpp.applyDefaultHierarchyTemplate=false
|
||||
kotlin.mpp.applyDefaultHierarchyTemplate=false
|
||||
kotlin.native.enableKlibsCrossCompilation=true
|
||||
# compileOnly dependencies from commonMain still throw warning
|
||||
kotlin.suppressGradlePluginWarnings=IncorrectCompileOnlyDependencyWarning
|
@ -0,0 +1,66 @@
|
||||
package ru.landgrafhomyak.utility.highlevel_try_finally.tests
|
||||
|
||||
import org.testng.annotations.Test
|
||||
import org.testng.asserts.Assertion
|
||||
import ru.landgrafhomyak.utility.highlevel_try_finally.safeAutoClose1
|
||||
import ru.landgrafhomyak.utility.highlevel_try_finally.tryFinallyChain
|
||||
|
||||
@Test
|
||||
class KotlinStdlibDependencyTest {
|
||||
@Test
|
||||
fun testNoKotlinStdlib() {
|
||||
try {
|
||||
KotlinVersion.CURRENT
|
||||
Assertion().assertTrue(false, "Kotlin stdlib still in runtime classpath")
|
||||
} catch (_: LinkageError) {
|
||||
}
|
||||
}
|
||||
|
||||
private class CustomTestException : RuntimeException()
|
||||
|
||||
private fun throw7throwFn() {
|
||||
safeAutoClose1(finally = { throw CustomTestException() }, action = { throw CustomTestException() })
|
||||
}
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
private inline fun throw7throwIn() {
|
||||
safeAutoClose1(finally = { throw CustomTestException() }, action = { throw CustomTestException() })
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = ["testNoKotlinStdlib"])
|
||||
fun testAutoCloseFn() {
|
||||
try {
|
||||
throw7throwFn()
|
||||
} catch (_: CustomTestException) {
|
||||
} catch (_: LinkageError) {
|
||||
Assertion().assertTrue(false, "safeAutoClose still has dependency on kotlin stdlib")
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = ["testNoKotlinStdlib"])
|
||||
fun testAutoCloseIn() {
|
||||
try {
|
||||
throw7throwIn()
|
||||
} catch (_: CustomTestException) {
|
||||
} catch (_: LinkageError) {
|
||||
Assertion().assertTrue(false, "safeAutoClose still has dependency on kotlin stdlib")
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = ["testNoKotlinStdlib"])
|
||||
fun testTryFinallyChain() {
|
||||
try {
|
||||
@Suppress("KotlinUnreachableCode")
|
||||
tryFinallyChain { chain ->
|
||||
chain.action { }
|
||||
chain.action { throw CustomTestException() }
|
||||
chain.action { throw CustomTestException() }
|
||||
chain.action { }
|
||||
chain.action { }
|
||||
}
|
||||
} catch (_: CustomTestException) {
|
||||
} catch (_: LinkageError) {
|
||||
Assertion().assertTrue(false, "safeAutoClose still has dependency on kotlin stdlib")
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user