Changeset

7051:ecfa474ff570

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.*
author Matthew Wild <mwild1@gmail.com>
date Wed, 06 Jan 2016 00:24:06 +0000
parents 7030:b5bc9f77f096
children 7052:306aabf2d57d
files tests/test.lua
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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;