|
|
@ -281,19 +281,20 @@ local function sort_tests(tests)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local function wrap_test(func)
|
|
|
|
local function wrap_test(func)
|
|
|
|
local saved_printerr, saved_run_script = dfhack.printerr, dfhack.run_script
|
|
|
|
local saved_printerr = dfhack.printerr
|
|
|
|
local printerr_called = false
|
|
|
|
local printerr_called = false
|
|
|
|
dfhack.printerr = function(msg)
|
|
|
|
local printerr_wrapper = function(msg)
|
|
|
|
if msg == nil then return end
|
|
|
|
if msg == nil then return end
|
|
|
|
saved_printerr(msg)
|
|
|
|
saved_printerr(msg)
|
|
|
|
printerr_called = true
|
|
|
|
printerr_called = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
dfhack.run_script = clean_run_script
|
|
|
|
|
|
|
|
return dfhack.with_finalize(
|
|
|
|
return mock.patch(
|
|
|
|
function()
|
|
|
|
{
|
|
|
|
dfhack.printerr = saved_printerr
|
|
|
|
{dfhack, 'printerr', printerr_wrapper},
|
|
|
|
dfhack.run_script = saved_run_script
|
|
|
|
{dfhack, 'run_script', clean_run_script},
|
|
|
|
end,
|
|
|
|
{dfhack, 'reqscript', clean_reqscript},
|
|
|
|
|
|
|
|
},
|
|
|
|
function()
|
|
|
|
function()
|
|
|
|
local ok, err = pcall(func)
|
|
|
|
local ok, err = pcall(func)
|
|
|
|
if printerr_called then
|
|
|
|
if printerr_called then
|
|
|
|