Pretty icons

This commit is contained in:
lumi 2025-06-27 14:39:04 +10:00
parent c07ec4c3ad
commit 40f7b85bca
Signed by: luaneko
GPG Key ID: 406809B8763FF07A

View File

@ -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
@ -93,14 +99,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