|
|
@ -426,7 +426,9 @@ local function run_test(test, status, counts)
|
|
|
|
test.private.checks_ok = 0
|
|
|
|
test.private.checks_ok = 0
|
|
|
|
counts.tests = counts.tests + 1
|
|
|
|
counts.tests = counts.tests + 1
|
|
|
|
dfhack.internal.IN_TEST = true
|
|
|
|
dfhack.internal.IN_TEST = true
|
|
|
|
|
|
|
|
local start_ms = dfhack.getTickCount()
|
|
|
|
local ok, err = wrap_test(test.func)
|
|
|
|
local ok, err = wrap_test(test.func)
|
|
|
|
|
|
|
|
local elapsed_ms = dfhack.getTickCount() - start_ms
|
|
|
|
dfhack.internal.IN_TEST = false
|
|
|
|
dfhack.internal.IN_TEST = false
|
|
|
|
local passed = false
|
|
|
|
local passed = false
|
|
|
|
if not ok then
|
|
|
|
if not ok then
|
|
|
@ -435,7 +437,7 @@ local function run_test(test, status, counts)
|
|
|
|
elseif test.private.checks ~= test.private.checks_ok then
|
|
|
|
elseif test.private.checks ~= test.private.checks_ok then
|
|
|
|
dfhack.printerr('test failed: ' .. test.name)
|
|
|
|
dfhack.printerr('test failed: ' .. test.name)
|
|
|
|
else
|
|
|
|
else
|
|
|
|
print('test passed: ' .. test.name)
|
|
|
|
print(('test passed in %d ms: %s'):format(elapsed_ms, test.name))
|
|
|
|
passed = true
|
|
|
|
passed = true
|
|
|
|
counts.tests_ok = counts.tests_ok + 1
|
|
|
|
counts.tests_ok = counts.tests_ok + 1
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -513,6 +515,7 @@ end
|
|
|
|
|
|
|
|
|
|
|
|
local function run_tests(tests, status, counts, config)
|
|
|
|
local function run_tests(tests, status, counts, config)
|
|
|
|
print(('Running %d tests'):format(#tests))
|
|
|
|
print(('Running %d tests'):format(#tests))
|
|
|
|
|
|
|
|
local start_ms = dfhack.getTickCount()
|
|
|
|
local num_skipped = 0
|
|
|
|
local num_skipped = 0
|
|
|
|
for _, test in pairs(tests) do
|
|
|
|
for _, test in pairs(tests) do
|
|
|
|
if MODES[test.config.mode].failed then
|
|
|
|
if MODES[test.config.mode].failed then
|
|
|
@ -536,6 +539,7 @@ local function run_tests(tests, status, counts, config)
|
|
|
|
save_test_status(status)
|
|
|
|
save_test_status(status)
|
|
|
|
::skip::
|
|
|
|
::skip::
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local elapsed_ms = dfhack.getTickCount() - start_ms
|
|
|
|
|
|
|
|
|
|
|
|
local function print_summary_line(ok, message)
|
|
|
|
local function print_summary_line(ok, message)
|
|
|
|
local print_fn = print
|
|
|
|
local print_fn = print
|
|
|
@ -543,11 +547,11 @@ local function run_tests(tests, status, counts, config)
|
|
|
|
status['*'] = TestStatus.FAILED
|
|
|
|
status['*'] = TestStatus.FAILED
|
|
|
|
print_fn = dfhack.printerr
|
|
|
|
print_fn = dfhack.printerr
|
|
|
|
end
|
|
|
|
end
|
|
|
|
print_fn(message)
|
|
|
|
print_fn(' ' .. message)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
status['*'] = status['*'] or TestStatus.PASSED
|
|
|
|
status['*'] = status['*'] or TestStatus.PASSED
|
|
|
|
print('\nTest summary:')
|
|
|
|
print(('\nTests completed in %d ms:'):format(elapsed_ms))
|
|
|
|
print_summary_line(counts.tests_ok == counts.tests,
|
|
|
|
print_summary_line(counts.tests_ok == counts.tests,
|
|
|
|
('%d/%d tests passed'):format(counts.tests_ok, counts.tests))
|
|
|
|
('%d/%d tests passed'):format(counts.tests_ok, counts.tests))
|
|
|
|
print_summary_line(counts.checks_ok == counts.checks,
|
|
|
|
print_summary_line(counts.checks_ok == counts.checks,
|
|
|
|