X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=tests%2Ftest.lua;h=b6728061e7ed9332cfb62a53c1495ebb259df917;hb=9c110de3eb2b376ff51bec2f4dc50f68110a24f2;hp=38ef6191ad4191a2ae49a88fd24a6513e9478f19;hpb=2f3a9c1f031f043e3984488f0ec5affa53a2f2f3;p=prosody.git diff --git a/tests/test.lua b/tests/test.lua index 38ef6191..b6728061 100644 --- a/tests/test.lua +++ b/tests/test.lua @@ -9,13 +9,17 @@ function run_all_tests() + package.loaded["net.connlisteners"] = { get = function () return {} end }; dotest "util.jid" dotest "util.multitable" - dotest "core.modulemanager" + dotest "util.rfc6724" + dotest "util.http" dotest "core.stanza_router" dotest "core.s2smanager" dotest "core.configmanager" + dotest "util.ip" dotest "util.stanza" + dotest "util.sasl.scram" dosingletest("test_sasl.lua", "latin1toutf8"); end @@ -132,15 +136,21 @@ function dotest(unitname) end local oldmodule, old_M = _fakeG.module, _fakeG._M; - _fakeG.module = function () _M = _G end + _fakeG.module = function () _M = unit end setfenv(chunk, unit); - local success, err = pcall(chunk); + local success, ret = pcall(chunk); _fakeG.module, _fakeG._M = oldmodule, old_M; if not success then print("WARNING: ", "Failed to initialise module: "..unitname, err); return; end + if type(ret) == "table" then + for k,v in pairs(ret) do + unit[k] = v; + end + end + for name, f in pairs(unit) do local test = rawget(tests, name); if type(f) ~= "function" then @@ -216,7 +226,7 @@ function new_line_coverage_monitor(file) for line, active in pairs(lines_hit) do if active ~= nil then total_active_lines = total_active_lines + 1; end if coverage_file then - if active == false then coverage_file:write(fn, "|", line, "|", name or "", "|miss\n"); + if active == false then coverage_file:write(fn, "|", line, "|", name or "", "|miss\n"); else coverage_file:write(fn, "|", line, "|", name or "", "|", tostring(success), "\n"); end end end