authorgravatar for benjamin.feng@glassdoor.comBenjamin Feng <benjamin.feng@glassdoor.com> 2020-01-29 17:38:52-06:00
committergravatar for benjamin.feng@glassdoor.comBenjamin Feng <benjamin.feng@glassdoor.com> 2020-01-29 17:38:52-06:00
log70ad84c8209ae7ab14472f77f9452820bc47c30e
tree7c37ec0b884bf406960b0d7c675d6ebad7c5bbc8
parent0c137934cbd10528c2dced898b6c5485ab528e6d

Use defer/panic to better account for test failure


1 files changed, 5 insertions(+), 2 deletions(-)

lib/std/special/test_runner.zig+5-2
...@@ -14,6 +14,11 @@ pub fn main() anyerror!void {...@@ -14,6 +14,11 @@ pub fn main() anyerror!void {
1414
15 for (test_fn_list) |test_fn, i| {15 for (test_fn_list) |test_fn, i| {
16 std.testing.allocator_instance.reset();16 std.testing.allocator_instance.reset();
17 defer {
18 std.testing.leak_count_allocator_instance.validate() catch |err| {
19 @panic(@errorName(err));
20 };
21 }
1722
18 var test_node = root_node.start(test_fn.name, null);23 var test_node = root_node.start(test_fn.name, null);
19 test_node.activate();24 test_node.activate();
...@@ -37,8 +42,6 @@ pub fn main() anyerror!void {...@@ -37,8 +42,6 @@ pub fn main() anyerror!void {
37 return err;42 return err;
38 },43 },
39 }44 }
40
41 try std.testing.leak_count_allocator_instance.validate();
42 }45 }
43 root_node.end();46 root_node.end();
44 if (ok_count == test_fn_list.len) {47 if (ok_count == test_fn_list.len) {