Mercurial > prosody-hg
comparison tests/test.lua @ 5776:bd0ff8ae98a8
Remove all trailing whitespace
| author | Florian Zeitz <florob@babelmonkeys.de> |
|---|---|
| date | Fri, 09 Aug 2013 17:48:21 +0200 |
| parents | 6df0ec991f2e |
| children | 61b6a4fc65f1 |
comparison
equal
deleted
inserted
replaced
| 5775:a6c2b8933507 | 5776:bd0ff8ae98a8 |
|---|---|
| 1 -- Prosody IM | 1 -- Prosody IM |
| 2 -- Copyright (C) 2008-2010 Matthew Wild | 2 -- Copyright (C) 2008-2010 Matthew Wild |
| 3 -- Copyright (C) 2008-2010 Waqas Hussain | 3 -- Copyright (C) 2008-2010 Waqas Hussain |
| 4 -- | 4 -- |
| 5 -- This project is MIT/X11 licensed. Please see the | 5 -- This project is MIT/X11 licensed. Please see the |
| 6 -- COPYING file in the source package for more information. | 6 -- COPYING file in the source package for more information. |
| 7 -- | 7 -- |
| 8 | 8 |
| 9 | 9 |
| 18 dotest "core.s2smanager" | 18 dotest "core.s2smanager" |
| 19 dotest "core.configmanager" | 19 dotest "core.configmanager" |
| 20 dotest "util.ip" | 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 |
| 26 | 26 |
| 27 local verbosity = tonumber(arg[1]) or 2; | 27 local verbosity = tonumber(arg[1]) or 2; |
| 28 | 28 |
| 85 local success, err = pcall(chunk); | 85 local success, err = pcall(chunk); |
| 86 if not success then | 86 if not success then |
| 87 print("WARNING: ", "Failed to initialise tests for "..testname, err); | 87 print("WARNING: ", "Failed to initialise tests for "..testname, err); |
| 88 return; | 88 return; |
| 89 end | 89 end |
| 90 | 90 |
| 91 if type(tests[fname]) ~= "function" then | 91 if type(tests[fname]) ~= "function" then |
| 92 error(testname.." has no test '"..fname.."'", 0); | 92 error(testname.." has no test '"..fname.."'", 0); |
| 93 end | 93 end |
| 94 | 94 |
| 95 | 95 |
| 96 local line_hook, line_info = new_line_coverage_monitor(testname); | 96 local line_hook, line_info = new_line_coverage_monitor(testname); |
| 97 debug.sethook(line_hook, "l") | 97 debug.sethook(line_hook, "l") |
| 98 local success, ret = pcall(tests[fname]); | 98 local success, ret = pcall(tests[fname]); |
| 99 debug.sethook(); | 99 debug.sethook(); |
| 100 if not success then | 100 if not success then |
| 132 local chunk, err = loadfile(fn); | 132 local chunk, err = loadfile(fn); |
| 133 if not chunk then | 133 if not chunk then |
| 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 = unit end | 139 _fakeG.module = function () _M = unit end |
| 140 setfenv(chunk, unit); | 140 setfenv(chunk, unit); |
| 141 local success, ret = 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 | 148 if type(ret) == "table" then |
| 149 for k,v in pairs(ret) do | 149 for k,v in pairs(ret) do |
| 150 unit[k] = v; | 150 unit[k] = v; |
| 151 end | 151 end |
| 152 end | 152 end |
| 195 end | 195 end |
| 196 | 196 |
| 197 function new_line_coverage_monitor(file) | 197 function new_line_coverage_monitor(file) |
| 198 local lines_hit, funcs_hit = {}, {}; | 198 local lines_hit, funcs_hit = {}, {}; |
| 199 local total_lines, covered_lines = 0, 0; | 199 local total_lines, covered_lines = 0, 0; |
| 200 | 200 |
| 201 for line in io.lines(file) do | 201 for line in io.lines(file) do |
| 202 total_lines = total_lines + 1; | 202 total_lines = total_lines + 1; |
| 203 end | 203 end |
| 204 | 204 |
| 205 return function (event, line) -- Line hook | 205 return function (event, line) -- Line hook |
| 206 if not lines_hit[line] then | 206 if not lines_hit[line] then |
| 207 local info = debug.getinfo(2, "fSL") | 207 local info = debug.getinfo(2, "fSL") |
| 208 if not info.source:find(file) then return; end | 208 if not info.source:find(file) then return; end |
| 209 if not funcs_hit[info.func] and info.activelines then | 209 if not funcs_hit[info.func] and info.activelines then |
