Skip to content

Commit d01d43e

Browse files
committed
Remove setup/teardown functionality. YAGNI
1 parent 2aa5f4f commit d01d43e

File tree

1 file changed

+0
-30
lines changed

1 file changed

+0
-30
lines changed

src/unit_tests.zig

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -56,26 +56,13 @@ pub fn main() !void {
5656
const printer = Printer.init();
5757
printer.fmt("\r\x1b[0K", .{}); // beginning of line and clear to end of line
5858

59-
for (builtin.test_functions) |t| {
60-
if (isSetup(t)) {
61-
t.func() catch |err| {
62-
printer.status(.fail, "\nsetup \"{s}\" failed: {}\n", .{ t.name, err });
63-
return err;
64-
};
65-
}
66-
}
67-
6859
for (builtin.test_functions) |t| {
6960
if (std.mem.eql(u8, t.name, "unit_tests.test_0")) {
7061
// don't display anything for this test
7162
try t.func();
7263
continue;
7364
}
7465

75-
if (isSetup(t) or isTeardown(t)) {
76-
continue;
77-
}
78-
7966
var status = Status.pass;
8067
slowest.startTiming();
8168

@@ -138,15 +125,6 @@ pub fn main() !void {
138125
}
139126
}
140127

141-
for (builtin.test_functions) |t| {
142-
if (isTeardown(t)) {
143-
t.func() catch |err| {
144-
printer.status(.fail, "\nteardown \"{s}\" failed: {}\n", .{ t.name, err });
145-
return err;
146-
};
147-
}
148-
}
149-
150128
const total_tests = pass + fail;
151129
const status = if (fail == 0) Status.pass else Status.fail;
152130
printer.status(status, "\n{d} of {d} test{s} passed\n", .{ pass, total_tests, if (total_tests != 1) "s" else "" });
@@ -316,14 +294,6 @@ fn isUnnamed(t: std.builtin.TestFn) bool {
316294
return true;
317295
}
318296

319-
fn isSetup(t: std.builtin.TestFn) bool {
320-
return std.mem.endsWith(u8, t.name, "tests:beforeAll");
321-
}
322-
323-
fn isTeardown(t: std.builtin.TestFn) bool {
324-
return std.mem.endsWith(u8, t.name, "tests:afterAll");
325-
}
326-
327297
fn serverHTTP(listener: *std.net.Server) !void {
328298
var read_buffer: [1024]u8 = undefined;
329299
ACCEPT: while (true) {

0 commit comments

Comments
 (0)