Skip to content

Commit a51442f

Browse files
feat: make sure test failures break the ci
😰
1 parent a3518b4 commit a51442f

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/tests/runner.zig

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,28 @@ 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

910
const name = extractName(t);
1011
const result = t.func();
1112
if (result) |_| {
1213
try std.fmt.format(out, "[SUCCESS] {s}\n", .{name});
13-
} else |err| {
14-
try std.fmt.format(out, "[FAIL] {s}: {}\n", .{ t.name, err });
14+
} else |err| switch (err) {
15+
error.SkipZigTest => try std.fmt.format(out, "[SKIP] {s}\n", .{name}),
16+
else => {
17+
has_failures = true;
18+
try std.fmt.format(out, "[FAIL] {s}: {}\n", .{ t.name, err });
19+
},
1520
}
1621

1722
if (std.testing.allocator_instance.deinit() == .leak) {
23+
has_failures = true;
1824
try std.fmt.format(out, "{s} leaked memory\n", .{name});
1925
}
2026
}
27+
if (has_failures) std.process.exit(1);
2128
}
2229

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

0 commit comments

Comments
 (0)