authorgravatar for benjamin.feng@glassdoor.comBenjamin Feng <benjamin.feng@glassdoor.com> 2020-01-29 21:22:01-06:00
committergravatar for benjamin.feng@glassdoor.comBenjamin Feng <benjamin.feng@glassdoor.com> 2020-01-29 22:22:00-06:00
logb077f3ab7d55374d2770336db236ecd7b18238a8
treed1a9453a3faf5e019afd75f3d7b59a0162ae1142
parent70ad84c8209ae7ab14472f77f9452820bc47c30e

Promoted "leak_count_allocator" to the main testing.allocator


23 files changed, 95 insertions(+), 94 deletions(-)

doc/docgen.zig+2-2
......@@ -672,8 +672,8 @@ const TermState = enum {
672672
673673test "term color" {
674674 const input_bytes = "A\x1b[32;1mgreen\x1b[0mB";
675 const result = try termColor(std.testing.leak_count_allocator, input_bytes);
676 defer std.testing.leak_count_allocator.free(result);
675 const result = try termColor(std.testing.allocator, input_bytes);
676 defer std.testing.allocator.free(result);
677677 testing.expectEqualSlices(u8, "A<span class=\"t32\">green</span>B", result);
678678}
679679
lib/std/array_list.zig+7-7
......@@ -320,7 +320,7 @@ test "std.ArrayList.basic" {
320320}
321321
322322test "std.ArrayList.orderedRemove" {
323 var list = ArrayList(i32).init(testing.leak_count_allocator);
323 var list = ArrayList(i32).init(testing.allocator);
324324 defer list.deinit();
325325
326326 try list.append(1);
......@@ -347,7 +347,7 @@ test "std.ArrayList.orderedRemove" {
347347}
348348
349349test "std.ArrayList.swapRemove" {
350 var list = ArrayList(i32).init(testing.leak_count_allocator);
350 var list = ArrayList(i32).init(testing.allocator);
351351 defer list.deinit();
352352
353353 try list.append(1);
......@@ -374,7 +374,7 @@ test "std.ArrayList.swapRemove" {
374374}
375375
376376test "std.ArrayList.swapRemoveOrError" {
377 var list = ArrayList(i32).init(testing.leak_count_allocator);
377 var list = ArrayList(i32).init(testing.allocator);
378378 defer list.deinit();
379379
380380 // Test just after initialization
......@@ -402,7 +402,7 @@ test "std.ArrayList.swapRemoveOrError" {
402402}
403403
404404test "std.ArrayList.insert" {
405 var list = ArrayList(i32).init(testing.leak_count_allocator);
405 var list = ArrayList(i32).init(testing.allocator);
406406 defer list.deinit();
407407
408408 try list.append(1);
......@@ -416,7 +416,7 @@ test "std.ArrayList.insert" {
416416}
417417
418418test "std.ArrayList.insertSlice" {
419 var list = ArrayList(i32).init(testing.leak_count_allocator);
419 var list = ArrayList(i32).init(testing.allocator);
420420 defer list.deinit();
421421
422422 try list.append(1);
......@@ -443,8 +443,8 @@ const Item = struct {
443443};
444444
445445test "std.ArrayList: ArrayList(T) of struct T" {
446 var root = Item{ .integer = 1, .sub_items = ArrayList(Item).init(testing.leak_count_allocator) };
446 var root = Item{ .integer = 1, .sub_items = ArrayList(Item).init(testing.allocator) };
447447 defer root.sub_items.deinit();
448 try root.sub_items.append(Item{ .integer = 42, .sub_items = ArrayList(Item).init(testing.leak_count_allocator) });
448 try root.sub_items.append(Item{ .integer = 42, .sub_items = ArrayList(Item).init(testing.allocator) });
449449 testing.expect(root.sub_items.items[0].integer == 42);
450450}
lib/std/buffer.zig+3-3
......@@ -150,7 +150,7 @@ pub const Buffer = struct {
150150};
151151
152152test "simple Buffer" {
153 var buf = try Buffer.init(testing.leak_count_allocator, "");
153 var buf = try Buffer.init(testing.allocator, "");
154154 defer buf.deinit();
155155
156156 testing.expect(buf.len() == 0);
......@@ -172,7 +172,7 @@ test "simple Buffer" {
172172}
173173
174174test "Buffer.initSize" {
175 var buf = try Buffer.initSize(testing.leak_count_allocator, 3);
175 var buf = try Buffer.initSize(testing.allocator, 3);
176176 defer buf.deinit();
177177 testing.expect(buf.len() == 3);
178178 try buf.append("hello");
......@@ -180,7 +180,7 @@ test "Buffer.initSize" {
180180}
181181
182182test "Buffer.initCapacity" {
183 var buf = try Buffer.initCapacity(testing.leak_count_allocator, 10);
183 var buf = try Buffer.initCapacity(testing.allocator, 10);
184184 defer buf.deinit();
185185 testing.expect(buf.len() == 0);
186186 testing.expect(buf.capacity() >= 10);
lib/std/debug.zig+1-1
......@@ -19,7 +19,7 @@ const windows = std.os.windows;
1919
2020pub const leb = @import("debug/leb128.zig");
2121
22pub const global_allocator = @compileError("Please switch to std.testing.leak_count_allocator.");
22pub const global_allocator = @compileError("Please switch to std.testing.allocator.");
2323pub const failing_allocator = @compileError("Please switch to std.testing.failing_allocator.");
2424
2525pub const runtime_safety = switch (builtin.mode) {
lib/std/fifo.zig+2-2
......@@ -347,7 +347,7 @@ pub fn LinearFifo(
347347}
348348
349349test "LinearFifo(u8, .Dynamic)" {
350 var fifo = LinearFifo(u8, .Dynamic).init(testing.leak_count_allocator);
350 var fifo = LinearFifo(u8, .Dynamic).init(testing.allocator);
351351 defer fifo.deinit();
352352
353353 try fifo.write("HELLO");
......@@ -422,7 +422,7 @@ test "LinearFifo" {
422422 var fifo = switch (bt) {
423423 .Static => FifoType.init(),
424424 .Slice => FifoType.init(buf[0..]),
425 .Dynamic => FifoType.init(testing.leak_count_allocator),
425 .Dynamic => FifoType.init(testing.allocator),
426426 };
427427 defer fifo.deinit();
428428
lib/std/fmt.zig+5-5
......@@ -1598,7 +1598,7 @@ test "hexToBytes" {
15981598test "formatIntValue with comptime_int" {
15991599 const value: comptime_int = 123456789123456789;
16001600
1601 var buf = try std.Buffer.init(std.testing.leak_count_allocator, "");
1601 var buf = try std.Buffer.init(std.testing.allocator, "");
16021602 defer buf.deinit();
16031603 try formatIntValue(value, "", FormatOptions{}, &buf, @TypeOf(std.Buffer.append).ReturnType.ErrorSet, std.Buffer.append);
16041604 std.testing.expect(mem.eql(u8, buf.toSlice(), "123456789123456789"));
......@@ -1653,22 +1653,22 @@ test "formatType max_depth" {
16531653 inst.a = &inst;
16541654 inst.tu.ptr = &inst.tu;
16551655
1656 var buf0 = try std.Buffer.init(std.testing.leak_count_allocator, "");
1656 var buf0 = try std.Buffer.init(std.testing.allocator, "");
16571657 defer buf0.deinit();
16581658 try formatType(inst, "", FormatOptions{}, &buf0, @TypeOf(std.Buffer.append).ReturnType.ErrorSet, std.Buffer.append, 0);
16591659 std.testing.expect(mem.eql(u8, buf0.toSlice(), "S{ ... }"));
16601660
1661 var buf1 = try std.Buffer.init(std.testing.leak_count_allocator, "");
1661 var buf1 = try std.Buffer.init(std.testing.allocator, "");
16621662 defer buf1.deinit();
16631663 try formatType(inst, "", FormatOptions{}, &buf1, @TypeOf(std.Buffer.append).ReturnType.ErrorSet, std.Buffer.append, 1);
16641664 std.testing.expect(mem.eql(u8, buf1.toSlice(), "S{ .a = S{ ... }, .tu = TU{ ... }, .e = E.Two, .vec = (10.200,2.220) }"));
16651665
1666 var buf2 = try std.Buffer.init(std.testing.leak_count_allocator, "");
1666 var buf2 = try std.Buffer.init(std.testing.allocator, "");
16671667 defer buf2.deinit();
16681668 try formatType(inst, "", FormatOptions{}, &buf2, @TypeOf(std.Buffer.append).ReturnType.ErrorSet, std.Buffer.append, 2);
16691669 std.testing.expect(mem.eql(u8, buf2.toSlice(), "S{ .a = S{ .a = S{ ... }, .tu = TU{ ... }, .e = E.Two, .vec = (10.200,2.220) }, .tu = TU{ .ptr = TU{ ... } }, .e = E.Two, .vec = (10.200,2.220) }"));
16701670
1671 var buf3 = try std.Buffer.init(std.testing.leak_count_allocator, "");
1671 var buf3 = try std.Buffer.init(std.testing.allocator, "");
16721672 defer buf3.deinit();
16731673 try formatType(inst, "", FormatOptions{}, &buf3, @TypeOf(std.Buffer.append).ReturnType.ErrorSet, std.Buffer.append, 3);
16741674 std.testing.expect(mem.eql(u8, buf3.toSlice(), "S{ .a = S{ .a = S{ .a = S{ ... }, .tu = TU{ ... }, .e = E.Two, .vec = (10.200,2.220) }, .tu = TU{ .ptr = TU{ ... } }, .e = E.Two, .vec = (10.200,2.220) }, .tu = TU{ .ptr = TU{ .ptr = TU{ ... } } }, .e = E.Two, .vec = (10.200,2.220) }"));
lib/std/fs/path.zig+16-16
......@@ -665,8 +665,8 @@ pub fn resolvePosix(allocator: *Allocator, paths: []const []const u8) ![]u8 {
665665}
666666
667667test "resolve" {
668 const cwd = try process.getCwdAlloc(testing.leak_count_allocator);
669 defer testing.leak_count_allocator.free(cwd);
668 const cwd = try process.getCwdAlloc(testing.allocator);
669 defer testing.allocator.free(cwd);
670670 if (builtin.os == .windows) {
671671 if (windowsParsePath(cwd).kind == WindowsPath.Kind.Drive) {
672672 cwd[0] = asciiUpper(cwd[0]);
......@@ -684,26 +684,26 @@ test "resolveWindows" {
684684 return error.SkipZigTest;
685685 }
686686 if (builtin.os == .windows) {
687 const cwd = try process.getCwdAlloc(testing.leak_count_allocator);
688 defer testing.leak_count_allocator.free(cwd);
687 const cwd = try process.getCwdAlloc(testing.allocator);
688 defer testing.allocator.free(cwd);
689689 const parsed_cwd = windowsParsePath(cwd);
690690 {
691 const expected = try join(testing.leak_count_allocator, &[_][]const u8{
691 const expected = try join(testing.allocator, &[_][]const u8{
692692 parsed_cwd.disk_designator,
693693 "usr\\local\\lib\\zig\\std\\array_list.zig",
694694 });
695 defer testing.leak_count_allocator.free(expected);
695 defer testing.allocator.free(expected);
696696 if (parsed_cwd.kind == WindowsPath.Kind.Drive) {
697697 expected[0] = asciiUpper(parsed_cwd.disk_designator[0]);
698698 }
699699 try testResolveWindows(&[_][]const u8{ "/usr/local", "lib\\zig\\std\\array_list.zig" }, expected);
700700 }
701701 {
702 const expected = try join(testing.leak_count_allocator, &[_][]const u8{
702 const expected = try join(testing.allocator, &[_][]const u8{
703703 cwd,
704704 "usr\\local\\lib\\zig",
705705 });
706 defer testing.leak_count_allocator.free(expected);
706 defer testing.allocator.free(expected);
707707 if (parsed_cwd.kind == WindowsPath.Kind.Drive) {
708708 expected[0] = asciiUpper(parsed_cwd.disk_designator[0]);
709709 }
......@@ -740,14 +740,14 @@ test "resolvePosix" {
740740}
741741
742742fn testResolveWindows(paths: []const []const u8, expected: []const u8) !void {
743 const actual = try resolveWindows(testing.leak_count_allocator, paths);
744 defer testing.leak_count_allocator.free(actual);
743 const actual = try resolveWindows(testing.allocator, paths);
744 defer testing.allocator.free(actual);
745745 return testing.expect(mem.eql(u8, actual, expected));
746746}
747747
748748fn testResolvePosix(paths: []const []const u8, expected: []const u8) !void {
749 const actual = try resolvePosix(testing.leak_count_allocator, paths);
750 defer testing.leak_count_allocator.free(actual);
749 const actual = try resolvePosix(testing.allocator, paths);
750 defer testing.allocator.free(actual);
751751 return testing.expect(mem.eql(u8, actual, expected));
752752}
753753
......@@ -1172,13 +1172,13 @@ test "relative" {
11721172}
11731173
11741174fn testRelativePosix(from: []const u8, to: []const u8, expected_output: []const u8) !void {
1175 const result = try relativePosix(testing.leak_count_allocator, from, to);
1176 defer testing.leak_count_allocator.free(result);
1175 const result = try relativePosix(testing.allocator, from, to);
1176 defer testing.allocator.free(result);
11771177 testing.expectEqualSlices(u8, expected_output, result);
11781178}
11791179
11801180fn testRelativeWindows(from: []const u8, to: []const u8, expected_output: []const u8) !void {
1181 const result = try relativeWindows(testing.leak_count_allocator, from, to);
1182 defer testing.leak_count_allocator.free(result);
1181 const result = try relativeWindows(testing.allocator, from, to);
1182 defer testing.allocator.free(result);
11831183 testing.expectEqualSlices(u8, expected_output, result);
11841184}
lib/std/linked_list.zig+3-3
......@@ -143,7 +143,7 @@ pub fn SinglyLinkedList(comptime T: type) type {
143143}
144144
145145test "basic SinglyLinkedList test" {
146 const allocator = testing.leak_count_allocator;
146 const allocator = testing.allocator;
147147 var list = SinglyLinkedList(u32).init();
148148
149149 var one = try list.createNode(1, allocator);
......@@ -404,7 +404,7 @@ pub fn TailQueue(comptime T: type) type {
404404}
405405
406406test "basic TailQueue test" {
407 const allocator = testing.leak_count_allocator;
407 const allocator = testing.allocator;
408408 var list = TailQueue(u32).init();
409409
410410 var one = try list.createNode(1, allocator);
......@@ -456,7 +456,7 @@ test "basic TailQueue test" {
456456}
457457
458458test "TailQueue concatenation" {
459 const allocator = testing.leak_count_allocator;
459 const allocator = testing.allocator;
460460 var list1 = TailQueue(u32).init();
461461 var list2 = TailQueue(u32).init();
462462
lib/std/os/test.zig+1-1
......@@ -9,7 +9,7 @@ const elf = std.elf;
99const File = std.fs.File;
1010const Thread = std.Thread;
1111
12const a = std.testing.leak_count_allocator;
12const a = std.testing.allocator;
1313
1414const builtin = @import("builtin");
1515const AtomicRmwOp = builtin.AtomicRmwOp;
lib/std/priority_queue.zig+14-14
......@@ -239,7 +239,7 @@ fn greaterThan(a: u32, b: u32) bool {
239239const PQ = PriorityQueue(u32);
240240
241241test "std.PriorityQueue: add and remove min heap" {
242 var queue = PQ.init(testing.leak_count_allocator, lessThan);
242 var queue = PQ.init(testing.allocator, lessThan);
243243 defer queue.deinit();
244244
245245 try queue.add(54);
......@@ -257,7 +257,7 @@ test "std.PriorityQueue: add and remove min heap" {
257257}
258258
259259test "std.PriorityQueue: add and remove same min heap" {
260 var queue = PQ.init(testing.leak_count_allocator, lessThan);
260 var queue = PQ.init(testing.allocator, lessThan);
261261 defer queue.deinit();
262262
263263 try queue.add(1);
......@@ -275,14 +275,14 @@ test "std.PriorityQueue: add and remove same min heap" {
275275}
276276
277277test "std.PriorityQueue: removeOrNull on empty" {
278 var queue = PQ.init(testing.leak_count_allocator, lessThan);
278 var queue = PQ.init(testing.allocator, lessThan);
279279 defer queue.deinit();
280280
281281 expect(queue.removeOrNull() == null);
282282}
283283
284284test "std.PriorityQueue: edge case 3 elements" {
285 var queue = PQ.init(testing.leak_count_allocator, lessThan);
285 var queue = PQ.init(testing.allocator, lessThan);
286286 defer queue.deinit();
287287
288288 try queue.add(9);
......@@ -294,7 +294,7 @@ test "std.PriorityQueue: edge case 3 elements" {
294294}
295295
296296test "std.PriorityQueue: peek" {
297 var queue = PQ.init(testing.leak_count_allocator, lessThan);
297 var queue = PQ.init(testing.allocator, lessThan);
298298 defer queue.deinit();
299299
300300 expect(queue.peek() == null);
......@@ -306,7 +306,7 @@ test "std.PriorityQueue: peek" {
306306}
307307
308308test "std.PriorityQueue: sift up with odd indices" {
309 var queue = PQ.init(testing.leak_count_allocator, lessThan);
309 var queue = PQ.init(testing.allocator, lessThan);
310310 defer queue.deinit();
311311 const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 };
312312 for (items) |e| {
......@@ -320,7 +320,7 @@ test "std.PriorityQueue: sift up with odd indices" {
320320}
321321
322322test "std.PriorityQueue: addSlice" {
323 var queue = PQ.init(testing.leak_count_allocator, lessThan);
323 var queue = PQ.init(testing.allocator, lessThan);
324324 defer queue.deinit();
325325 const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 };
326326 try queue.addSlice(items[0..]);
......@@ -333,8 +333,8 @@ test "std.PriorityQueue: addSlice" {
333333
334334test "std.PriorityQueue: fromOwnedSlice" {
335335 const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 };
336 const heap_items = try std.mem.dupe(testing.leak_count_allocator, u32, items[0..]);
337 var queue = PQ.fromOwnedSlice(testing.leak_count_allocator, lessThan, heap_items[0..]);
336 const heap_items = try std.mem.dupe(testing.allocator, u32, items[0..]);
337 var queue = PQ.fromOwnedSlice(testing.allocator, lessThan, heap_items[0..]);
338338 defer queue.deinit();
339339
340340 const sorted_items = [_]u32{ 1, 2, 5, 6, 7, 7, 11, 12, 13, 14, 15, 15, 16, 21, 22, 24, 24, 25 };
......@@ -344,7 +344,7 @@ test "std.PriorityQueue: fromOwnedSlice" {
344344}
345345
346346test "std.PriorityQueue: add and remove max heap" {
347 var queue = PQ.init(testing.leak_count_allocator, greaterThan);
347 var queue = PQ.init(testing.allocator, greaterThan);
348348 defer queue.deinit();
349349
350350 try queue.add(54);
......@@ -362,7 +362,7 @@ test "std.PriorityQueue: add and remove max heap" {
362362}
363363
364364test "std.PriorityQueue: add and remove same max heap" {
365 var queue = PQ.init(testing.leak_count_allocator, greaterThan);
365 var queue = PQ.init(testing.allocator, greaterThan);
366366 defer queue.deinit();
367367
368368 try queue.add(1);
......@@ -380,8 +380,8 @@ test "std.PriorityQueue: add and remove same max heap" {
380380}
381381
382382test "std.PriorityQueue: iterator" {
383 var queue = PQ.init(testing.leak_count_allocator, lessThan);
384 var map = std.AutoHashMap(u32, void).init(testing.leak_count_allocator);
383 var queue = PQ.init(testing.allocator, lessThan);
384 var map = std.AutoHashMap(u32, void).init(testing.allocator);
385385 defer {
386386 queue.deinit();
387387 map.deinit();
......@@ -402,7 +402,7 @@ test "std.PriorityQueue: iterator" {
402402}
403403
404404test "std.PriorityQueue: remove at index" {
405 var queue = PQ.init(testing.leak_count_allocator, lessThan);
405 var queue = PQ.init(testing.allocator, lessThan);
406406 defer queue.deinit();
407407
408408 try queue.add(3);
lib/std/process.zig+5-5
......@@ -114,7 +114,7 @@ pub fn getEnvMap(allocator: *Allocator) !BufMap {
114114}
115115
116116test "os.getEnvMap" {
117 var env = try getEnvMap(std.testing.leak_count_allocator);
117 var env = try getEnvMap(std.testing.allocator);
118118 defer env.deinit();
119119}
120120
......@@ -165,7 +165,7 @@ pub fn getEnvVarOwned(allocator: *mem.Allocator, key: []const u8) GetEnvVarOwned
165165}
166166
167167test "os.getEnvVarOwned" {
168 var ga = std.testing.leak_count_allocator;
168 var ga = std.testing.allocator;
169169 testing.expectError(error.EnvironmentVariableNotFound, getEnvVarOwned(ga, "BADENV"));
170170}
171171
......@@ -492,11 +492,11 @@ test "windows arg parsing" {
492492fn testWindowsCmdLine(input_cmd_line: [*]const u8, expected_args: []const []const u8) void {
493493 var it = ArgIteratorWindows.initWithCmdLine(input_cmd_line);
494494 for (expected_args) |expected_arg| {
495 const arg = it.next(std.testing.leak_count_allocator).? catch unreachable;
496 defer std.testing.leak_count_allocator.free(arg);
495 const arg = it.next(std.testing.allocator).? catch unreachable;
496 defer std.testing.allocator.free(arg);
497497 testing.expectEqualSlices(u8, expected_arg, arg);
498498 }
499 testing.expect(it.next(std.testing.leak_count_allocator) == null);
499 testing.expect(it.next(std.testing.allocator) == null);
500500}
501501
502502pub const UserInfo = struct {
lib/std/special/test_runner.zig+4-3
......@@ -13,10 +13,11 @@ pub fn main() anyerror!void {
1313 };
1414
1515 for (test_fn_list) |test_fn, i| {
16 std.testing.allocator_instance.reset();
16 std.testing.base_allocator_instance.reset();
1717 defer {
18 std.testing.leak_count_allocator_instance.validate() catch |err| {
19 @panic(@errorName(err));
18 std.testing.allocator_instance.validate() catch |err| switch (err) {
19 error.Leak => std.debug.panic("", .{}),
20 else => std.debug.panic("error.{}", .{@errorName(err)}),
2021 };
2122 }
2223
lib/std/testing.zig+7-7
......@@ -2,17 +2,17 @@ const builtin = @import("builtin");
22const TypeId = builtin.TypeId;
33const std = @import("std.zig");
44
5pub const LeakCountAllocator = @import("testing/leak_count_allocator.zig").LeakCountAllocator;
6pub const FailingAllocator = @import("testing/failing_allocator.zig").FailingAllocator;
7
58/// This should only be used in temporary test programs.
69pub const allocator = &allocator_instance.allocator;
7pub var allocator_instance = std.heap.ThreadSafeFixedBufferAllocator.init(allocator_mem[0..]);
8var allocator_mem: [100 * 1024]u8 = undefined;
10pub var allocator_instance = LeakCountAllocator.init(&base_allocator_instance.allocator);
911
10pub const FailingAllocator = @import("testing/failing_allocator.zig").FailingAllocator;
11pub const failing_allocator = &FailingAllocator.init(allocator, 0).allocator;
12pub const failing_allocator = &FailingAllocator.init(&base_allocator_instance.allocator, 0).allocator;
1213
13pub const LeakCountAllocator = @import("testing/leak_count_allocator.zig").LeakCountAllocator;
14pub var leak_count_allocator_instance = LeakCountAllocator.init(allocator);
15pub const leak_count_allocator = &leak_count_allocator_instance.allocator;
14pub var base_allocator_instance = std.heap.ThreadSafeFixedBufferAllocator.init(allocator_mem[0..]);
15var allocator_mem: [100 * 1024]u8 = undefined;
1616
1717/// This function is intended to be used only in tests. It prints diagnostics to stderr
1818/// and then aborts when actual_error_union is not expected_error.
lib/std/testing/leak_count_allocator.zig+1-1
......@@ -39,7 +39,7 @@ pub const LeakCountAllocator = struct {
3939
4040 pub fn validate(self: LeakCountAllocator) !void {
4141 if (self.count > 0) {
42 std.debug.warn("Detected leaked allocations without matching free: {}\n", .{self.count});
42 std.debug.warn("error - detected leaked allocations without matching free: {}\n", .{self.count});
4343 return error.Leak;
4444 }
4545 }
lib/std/unicode.zig+12-12
......@@ -501,16 +501,16 @@ test "utf16leToUtf8" {
501501 {
502502 mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 'A');
503503 mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 'a');
504 const utf8 = try utf16leToUtf8Alloc(std.testing.leak_count_allocator, &utf16le);
505 defer std.testing.leak_count_allocator.free(utf8);
504 const utf8 = try utf16leToUtf8Alloc(std.testing.allocator, &utf16le);
505 defer std.testing.allocator.free(utf8);
506506 testing.expect(mem.eql(u8, utf8, "Aa"));
507507 }
508508
509509 {
510510 mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0x80);
511511 mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xffff);
512 const utf8 = try utf16leToUtf8Alloc(std.testing.leak_count_allocator, &utf16le);
513 defer std.testing.leak_count_allocator.free(utf8);
512 const utf8 = try utf16leToUtf8Alloc(std.testing.allocator, &utf16le);
513 defer std.testing.allocator.free(utf8);
514514 testing.expect(mem.eql(u8, utf8, "\xc2\x80" ++ "\xef\xbf\xbf"));
515515 }
516516
......@@ -518,8 +518,8 @@ test "utf16leToUtf8" {
518518 // the values just outside the surrogate half range
519519 mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0xd7ff);
520520 mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xe000);
521 const utf8 = try utf16leToUtf8Alloc(std.testing.leak_count_allocator, &utf16le);
522 defer std.testing.leak_count_allocator.free(utf8);
521 const utf8 = try utf16leToUtf8Alloc(std.testing.allocator, &utf16le);
522 defer std.testing.allocator.free(utf8);
523523 testing.expect(mem.eql(u8, utf8, "\xed\x9f\xbf" ++ "\xee\x80\x80"));
524524 }
525525
......@@ -527,8 +527,8 @@ test "utf16leToUtf8" {
527527 // smallest surrogate pair
528528 mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0xd800);
529529 mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xdc00);
530 const utf8 = try utf16leToUtf8Alloc(std.testing.leak_count_allocator, &utf16le);
531 defer std.testing.leak_count_allocator.free(utf8);
530 const utf8 = try utf16leToUtf8Alloc(std.testing.allocator, &utf16le);
531 defer std.testing.allocator.free(utf8);
532532 testing.expect(mem.eql(u8, utf8, "\xf0\x90\x80\x80"));
533533 }
534534
......@@ -536,16 +536,16 @@ test "utf16leToUtf8" {
536536 // largest surrogate pair
537537 mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0xdbff);
538538 mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xdfff);
539 const utf8 = try utf16leToUtf8Alloc(std.testing.leak_count_allocator, &utf16le);
540 defer std.testing.leak_count_allocator.free(utf8);
539 const utf8 = try utf16leToUtf8Alloc(std.testing.allocator, &utf16le);
540 defer std.testing.allocator.free(utf8);
541541 testing.expect(mem.eql(u8, utf8, "\xf4\x8f\xbf\xbf"));
542542 }
543543
544544 {
545545 mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0xdbff);
546546 mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xdc00);
547 const utf8 = try utf16leToUtf8Alloc(std.testing.leak_count_allocator, &utf16le);
548 defer std.testing.leak_count_allocator.free(utf8);
547 const utf8 = try utf16leToUtf8Alloc(std.testing.allocator, &utf16le);
548 defer std.testing.allocator.free(utf8);
549549 testing.expect(mem.eql(u8, utf8, "\xf4\x8f\xb0\x80"));
550550 }
551551}
lib/std/zig/ast.zig+1-1
......@@ -2287,7 +2287,7 @@ pub const Node = struct {
22872287test "iterate" {
22882288 var root = Node.Root{
22892289 .base = Node{ .id = Node.Id.Root },
2290 .decls = Node.Root.DeclList.init(std.testing.leak_count_allocator),
2290 .decls = Node.Root.DeclList.init(std.testing.allocator),
22912291 .eof_token = 0,
22922292 };
22932293 var base = &root.base;
test/compare_output.zig+2-2
......@@ -445,7 +445,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
445445 \\const std = @import("std");
446446 \\const io = std.io;
447447 \\const os = std.os;
448 \\const allocator = std.testing.leak_count_allocator;
448 \\const allocator = std.testing.allocator;
449449 \\
450450 \\pub fn main() !void {
451451 \\ var args_it = std.process.args();
......@@ -486,7 +486,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
486486 \\const std = @import("std");
487487 \\const io = std.io;
488488 \\const os = std.os;
489 \\const allocator = std.testing.leak_count_allocator;
489 \\const allocator = std.testing.allocator;
490490 \\
491491 \\pub fn main() !void {
492492 \\ var args_it = std.process.args();
test/compile_errors.zig+1-1
......@@ -5765,7 +5765,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
57655765 \\
57665766 \\export fn entry() void {
57675767 \\ const a = MdNode.Header {
5768 \\ .text = MdText.init(&std.testing.leak_count_allocator),
5768 \\ .text = MdText.init(&std.testing.allocator),
57695769 \\ .weight = HeaderWeight.H1,
57705770 \\ };
57715771 \\}
test/stage1/behavior/const_slice_child.zig+2-2
......@@ -23,8 +23,8 @@ fn foo(args: [][]const u8) void {
2323}
2424
2525fn bar(argc: usize) void {
26 const args = testing.leak_count_allocator.alloc([]const u8, argc) catch unreachable;
27 defer testing.leak_count_allocator.free(args);
26 const args = testing.allocator.alloc([]const u8, argc) catch unreachable;
27 defer testing.allocator.free(args);
2828 for (args) |_, i| {
2929 const ptr = argv[i];
3030 args[i] = ptr[0..strlen(ptr)];
test/standalone/brace_expansion/main.zig+2-2
......@@ -201,7 +201,7 @@ pub fn main() !void {
201201}
202202
203203test "invalid inputs" {
204 global_allocator = std.testing.leak_count_allocator;
204 global_allocator = std.testing.allocator;
205205
206206 expectError("}ABC", error.InvalidInput);
207207 expectError("{ABC", error.InvalidInput);
......@@ -222,7 +222,7 @@ fn expectError(test_input: []const u8, expected_err: anyerror) void {
222222}
223223
224224test "valid inputs" {
225 global_allocator = std.testing.leak_count_allocator;
225 global_allocator = std.testing.allocator;
226226
227227 expectExpansion("{x,y,z}", "x y z");
228228 expectExpansion("{A,B}{x,y}", "Ax Ay Bx By");
test/standalone/cat/main.zig+1-1
......@@ -4,7 +4,7 @@ const process = std.process;
44const fs = std.fs;
55const mem = std.mem;
66const warn = std.debug.warn;
7const allocator = std.testing.leak_count_allocator;
7const allocator = std.testing.allocator;
88
99pub fn main() !void {
1010 var args_it = process.args();
test/standalone/empty_env/main.zig+1-1
......@@ -1,6 +1,6 @@
11const std = @import("std");
22
33pub fn main() void {
4 const env_map = std.process.getEnvMap(std.testing.leak_count_allocator) catch @panic("unable to get env map");
4 const env_map = std.process.getEnvMap(std.testing.allocator) catch @panic("unable to get env map");
55 std.testing.expect(env_map.count() == 0);
66}
test/standalone/load_dynamic_library/main.zig+2-2
......@@ -1,8 +1,8 @@
11const std = @import("std");
22
33pub fn main() !void {
4 const args = try std.process.argsAlloc(std.testing.leak_count_allocator);
5 defer std.process.argsFree(std.testing.leak_count_allocator, args);
4 const args = try std.process.argsAlloc(std.testing.allocator);
5 defer std.process.argsFree(std.testing.allocator, args);
66
77 const dynlib_name = args[1];
88