Merge 0.9->0.10
[prosody.git] / tests / test.lua
index 1666fcf5199e8de327b05db19cb78162e03e6bff..5d5851e128b20d340b9c1a2f988c71b15fce8954 100644 (file)
@@ -14,6 +14,7 @@ function run_all_tests()
        dotest "util.multitable"
        dotest "util.rfc6724"
        dotest "util.http"
+       dotest "core.modulemanager"
        dotest "core.stanza_router"
        dotest "core.s2smanager"
        dotest "core.configmanager"
@@ -140,9 +141,12 @@ function dotest(unitname)
        end
 
        local oldmodule, old_M = _fakeG.module, _fakeG._M;
-       _fakeG.module = function () _M = unit end
+       _fakeG.module = function ()
+               setmetatable(unit, nil);
+               unit._M = unit;
+       end
        setfenv(chunk, unit);
-       local success, ret = pcall(chunk);
+       local success, err = pcall(chunk);
        _fakeG.module, _fakeG._M = oldmodule, old_M;
        if not success then
                print("WARNING: ", "Failed to initialise module: "..unitname, err);