-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.lua
47 lines (38 loc) · 1.12 KB
/
test.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
local utils = require("ltml.utils")
local color = utils.color
local test_imports = {
"ltml.tests.render_tests",
"ltml.tests.sandbox_tests",
"ltml.tests.util_tests"
}
local tests = {}
local testCount = 0
for _, v in pairs(test_imports) do
tests[v] = require(v)
for _ in pairs(tests[v]) do
testCount = testCount + 1
end
end
local passedTests = 0
local failedTests = 0
print("Loaded " .. testCount .. " tests.")
for category, list in pairs(tests) do
if utils.count(list) > 0 then
print(category..": ")
end
for name, test in pairs(list) do
local status, value = pcall(test)
if status and value then
print(" [" .. color.green("PASS") .. "] " .. name)
passedTests = passedTests + 1
else
print(" [" .. color.red("FAIL") .. "] " .. name)
print(" !!! " .. color.red("ERROR") .. "!!!: " .. tostring(value))
failedTests = failedTests + 1
end
end
end
print(color.green(passedTests) .. " tests passed, " .. color.red(failedTests) .. " tests failed.")
if failedTests > 0 then
os.exit(1)
end