aboutsummaryrefslogtreecommitdiff
path: root/core/testing/testing.odin
diff options
context:
space:
mode:
authorFeoramund <161657516+Feoramund@users.noreply.github.com>2024-06-15 10:36:05 -0400
committerFeoramund <161657516+Feoramund@users.noreply.github.com>2024-06-15 10:53:21 -0400
commitbb823d5ba0aa412c40a0e23c9b27f00c734e9866 (patch)
tree366bcfcf45f64337636de407d024acd86a510022 /core/testing/testing.odin
parent784408358d39346b410df65b9f657007c467a010 (diff)
Make `testing.fail_now` divergent
This is in line with the old way it worked on Windows.
Diffstat (limited to 'core/testing/testing.odin')
-rw-r--r--core/testing/testing.odin15
1 files changed, 10 insertions, 5 deletions
diff --git a/core/testing/testing.odin b/core/testing/testing.odin
index 07e2063ca..29fe853ef 100644
--- a/core/testing/testing.odin
+++ b/core/testing/testing.odin
@@ -48,7 +48,7 @@ T :: struct {
// tests during channel transmission.
_log_allocator: runtime.Allocator,
- _fail_now: proc() -> !,
+ _fail_now_called: bool,
}
@@ -66,15 +66,20 @@ fail :: proc(t: ^T, loc := #caller_location) {
pkg_log.error("FAIL", location=loc)
}
-fail_now :: proc(t: ^T, msg := "", loc := #caller_location) {
+// fail_now will cause a test to immediately fail and abort, much in the same
+// way a failed assertion or panic call will stop a thread.
+//
+// It is for when you absolutely need a test to fail without calling any of its
+// deferred statements. It will be cleaner than a regular assert or panic,
+// as the test runner will know to expect the signal this procedure will raise.
+fail_now :: proc(t: ^T, msg := "", loc := #caller_location) -> ! {
+ t._fail_now_called = true
if msg != "" {
pkg_log.error("FAIL:", msg, location=loc)
} else {
pkg_log.error("FAIL", location=loc)
}
- if t._fail_now != nil {
- t._fail_now()
- }
+ runtime.trap()
}
failed :: proc(t: ^T) -> bool {