31 lines
1.0 KiB
Zig
31 lines
1.0 KiB
Zig
const std = @import("std");
|
|
const Io = std.Io;
|
|
|
|
const builtin = @import("builtin");
|
|
|
|
pub const colour_set_string_fg_fmt = "\x1B[38;2;{d};{d};{d}m";
|
|
pub const colour_set_string_bg_fmt = "\x1B[48;2;{d};{d};{d}m";
|
|
pub const colour_set_string_fmt = colour_set_string_fg_fmt ++ colour_set_string_bg_fmt;
|
|
pub const colour_end_string_fmt = "\x1B[0m";
|
|
|
|
pub fn main(init: std.process.Init) !void {
|
|
const io = init.io;
|
|
|
|
var stdout_buffer: [1024]u8 = undefined;
|
|
var stdout_file_writer: Io.File.Writer = .init(.stdout(), io, &stdout_buffer);
|
|
const stdout = &stdout_file_writer.interface;
|
|
|
|
var passed: usize = 0;
|
|
for (builtin.test_functions) |t| {
|
|
t.func() catch |err| {
|
|
try stdout.print("[\x1B[38;2;255;0;0mfail\x1B[0m] {s} : {}\n", .{ t.name, err });
|
|
continue;
|
|
};
|
|
passed += 1;
|
|
try stdout.print("[\x1B[38;2;0;255;0mpassed\x1B[0m] {s} \n", .{t.name});
|
|
}
|
|
|
|
try stdout.print("[{}/{}] test passed\n", .{ passed, builtin.test_functions.len });
|
|
try stdout.flush(); // Don't forget to flush!
|
|
}
|