aboutsummaryrefslogtreecommitdiff
path: root/core/testing/testing.odin
diff options
context:
space:
mode:
authorFeoramund <161657516+Feoramund@users.noreply.github.com>2024-06-15 10:25:58 -0400
committerFeoramund <161657516+Feoramund@users.noreply.github.com>2024-06-15 10:46:47 -0400
commit784408358d39346b410df65b9f657007c467a010 (patch)
treef3b39a7fa1e68ce0a2689804849a56c9131b2623 /core/testing/testing.odin
parent94ec647923e2ba0d89351a55f80b8711c3b68a13 (diff)
Call `cleanups` after test signal
Diffstat (limited to 'core/testing/testing.odin')
-rw-r--r--core/testing/testing.odin12
1 files changed, 11 insertions, 1 deletions
diff --git a/core/testing/testing.odin b/core/testing/testing.odin
index 92b4d391d..07e2063ca 100644
--- a/core/testing/testing.odin
+++ b/core/testing/testing.odin
@@ -94,7 +94,17 @@ logf :: proc(t: ^T, format: string, args: ..any, loc := #caller_location) {
// cleanup registers a procedure and user_data, which will be called when the test, and all its subtests, complete.
// Cleanup procedures will be called in LIFO (last added, first called) order.
-// Each procedure will use a copy of the context at the time of registering.
+//
+// Each procedure will use a copy of the context at the time of registering,
+// and if the test failed due to a timeout, failed assertion, panic, bounds-checking error,
+// memory access violation, or any other signal-based fault, this procedure will
+// run with greater privilege in the test runner's main thread.
+//
+// That means that any cleanup procedure absolutely must not fail in the same way,
+// or it will take down the entire test runner with it. This is for when you
+// need something to run no matter what, if a test failed.
+//
+// For almost every usual case, `defer` should be preferable and sufficient.
cleanup :: proc(t: ^T, procedure: proc(rawptr), user_data: rawptr) {
append(&t.cleanups, Internal_Cleanup{procedure, user_data, context})
}