Report number of passing and failing tests

This commit is contained in:
lumi 2025-06-27 14:28:08 +10:00
parent eb7b05d07a
commit 7c40fb4322
Signed by: luaneko
GPG Key ID: 406809B8763FF07A

View File

@ -81,18 +81,31 @@ local function start(cx, item)
end end
end end
local function run(item) local function main(item)
local cx = { tasks = {} } local cx = { tasks = {} }
local pass = true local pass, fail = 0, 0
start(cx, item) start(cx, item)
for _, task in ipairs(cx.tasks) do for _, task in ipairs(cx.tasks) do
if task:await().state ~= "pass" then pass = false end if task:await().state == "pass" then
pass = pass + 1
else
fail = fail + 1
end
end end
if pass then return 0 end -- report status to cargo if fail == 0 then
return 1 print("", color("pass", string.format("%d tests passed", pass)))
return 0
end
print(
"",
color("pass", string.format("%d tests passed", pass))
.. ", "
.. color("fail", string.format("%d tests failed", fail))
)
return 1 -- report error to cargo
end end
return run(create_group("", function() return main(create_group("", function()
local function glob(path, pat) local function glob(path, pat)
for entry in fs:glob_dir(path, pat) do for entry in fs:glob_dir(path, pat) do
local path = entry:path() local path = entry:path()