aboutsummaryrefslogtreecommitdiff
path: root/tests/tests.lua
blob: c95e072a27523a7a07445a66613f730e4ec3afe2 (plain)
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
48
49
llby = require("lullaby")
PORT = 5552

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
  print(file)
  local f = loadfile(file)()

  --move up one line and clear it
  io.write("\27[1A\27[K")

  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()