aboutsummaryrefslogtreecommitdiff
path: root/core/testing/testing.odin
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2024-08-08 20:58:25 +0200
committerJeroen van Rijn <Kelimion@users.noreply.github.com>2024-08-08 20:58:25 +0200
commit4d27898418e3bdf8d6de5baccc135e2146085349 (patch)
tree806aba79b3cba0319413d8e59853889c6971b541 /core/testing/testing.odin
parent80d1e1ba82cb21edb0a5263ea616d7105038bc0e (diff)
Use test runner's own tracking allocator.
Diffstat (limited to 'core/testing/testing.odin')
-rw-r--r--core/testing/testing.odin15
1 files changed, 7 insertions, 8 deletions
diff --git a/core/testing/testing.odin b/core/testing/testing.odin
index 5282f5a20..b7cd23adf 100644
--- a/core/testing/testing.odin
+++ b/core/testing/testing.odin
@@ -141,20 +141,19 @@ expect_value :: proc(t: ^T, value, expected: $T, loc := #caller_location) -> boo
Memory_Verifier_Proc :: #type proc(t: ^T, ta: ^mem.Tracking_Allocator)
expect_leaks :: proc(t: ^T, client_test: proc(t: ^T), verifier: Memory_Verifier_Proc) {
- {
- ta: mem.Tracking_Allocator
- mem.tracking_allocator_init(&ta, context.allocator)
- defer mem.tracking_allocator_destroy(&ta)
- context.allocator = mem.tracking_allocator(&ta)
-
+ when TRACKING_MEMORY {
client_test(t)
+ ta := (^mem.Tracking_Allocator)(context.allocator.data)
+
sync.mutex_lock(&ta.mutex)
// The verifier can inspect this local tracking allocator.
// And then call `testing.expect_*` as makes sense for the client test.
- verifier(t, &ta)
+ verifier(t, ta)
sync.mutex_unlock(&ta.mutex)
+
+ clear(&ta.bad_free_array)
+ free_all(context.allocator)
}
- free_all(context.allocator)
}
set_fail_timeout :: proc(t: ^T, duration: time.Duration, loc := #caller_location) {