Skip to content

Commit a798b20

Browse files
feat: make sure test failures break the ci
😰
1 parent de6d87f commit a798b20

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/tests/runner.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const builtin = @import("builtin");
33

44
pub fn main() !void {
55
const out = std.io.getStdOut().writer();
6+
var has_failures = false;
67
for (builtin.test_functions) |t| {
78
std.testing.allocator_instance = .{};
89

@@ -11,13 +12,16 @@ pub fn main() !void {
1112
if (result) |_| {
1213
try std.fmt.format(out, "[SUCCESS] {s}\n", .{name});
1314
} else |err| {
15+
has_failures = true;
1416
try std.fmt.format(out, "[FAIL] {s}: {}\n", .{ t.name, err });
1517
}
1618

1719
if (std.testing.allocator_instance.deinit() == .leak) {
20+
has_failures = true;
1821
try std.fmt.format(out, "{s} leaked memory\n", .{name});
1922
}
2023
}
24+
if (has_failures) std.process.exit(1);
2125
}
2226

2327
fn extractName(t: std.builtin.TestFn) []const u8 {

0 commit comments

Comments
 (0)