2017-10-31 01:47:55 -07:00
|
|
|
const std = @import("std");
|
|
|
|
const io = std.io;
|
2017-05-01 10:12:38 -07:00
|
|
|
const builtin = @import("builtin");
|
2019-04-02 08:11:42 -07:00
|
|
|
const test_fn_list = builtin.test_functions;
|
2016-02-03 17:02:01 -08:00
|
|
|
|
2019-10-17 18:46:41 -07:00
|
|
|
pub fn main() anyerror!void {
|
2018-07-21 20:43:43 -07:00
|
|
|
var ok_count: usize = 0;
|
|
|
|
var skip_count: usize = 0;
|
2019-10-17 18:46:41 -07:00
|
|
|
var progress = std.Progress{};
|
|
|
|
const root_node = progress.start("Test", test_fn_list.len) catch |err| switch (err) {
|
|
|
|
// TODO still run tests in this case
|
|
|
|
error.TimerUnsupported => @panic("timer unsupported"),
|
|
|
|
};
|
2016-02-03 17:02:01 -08:00
|
|
|
|
2019-10-17 18:46:41 -07:00
|
|
|
for (test_fn_list) |test_fn, i| {
|
|
|
|
var test_node = root_node.start(test_fn.name, null);
|
|
|
|
test_node.activate();
|
2019-10-21 16:01:08 -07:00
|
|
|
progress.refresh();
|
2019-10-21 17:49:35 -07:00
|
|
|
if (progress.terminal == null) std.debug.warn("{}/{} {}...", i + 1, test_fn_list.len, test_fn.name);
|
2018-07-21 20:43:43 -07:00
|
|
|
if (test_fn.func()) |_| {
|
|
|
|
ok_count += 1;
|
2019-10-17 18:46:41 -07:00
|
|
|
test_node.end();
|
2019-10-21 17:49:35 -07:00
|
|
|
if (progress.terminal == null) std.debug.warn("OK\n");
|
2018-07-21 20:43:43 -07:00
|
|
|
} else |err| switch (err) {
|
|
|
|
error.SkipZigTest => {
|
|
|
|
skip_count += 1;
|
2019-10-17 18:46:41 -07:00
|
|
|
test_node.end();
|
|
|
|
progress.log("{}...SKIP\n", test_fn.name);
|
2019-10-21 17:49:35 -07:00
|
|
|
if (progress.terminal == null) std.debug.warn("SKIP\n");
|
2018-07-21 20:43:43 -07:00
|
|
|
},
|
2019-10-21 15:35:14 -07:00
|
|
|
else => {
|
|
|
|
progress.log("");
|
|
|
|
return err;
|
|
|
|
},
|
2018-07-21 20:43:43 -07:00
|
|
|
}
|
|
|
|
}
|
2019-10-17 18:46:41 -07:00
|
|
|
root_node.end();
|
2019-10-21 19:20:45 -07:00
|
|
|
if (ok_count == test_fn_list.len) {
|
2019-11-24 12:17:55 -08:00
|
|
|
std.debug.warn("All {} tests passed.\n", ok_count);
|
2019-10-21 19:20:45 -07:00
|
|
|
} else {
|
2019-10-21 15:35:14 -07:00
|
|
|
std.debug.warn("{} passed; {} skipped.\n", ok_count, skip_count);
|
2016-02-03 17:02:01 -08:00
|
|
|
}
|
|
|
|
}
|