aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2016-01-06 00:24:06 +0000
committerMatthew Wild <mwild1@gmail.com>2016-01-06 00:24:06 +0000
commit11e5133ad3d4b9cda79828641b77003fb85ebf8f (patch)
treee0e38fe44909123444b2ca760d8699df92b1920d
parent8e3e252dea3e5d51a7428cf7c0d31894faac5b8e (diff)
downloadprosody-11e5133ad3d4b9cda79828641b77003fb85ebf8f.tar.gz
prosody-11e5133ad3d4b9cda79828641b77003fb85ebf8f.zip
tests/test.lua: Fix fake module() function to prevent _M from being _G (test.lua's environment), which caused modules to break the sandbox when they set _M.*
-rw-r--r--tests/test.lua5
1 files changed, 4 insertions, 1 deletions
diff --git a/tests/test.lua b/tests/test.lua
index de1e40fd..bb11ab26 100644
--- a/tests/test.lua
+++ b/tests/test.lua
@@ -137,7 +137,10 @@ function dotest(unitname)
end
local oldmodule, old_M = _fakeG.module, _fakeG._M;
- _fakeG.module = function () _M = _G end
+ _fakeG.module = function ()
+ setmetatable(unit, nil);
+ unit._M = unit;
+ end
setfenv(chunk, unit);
local success, err = pcall(chunk);
_fakeG.module, _fakeG._M = oldmodule, old_M;