mirror of
https://github.com/ziglang/zig.git
synced 2026-02-16 06:18:32 +00:00
Fix testing.allocator wiring
This commit is contained in:
parent
5c8e85f388
commit
184128fd9e
@ -14,12 +14,6 @@ pub fn main() anyerror!void {
|
||||
|
||||
for (test_fn_list) |test_fn, i| {
|
||||
std.testing.base_allocator_instance.reset();
|
||||
defer {
|
||||
std.testing.allocator_instance.validate() catch |err| switch (err) {
|
||||
error.Leak => std.debug.panic("", .{}),
|
||||
else => std.debug.panic("error.{}", .{@errorName(err)}),
|
||||
};
|
||||
}
|
||||
|
||||
var test_node = root_node.start(test_fn.name, null);
|
||||
test_node.activate();
|
||||
@ -30,6 +24,10 @@ pub fn main() anyerror!void {
|
||||
if (test_fn.func()) |_| {
|
||||
ok_count += 1;
|
||||
test_node.end();
|
||||
std.testing.allocator_instance.validate() catch |err| switch (err) {
|
||||
error.Leak => std.debug.panic("", .{}),
|
||||
else => std.debug.panic("error.{}", .{@errorName(err)}),
|
||||
};
|
||||
if (progress.terminal == null) std.debug.warn("OK\n", .{});
|
||||
} else |err| switch (err) {
|
||||
error.SkipZigTest => {
|
||||
|
||||
@ -23,10 +23,11 @@ pub const LeakCountAllocator = struct {
|
||||
|
||||
fn realloc(allocator: *std.mem.Allocator, old_mem: []u8, old_align: u29, new_size: usize, new_align: u29) ![]u8 {
|
||||
const self = @fieldParentPtr(LeakCountAllocator, "allocator", allocator);
|
||||
var data = try self.internal_allocator.reallocFn(self.internal_allocator, old_mem, old_align, new_size, new_align);
|
||||
if (old_mem.len == 0) {
|
||||
self.count += 1;
|
||||
}
|
||||
return self.internal_allocator.reallocFn(self.internal_allocator, old_mem, old_align, new_size, new_align);
|
||||
return data;
|
||||
}
|
||||
|
||||
fn shrink(allocator: *std.mem.Allocator, old_mem: []u8, old_align: u29, new_size: usize, new_align: u29) []u8 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user