Pretty icons
This commit is contained in:
parent
c07ec4c3ad
commit
5ea532f1c6
@ -12,6 +12,12 @@ local colors = {
|
|||||||
fail = "\x1b[31;1m",
|
fail = "\x1b[31;1m",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local icons = {
|
||||||
|
check = "\u{2713}",
|
||||||
|
cross = "\u{00d7}",
|
||||||
|
chevron = "\u{203a}",
|
||||||
|
}
|
||||||
|
|
||||||
local function color(name, s)
|
local function color(name, s)
|
||||||
return colors[name] .. s .. colors.reset
|
return colors[name] .. s .. colors.reset
|
||||||
end
|
end
|
||||||
@ -48,7 +54,7 @@ local function name_test(test)
|
|||||||
local name = test.name
|
local name = test.name
|
||||||
local group = test.group
|
local group = test.group
|
||||||
while group ~= nil do
|
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
|
group = group.parent
|
||||||
end
|
end
|
||||||
return name
|
return name
|
||||||
@ -62,11 +68,10 @@ local function run_test(test)
|
|||||||
local ok, res = xpcall(test.f, trace, test)
|
local ok, res = xpcall(test.f, trace, test)
|
||||||
if ok then
|
if ok then
|
||||||
test.state = "pass"
|
test.state = "pass"
|
||||||
print("", color("pass", "PASS") .. " " .. name_test(test))
|
print("", string.format("%s %s", color("pass", "PASS"), name_test(test)))
|
||||||
else
|
else
|
||||||
test.state = "fail"
|
test.state = "fail"
|
||||||
print("", color("fail", "FAIL") .. " " .. name_test(test) .. "\n")
|
print("", string.format("%s %s\n\n%s\n", color("fail", "FAIL"), name_test(test), res))
|
||||||
print(res .. "\n")
|
|
||||||
end
|
end
|
||||||
return test
|
return test
|
||||||
end
|
end
|
||||||
@ -93,14 +98,14 @@ local function main(item)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if fail == 0 then
|
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
|
return 0
|
||||||
end
|
end
|
||||||
print(
|
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
|
return 1 -- report error to cargo
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user