diff --git a/tests/test.lua b/tests/test.lua index 4ac51bd..481f504 100644 --- a/tests/test.lua +++ b/tests/test.lua @@ -12,6 +12,12 @@ local colors = { fail = "\x1b[31;1m", } +local icons = { + check = "\u{2713}", + cross = "\u{00d7}", + chevron = "\u{203a}", +} + local function color(name, s) return colors[name] .. s .. colors.reset end @@ -48,7 +54,7 @@ local function name_test(test) local name = test.name local group = test.group while group ~= nil do - if group.name ~= "" then name = group.name .. " › " .. name end + if group.name ~= "" then name = string.format("%s %s %s", group.name, icons.chevron, name) end group = group.parent end return name @@ -62,11 +68,10 @@ local function run_test(test) local ok, res = xpcall(test.f, trace, test) if ok then test.state = "pass" - print("", color("pass", "PASS") .. " " .. name_test(test)) + print("", string.format("%s %s", color("pass", "PASS"), name_test(test))) else test.state = "fail" - print("", color("fail", "FAIL") .. " " .. name_test(test) .. "\n") - print(res .. "\n") + print("", string.format("%s %s\n\n%s\n", color("fail", "FAIL"), name_test(test), res)) end return test end @@ -93,14 +98,14 @@ local function main(item) end end if fail == 0 then - print("", color("pass", string.format("%d tests passed", pass))) + print("", color("pass", string.format("%s %d tests passed", icons.check, pass))) return 0 end print( "", - color("pass", string.format("%d tests passed", pass)) + color("pass", string.format("%s %d tests passed", icons.check, pass)) .. ", " - .. color("fail", string.format("%d tests failed", fail)) + .. color("fail", string.format("%s %d tests failed", icons.cross, fail)) ) return 1 -- report error to cargo end