[K/N][tests] Migrate termination runtime tests to new testing infra ^KT-61259
This commit is contained in:
committed by
Space Team
parent
226ee3c367
commit
04a2a2d90d
@@ -0,0 +1,8 @@
|
||||
// EXIT_CODE: !0
|
||||
@file:OptIn(kotlin.experimental.ExperimentalNativeApi::class)
|
||||
|
||||
// TODO: Test running this test with disabled assertions. This requires removing always-enabled
|
||||
// -enable-assertions from `BasicCompilation`.
|
||||
fun main() {
|
||||
assert(false)
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
@file:OptIn(kotlin.experimental.ExperimentalNativeApi::class)
|
||||
|
||||
fun main() {
|
||||
assert(true)
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// EXIT_CODE: 42
|
||||
// OUTPUT_DATA_FILE: exitProcess.out
|
||||
|
||||
import kotlin.system.*
|
||||
|
||||
fun main() {
|
||||
print("OK")
|
||||
exitProcess(42)
|
||||
println("FAIL")
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -0,0 +1,8 @@
|
||||
// EXIT_CODE: !0
|
||||
// OUTPUT_REGEX: Uncaught Kotlin exception: kotlin\.Error: an error\n(?!.*FAIL.*).*
|
||||
|
||||
val p: Nothing = throw Error("an error")
|
||||
|
||||
fun main() {
|
||||
println("FAIL")
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// EXIT_CODE: !0
|
||||
// OUTPUT_REGEX: Uncaught Kotlin exception: kotlin\.Error: an error\n.*
|
||||
|
||||
fun main() {
|
||||
throw Error("an error")
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// EXIT_CODE: !0
|
||||
// OUTPUT_REGEX: Uncaught Kotlin exception: kotlin\.Error: an error\n.*
|
||||
@file:OptIn(kotlin.experimental.ExperimentalNativeApi::class)
|
||||
|
||||
fun main() {
|
||||
processUnhandledException(Error("an error"))
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// EXIT_CODE: !0
|
||||
// OUTPUT_REGEX: Uncaught Kotlin exception: kotlin\.Error: an error\n.*
|
||||
@file:OptIn(kotlin.experimental.ExperimentalNativeApi::class)
|
||||
|
||||
fun main() {
|
||||
terminateWithUnhandledException(Error("an error"))
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// EXIT_CODE: !0
|
||||
// FREE_COMPILER_ARGS: -opt-in=kotlin.native.internal.InternalForKotlinNative
|
||||
// OUTPUT_REGEX: value 42: Error\. Runnable state: true\nUncaught Kotlin exception: kotlin\.Error: an error\n.*
|
||||
@file:OptIn(kotlin.experimental.ExperimentalNativeApi::class, kotlin.native.runtime.NativeRuntimeApi::class)
|
||||
|
||||
import kotlin.native.runtime.Debugging
|
||||
import kotlin.test.*
|
||||
|
||||
fun main() {
|
||||
val x = 42
|
||||
setUnhandledExceptionHook { throwable: Throwable ->
|
||||
println("value $x: ${throwable::class.simpleName}. Runnable state: ${Debugging.isThreadStateRunnable}")
|
||||
}
|
||||
|
||||
throw Error("an error")
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// EXIT_CODE: !0
|
||||
// FREE_COMPILER_ARGS: -opt-in=kotlin.native.internal.InternalForKotlinNative
|
||||
// OUTPUT_REGEX: value true: Error\. Runnable state: true\nUncaught Kotlin exception: kotlin\.Error: an error\n.*
|
||||
@file:OptIn(kotlin.experimental.ExperimentalNativeApi::class, kotlin.native.runtime.NativeRuntimeApi::class)
|
||||
|
||||
import kotlin.native.runtime.Debugging
|
||||
import kotlin.test.*
|
||||
|
||||
fun customExceptionHook(throwable: Throwable) {
|
||||
println("value ${getUnhandledExceptionHook() == ::customExceptionHook}: ${throwable::class.simpleName}. Runnable state: ${Debugging.isThreadStateRunnable}")
|
||||
}
|
||||
|
||||
fun main() {
|
||||
val x = 42
|
||||
setUnhandledExceptionHook(::customExceptionHook)
|
||||
|
||||
throw Error("an error")
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// No termination is going on here. But that's the closest location to other unhandled exception hook tests.
|
||||
@file:OptIn(kotlin.experimental.ExperimentalNativeApi::class)
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun main() {
|
||||
val exceptionHook = { _: Throwable -> Unit }
|
||||
|
||||
val oldHook = setUnhandledExceptionHook(exceptionHook)
|
||||
assertNull(oldHook)
|
||||
val hook1 = getUnhandledExceptionHook()
|
||||
assertEquals(exceptionHook, hook1)
|
||||
val hook2 = getUnhandledExceptionHook()
|
||||
assertEquals(exceptionHook, hook2)
|
||||
val hook3 = setUnhandledExceptionHook(null)
|
||||
assertEquals(exceptionHook, hook3)
|
||||
val hook4 = getUnhandledExceptionHook()
|
||||
assertNull(hook4)
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// EXIT_CODE: !0
|
||||
// OUTPUT_REGEX: Hook\nUncaught Kotlin exception: kotlin\.Error: an error\n.*
|
||||
@file:OptIn(kotlin.experimental.ExperimentalNativeApi::class)
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun main() {
|
||||
setUnhandledExceptionHook {
|
||||
println("Hook")
|
||||
terminateWithUnhandledException(it)
|
||||
}
|
||||
|
||||
throw Error("an error")
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// EXIT_CODE: !0
|
||||
// OUTPUT_REGEX: Hook\nUncaught Kotlin exception: kotlin\.Error: an error\n(?!.*FAIL.*).*
|
||||
@file:OptIn(kotlin.experimental.ExperimentalNativeApi::class)
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun main() {
|
||||
setUnhandledExceptionHook {
|
||||
println("Hook")
|
||||
terminateWithUnhandledException(it)
|
||||
}
|
||||
|
||||
processUnhandledException(Error("an error"))
|
||||
println("FAIL")
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// EXIT_CODE: !0
|
||||
// OUTPUT_REGEX: Hook\nUncaught Kotlin exception: kotlin\.Error: another error\n(?!.*an error.*).*
|
||||
@file:OptIn(kotlin.experimental.ExperimentalNativeApi::class)
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun main() {
|
||||
setUnhandledExceptionHook {
|
||||
println("Hook")
|
||||
throw Error("another error")
|
||||
}
|
||||
|
||||
throw Error("an error")
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// No termination is going on here. But that's the closest location to other unhandled exception hook tests.
|
||||
// OUTPUT_DATA_FILE: unhandledExceptionHookWithProcess.out
|
||||
@file:OptIn(kotlin.experimental.ExperimentalNativeApi::class)
|
||||
|
||||
import kotlin.concurrent.AtomicInt
|
||||
import kotlin.test.*
|
||||
|
||||
fun main() {
|
||||
val exception = Error("an error")
|
||||
val called = AtomicInt(0)
|
||||
setUnhandledExceptionHook {
|
||||
assertSame(exception, it)
|
||||
called.value = 1
|
||||
}
|
||||
|
||||
processUnhandledException(exception)
|
||||
assertEquals(1, called.value)
|
||||
}
|
||||
+99
@@ -141,4 +141,103 @@ public class FirNativeStandaloneTestGenerated extends AbstractNativeBlackBoxTest
|
||||
runTest("native/native.tests/testData/standalone/entryPoint/mainOverloadingNoArgs.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("native/native.tests/testData/standalone/termination")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@Tag("standalone")
|
||||
@EnforcedProperty(property = ClassLevelProperty.TEST_KIND, propertyValue = "STANDALONE_NO_TR")
|
||||
@UseStandardTestCaseGroupProvider()
|
||||
@Tag("frontend-fir")
|
||||
@FirPipeline()
|
||||
public class Termination {
|
||||
@Test
|
||||
public void testAllFilesPresentInTermination() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/standalone/termination"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("assertFailed.kt")
|
||||
public void testAssertFailed() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/assertFailed.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("assertPassed.kt")
|
||||
public void testAssertPassed() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/assertPassed.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("exitProcess.kt")
|
||||
public void testExitProcess() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/exitProcess.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("globalThrow.kt")
|
||||
public void testGlobalThrow() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/globalThrow.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mainThrow.kt")
|
||||
public void testMainThrow() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/mainThrow.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("processUnhandledException.kt")
|
||||
public void testProcessUnhandledException() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/processUnhandledException.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("terminateWithUnhandledException.kt")
|
||||
public void testTerminateWithUnhandledException() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/terminateWithUnhandledException.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unhandledExceptionHookClosure.kt")
|
||||
public void testUnhandledExceptionHookClosure() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/unhandledExceptionHookClosure.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unhandledExceptionHookFun.kt")
|
||||
public void testUnhandledExceptionHookFun() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/unhandledExceptionHookFun.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unhandledExceptionHookGet.kt")
|
||||
public void testUnhandledExceptionHookGet() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/unhandledExceptionHookGet.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unhandledExceptionHookTerminate.kt")
|
||||
public void testUnhandledExceptionHookTerminate() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/unhandledExceptionHookTerminate.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unhandledExceptionHookTerminateWithProcess.kt")
|
||||
public void testUnhandledExceptionHookTerminateWithProcess() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/unhandledExceptionHookTerminateWithProcess.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unhandledExceptionHookThrow.kt")
|
||||
public void testUnhandledExceptionHookThrow() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/unhandledExceptionHookThrow.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unhandledExceptionHookWithProcess.kt")
|
||||
public void testUnhandledExceptionHookWithProcess() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/unhandledExceptionHookWithProcess.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+97
@@ -134,4 +134,101 @@ public class NativeStandaloneTestGenerated extends AbstractNativeBlackBoxTest {
|
||||
runTest("native/native.tests/testData/standalone/entryPoint/mainOverloadingNoArgs.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("native/native.tests/testData/standalone/termination")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@Tag("standalone")
|
||||
@EnforcedProperty(property = ClassLevelProperty.TEST_KIND, propertyValue = "STANDALONE_NO_TR")
|
||||
@UseStandardTestCaseGroupProvider()
|
||||
public class Termination {
|
||||
@Test
|
||||
public void testAllFilesPresentInTermination() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/standalone/termination"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("assertFailed.kt")
|
||||
public void testAssertFailed() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/assertFailed.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("assertPassed.kt")
|
||||
public void testAssertPassed() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/assertPassed.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("exitProcess.kt")
|
||||
public void testExitProcess() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/exitProcess.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("globalThrow.kt")
|
||||
public void testGlobalThrow() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/globalThrow.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mainThrow.kt")
|
||||
public void testMainThrow() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/mainThrow.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("processUnhandledException.kt")
|
||||
public void testProcessUnhandledException() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/processUnhandledException.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("terminateWithUnhandledException.kt")
|
||||
public void testTerminateWithUnhandledException() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/terminateWithUnhandledException.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unhandledExceptionHookClosure.kt")
|
||||
public void testUnhandledExceptionHookClosure() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/unhandledExceptionHookClosure.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unhandledExceptionHookFun.kt")
|
||||
public void testUnhandledExceptionHookFun() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/unhandledExceptionHookFun.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unhandledExceptionHookGet.kt")
|
||||
public void testUnhandledExceptionHookGet() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/unhandledExceptionHookGet.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unhandledExceptionHookTerminate.kt")
|
||||
public void testUnhandledExceptionHookTerminate() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/unhandledExceptionHookTerminate.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unhandledExceptionHookTerminateWithProcess.kt")
|
||||
public void testUnhandledExceptionHookTerminateWithProcess() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/unhandledExceptionHookTerminateWithProcess.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unhandledExceptionHookThrow.kt")
|
||||
public void testUnhandledExceptionHookThrow() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/unhandledExceptionHookThrow.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unhandledExceptionHookWithProcess.kt")
|
||||
public void testUnhandledExceptionHookWithProcess() throws Exception {
|
||||
runTest("native/native.tests/testData/standalone/termination/unhandledExceptionHookWithProcess.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user