-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
54 lines (46 loc) · 1.19 KB
/
main.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
53
54
package.path = "./libs/?.lua;" .. package.path -- Try our local version first
require "jestronaut":withGlobals()
local config = {}
for _, arg in ipairs(args) do
local key, value = arg:match("^%-%-([%w_]+)=(.+)$")
if value == "true" then
value = true
elseif value == "false" then
value = false
end
if key then
if config[key] then
if type(config[key]) == "table" then
table.insert(config[key], value)
else
config[key] = {config[key], value}
end
else
config[key] = value
end
end
end
if not config.roots or #config.roots == 0 then
print("No roots set. Please set the roots to your test files. For example: `jestronaut --roots=./tests/`")
os.exit(1)
end
local tableConfigKeys = {
roots = true,
testPathIgnorePatterns = true,
}
for key, value in pairs(config) do
if tableConfigKeys[key] then
if type(value) ~= "table" then
config[key] = {value}
end
end
end
jestronaut
:configure(config)
:registerTests(function()
package.path = package.path .. ";./?.lua;./?/init.lua"
for _, root in pairs(config.roots) do
require(root:gsub("^%./",""):gsub("\\","/"):gsub("%.lua",""))
end
end)
:runTests()