forked from Crimso777/Factorio-Access
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathrun-tests.lua
More file actions
61 lines (52 loc) · 1.63 KB
/
run-tests.lua
File metadata and controls
61 lines (52 loc) · 1.63 KB
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
53
54
55
56
57
58
59
60
61
#!/usr/bin/env lua
---@diagnostic disable
-- General test runner for FactorioAccess
-- Usage: lua run-tests.lua [suite]
-- Where suite is one of: syntrax, ds, all (default)
local lu = require("luaunit")
local function load_test_suite(suite_name, test_specs)
local tests = {}
for _, spec in ipairs(test_specs) do
table.insert(tests, { spec[1], spec[2] })
end
return tests
end
local syntrax_tests = {
{ "span", require("syntrax.tests.span") },
{ "lexer", require("syntrax.tests.lexer") },
{ "ast", require("syntrax.tests.ast") },
{ "parser", require("syntrax.tests.parser") },
{ "directions", require("syntrax.tests.directions") },
{ "vm", require("syntrax.tests.vm") },
{ "compiler", require("syntrax.tests.compiler") },
{ "syntrax", require("syntrax.tests.syntrax") },
{ "syntax", require("syntrax.tests.syntax") },
{ "rail-stack", require("syntrax.tests.rail-stack") },
}
local ds_tests = {
{ "deque", require("ds.tests.deque") },
{ "sparse-bitset", require("ds.tests.sparse-bitset") },
}
-- Parse command line arguments
local suite = arg and arg[1] or "all"
local tests = {}
if suite == "syntrax" then
tests = syntrax_tests
elseif suite == "ds" then
tests = ds_tests
elseif suite == "all" then
-- Combine both test suites
for _, test in ipairs(syntrax_tests) do
table.insert(tests, test)
end
for _, test in ipairs(ds_tests) do
table.insert(tests, test)
end
else
print("Unknown test suite: " .. suite)
int("Usage: lua run-tests.lua [syntrax|ds|all]")
os.exit(1)
end
-- Run the tests
local runner = lu.LuaUnit.new()
os.exit(runner:runSuiteByInstances(tests))