summaryrefslogtreecommitdiff
path: root/src/mini.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/mini.zig')
-rw-r--r--src/mini.zig16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/mini.zig b/src/mini.zig
index ce291c99..8d8ea0b2 100644
--- a/src/mini.zig
+++ b/src/mini.zig
@@ -313,7 +313,21 @@ test "Mini publishes only complete snapshots and content replacement drops metad
const dir = dir_buf[0..try tmp.dir.realPath(std.testing.io, &dir_buf)];
var path_buf: [4096]u8 = undefined;
const path = try std.fmt.bufPrint(&path_buf, "{s}/mini.txt", .{dir});
- try std.testing.checkAllAllocationFailures(std.testing.allocator, Case.run, .{path});
+ // Growth that never resizes in place: whether a resize fits where it is
+ // depends on the heap's layout, and with it how many allocations a run
+ // makes, which checkAllAllocationFailures needs to be the same each run.
+ const NoResize = struct {
+ fn resize(_: *anyopaque, _: []u8, _: std.mem.Alignment, _: usize, _: usize) bool {
+ return false;
+ }
+ fn remap(_: *anyopaque, _: []u8, _: std.mem.Alignment, _: usize, _: usize) ?[*]u8 {
+ return null;
+ }
+ };
+ const testing_vtable = std.testing.allocator.vtable;
+ const no_resize_vtable: std.mem.Allocator.VTable = .{ .alloc = testing_vtable.alloc, .resize = NoResize.resize, .remap = NoResize.remap, .free = testing_vtable.free };
+ const backing: std.mem.Allocator = .{ .ptr = std.testing.allocator.ptr, .vtable = &no_resize_vtable };
+ try std.testing.checkAllAllocationFailures(backing, Case.run, .{path});
}
test "Mini refuses a file that is no UTF-8, before its decoding could panic" {