Use mock.patch() in ci/test.lua

Other tests that could benefit are currently only in the scripts repo.
develop
lethosor 2021-04-09 00:50:06 -04:00
parent 5424392273
commit f44442e5e9
No known key found for this signature in database
GPG Key ID: 76A269552F4F58C1
1 changed files with 13 additions and 12 deletions

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