From aca474d31ede34347e776504b5a4228800d0e3a8 Mon Sep 17 00:00:00 2001 From: ame Date: Tue, 2 Sep 2025 22:41:16 -0500 Subject: better tests --- tests/tests.lua | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 tests/tests.lua (limited to 'tests/tests.lua') diff --git a/tests/tests.lua b/tests/tests.lua new file mode 100644 index 0000000..b4110d4 --- /dev/null +++ b/tests/tests.lua @@ -0,0 +1,44 @@ +llby = require("lullaby") + +local failed = {} +local total = 0 + +function yay(M) + print(string.format("\27[32m%s\27[0m passed", M)) +end + +function nay(M) + print(string.format("\27[31m%s\27[0m failed", M)) +end + +local search = "" +if arg[1] ~= nil then + search = "*" .. arg[1] .. "*" +end + +local handle = assert(io.popen("find tests/units/".. search .." -type f")) + +for file in handle:lines() do + total = total + 1 + local f = loadfile(file)() + + if f == true then + yay(file) + else + nay(file) + table.insert(failed, file) + end +end + +if #failed > 0 then + print("\n--- failed units (".. #failed .."/".. total ..") ---") + for _,fail in ipairs(failed) do + nay(fail) + end + print("--- failed units (".. #failed .."/".. total ..") ---") +else + print("passed all (".. total ..")") +end + +handle:close() + -- cgit v1.2.3