Commit 70ad84c820

Benjamin Feng <benjamin.feng@glassdoor.com>
2020-01-30 00:38:52
Use defer/panic to better account for test failure
1 parent 0c13793
Changed files (1)
lib
std
lib/std/special/test_runner.zig
@@ -14,6 +14,11 @@ pub fn main() anyerror!void {
 
     for (test_fn_list) |test_fn, i| {
         std.testing.allocator_instance.reset();
+        defer {
+            std.testing.leak_count_allocator_instance.validate() catch |err| {
+                @panic(@errorName(err));
+            };
+        }
 
         var test_node = root_node.start(test_fn.name, null);
         test_node.activate();
@@ -37,8 +42,6 @@ pub fn main() anyerror!void {
                 return err;
             },
         }
-
-        try std.testing.leak_count_allocator_instance.validate();
     }
     root_node.end();
     if (ok_count == test_fn_list.len) {