# HG changeset patch # User Matthew Wild # Date 1452039846 0 # Node ID ecfa474ff5700bcbcc1b0ea08e45b04070c2c676 # Parent b5bc9f77f096d9e6a195b1d9712a60098e7a25c6 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.* diff -r b5bc9f77f096 -r ecfa474ff570 tests/test.lua --- a/tests/test.lua Wed Dec 23 12:07:03 2015 +0100 +++ b/tests/test.lua Wed Jan 06 00:24:06 2016 +0000 @@ -137,7 +137,10 @@ 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;