|
|
@ -12,6 +12,8 @@ local TestStatus = {
|
|
|
|
FAILED = 'failed',
|
|
|
|
FAILED = 'failed',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local VALID_MODES = utils.invert{'none', 'fortress'}
|
|
|
|
|
|
|
|
|
|
|
|
expect = {}
|
|
|
|
expect = {}
|
|
|
|
function expect.true_(value, comment)
|
|
|
|
function expect.true_(value, comment)
|
|
|
|
return not not value, comment, 'expected true'
|
|
|
|
return not not value, comment, 'expected true'
|
|
|
@ -42,6 +44,9 @@ end
|
|
|
|
function build_test_env()
|
|
|
|
function build_test_env()
|
|
|
|
local env = {
|
|
|
|
local env = {
|
|
|
|
test = utils.OrderedTable(),
|
|
|
|
test = utils.OrderedTable(),
|
|
|
|
|
|
|
|
config = {
|
|
|
|
|
|
|
|
mode = 'none',
|
|
|
|
|
|
|
|
},
|
|
|
|
expect = {},
|
|
|
|
expect = {},
|
|
|
|
delay = delay,
|
|
|
|
delay = delay,
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -116,11 +121,16 @@ function load_tests(file, tests)
|
|
|
|
dfhack.printerr('Error when running file: ' .. tostring(err))
|
|
|
|
dfhack.printerr('Error when running file: ' .. tostring(err))
|
|
|
|
return false
|
|
|
|
return false
|
|
|
|
else
|
|
|
|
else
|
|
|
|
|
|
|
|
if not VALID_MODES[env.config.mode] then
|
|
|
|
|
|
|
|
dfhack.printerr('Invalid config.mode: ' .. env.config.mode)
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
end
|
|
|
|
for name, test_func in pairs(env.test) do
|
|
|
|
for name, test_func in pairs(env.test) do
|
|
|
|
local test_data = {
|
|
|
|
local test_data = {
|
|
|
|
full_name = short_filename .. ':' .. name,
|
|
|
|
full_name = short_filename .. ':' .. name,
|
|
|
|
func = test_func,
|
|
|
|
func = test_func,
|
|
|
|
private = env_private,
|
|
|
|
private = env_private,
|
|
|
|
|
|
|
|
config = env.config,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
test_data.name = test_data.full_name:gsub('test/', ''):gsub('.lua', '')
|
|
|
|
test_data.name = test_data.full_name:gsub('test/', ''):gsub('.lua', '')
|
|
|
|
table.insert(tests, test_data)
|
|
|
|
table.insert(tests, test_data)
|
|
|
|