-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.lua
52 lines (41 loc) · 1012 Bytes
/
cli.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
48
49
50
51
52
-- (c) 2024 Jacek Olszak
-- This code is licensed under MIT license (see LICENSE for details)
local work_dir = env().path
local test_file = env().argv[1]
print("Running " .. test_file .. "...")
local executed = 0
local failed = 0
on_event("test_started", function(e)
executed += 1
end)
on_event("test_finished", function(e)
if e.error != nil then
failed += 1
end
end)
on_event("print", function(e)
-- print to stdout, because Picotron's terminal has limited size.
printh("test " .. e.test.id .. ": " .. e.text)
end)
on_event("done", function(e)
if failed > 0 then
print(string.format("\f8Failed tests: %d/%d", failed, executed))
exit(1)
elseif executed > 0 then
print(string.format("\fbAll %d tests successful", executed))
exit(0)
else
print(string.format("\f3No tests found"))
exit(0)
end
end)
runner_pid = create_process(
"runner.lua",
{
argv = { test_file },
path = work_dir,
window_attribs = { autoclose = true }
}
)
function _update() -- run in the background
end