Comparison

tests/test.lua @ 5604:6df0ec991f2e

tests: Some much-needed cleanup...
author Matthew Wild <mwild1@gmail.com>
date Sat, 18 May 2013 17:14:30 +0100
parent 4420:4314eeeed394
child 5776:bd0ff8ae98a8
comparison
equal deleted inserted replaced
5603:e07f4f02e4f9 5604:6df0ec991f2e
10 10
11 function run_all_tests() 11 function run_all_tests()
12 package.loaded["net.connlisteners"] = { get = function () return {} end }; 12 package.loaded["net.connlisteners"] = { get = function () return {} end };
13 dotest "util.jid" 13 dotest "util.jid"
14 dotest "util.multitable" 14 dotest "util.multitable"
15 dotest "util.rfc3484" 15 dotest "util.rfc6724"
16 dotest "net.http" 16 dotest "util.http"
17 dotest "core.modulemanager"
18 dotest "core.stanza_router" 17 dotest "core.stanza_router"
19 dotest "core.s2smanager" 18 dotest "core.s2smanager"
20 dotest "core.configmanager" 19 dotest "core.configmanager"
20 dotest "util.ip"
21 dotest "util.stanza" 21 dotest "util.stanza"
22 dotest "util.sasl.scram" 22 dotest "util.sasl.scram"
23 23
24 dosingletest("test_sasl.lua", "latin1toutf8"); 24 dosingletest("test_sasl.lua", "latin1toutf8");
25 end 25 end
134 print("WARNING: ", "Failed to load module: "..unitname, err); 134 print("WARNING: ", "Failed to load module: "..unitname, err);
135 return; 135 return;
136 end 136 end
137 137
138 local oldmodule, old_M = _fakeG.module, _fakeG._M; 138 local oldmodule, old_M = _fakeG.module, _fakeG._M;
139 _fakeG.module = function () _M = _G end 139 _fakeG.module = function () _M = unit end
140 setfenv(chunk, unit); 140 setfenv(chunk, unit);
141 local success, err = pcall(chunk); 141 local success, ret = pcall(chunk);
142 _fakeG.module, _fakeG._M = oldmodule, old_M; 142 _fakeG.module, _fakeG._M = oldmodule, old_M;
143 if not success then 143 if not success then
144 print("WARNING: ", "Failed to initialise module: "..unitname, err); 144 print("WARNING: ", "Failed to initialise module: "..unitname, err);
145 return; 145 return;
146 end 146 end
147 147
148 if type(ret) == "table" then
149 for k,v in pairs(ret) do
150 unit[k] = v;
151 end
152 end
153
148 for name, f in pairs(unit) do 154 for name, f in pairs(unit) do
149 local test = rawget(tests, name); 155 local test = rawget(tests, name);
150 if type(f) ~= "function" then 156 if type(f) ~= "function" then
151 if verbosity >= 3 then 157 if verbosity >= 3 then
152 print("INFO: ", "Skipping "..unitname.."."..name.." because it is not a function"); 158 print("INFO: ", "Skipping "..unitname.."."..name.." because it is not a function");