mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Call cleanups after test signal
This commit is contained in:
@@ -604,10 +604,10 @@ runner :: proc(internal_tests: []Internal_Test) -> bool {
|
|||||||
})
|
})
|
||||||
fmt.assertf(alloc_error == nil, "Error appending to log messages: %v", alloc_error)
|
fmt.assertf(alloc_error == nil, "Error appending to log messages: %v", alloc_error)
|
||||||
|
|
||||||
find_task_data: for &data in task_data_slots {
|
find_task_data_for_timeout: for &data in task_data_slots {
|
||||||
if data.it.pkg == it.pkg && data.it.name == it.name {
|
if data.it.pkg == it.pkg && data.it.name == it.name {
|
||||||
end_t(&data.t)
|
end_t(&data.t)
|
||||||
break find_task_data
|
break find_task_data_for_timeout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -655,6 +655,13 @@ runner :: proc(internal_tests: []Internal_Test) -> bool {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
find_task_data_for_stop_signal: for &data in task_data_slots {
|
||||||
|
if data.it.pkg == it.pkg && data.it.name == it.name {
|
||||||
|
end_t(&data.t)
|
||||||
|
break find_task_data_for_stop_signal
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
when FANCY_OUTPUT {
|
when FANCY_OUTPUT {
|
||||||
bypass_progress_overwrite = true
|
bypass_progress_overwrite = true
|
||||||
signals_were_raised = true
|
signals_were_raised = true
|
||||||
|
|||||||
@@ -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 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.
|
// 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) {
|
cleanup :: proc(t: ^T, procedure: proc(rawptr), user_data: rawptr) {
|
||||||
append(&t.cleanups, Internal_Cleanup{procedure, user_data, context})
|
append(&t.cleanups, Internal_Cleanup{procedure, user_data, context})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user