mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 14:48:47 +00:00
Add testing.fail_now
This commit is contained in:
@@ -156,7 +156,7 @@ run_internal_test :: proc(t: ^T, it: Internal_Test) {
|
|||||||
|
|
||||||
context.assertion_failure_proc = proc(prefix, message: string, loc: runtime.Source_Code_Location) {
|
context.assertion_failure_proc = proc(prefix, message: string, loc: runtime.Source_Code_Location) {
|
||||||
errorf(t=global_current_t, format="%s %s", args={prefix, message}, loc=loc);
|
errorf(t=global_current_t, format="%s %s", args={prefix, message}, loc=loc);
|
||||||
intrinsics.debug_trap();
|
intrinsics.trap();
|
||||||
};
|
};
|
||||||
|
|
||||||
thread.it.p(thread.t);
|
thread.it.p(thread.t);
|
||||||
@@ -168,6 +168,10 @@ run_internal_test :: proc(t: ^T, it: Internal_Test) {
|
|||||||
sema_reset(&global_threaded_runner_semaphore);
|
sema_reset(&global_threaded_runner_semaphore);
|
||||||
global_current_t = t;
|
global_current_t = t;
|
||||||
|
|
||||||
|
t._fail_now = proc() -> ! {
|
||||||
|
intrinsics.trap();
|
||||||
|
};
|
||||||
|
|
||||||
thread.t = t;
|
thread.t = t;
|
||||||
thread.it = it;
|
thread.it = it;
|
||||||
thread.success = false;
|
thread.success = false;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ T :: struct {
|
|||||||
w: io.Writer,
|
w: io.Writer,
|
||||||
|
|
||||||
cleanups: [dynamic]Internal_Cleanup,
|
cleanups: [dynamic]Internal_Cleanup,
|
||||||
|
|
||||||
|
_fail_now: proc() -> !,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -46,6 +48,13 @@ fail :: proc(t: ^T) {
|
|||||||
t.error_count += 1;
|
t.error_count += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fail_now :: proc(t: ^T) {
|
||||||
|
fail(t);
|
||||||
|
if t._fail_now != nil {
|
||||||
|
t._fail_now();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
failed :: proc(t: ^T) -> bool {
|
failed :: proc(t: ^T) -> bool {
|
||||||
return t.error_count != 0;
|
return t.error_count != 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user