diff options
author | koray kavukcuoglu <koray@kavukcuoglu.org> | 2013-01-03 14:31:00 +0400 |
---|---|---|
committer | koray kavukcuoglu <koray@kavukcuoglu.org> | 2013-01-03 14:31:00 +0400 |
commit | 756083d08ad1bd133f478cf82dfc6ed38801ec55 (patch) | |
tree | 9b0591ee04162bae54790e19dc0513d61e5ac7c9 /Tester.lua | |
parent | 65f0ea78703778c39dc06e77dfdb3da261cd8aba (diff) |
protect tester calls with pcall.
Diffstat (limited to 'Tester.lua')
-rw-r--r-- | Tester.lua | 21 |
1 files changed, 11 insertions, 10 deletions
@@ -87,13 +87,14 @@ end function Tester:pcall(f) local nerr = #self.errors - local res = f() --- local stat, result = pcall(f) --- if not stat then --- result = result .. debug.traceback() --- end --- return stat, result, stat and (nerr == #self.errors) - return true, res, nerr == #self.errors + -- local res = f() + local stat, result = pcall(f) + if not stat then + result = result .. debug.traceback() + self.errors[#self.errors+1] = self.curtestname .. '\n Function call failed \n' .. result .. '\n' + end + return stat, result, stat and (nerr == #self.errors) + -- return true, res, nerr == #self.errors end function Tester:report(tests) @@ -156,9 +157,9 @@ function Tester:run(run_tests) end if not stat then - print() - print('Function call failed: Test No ' .. i .. ' ' .. testnames[i]) - print(message) + -- print() + -- print('Function call failed: Test No ' .. i .. ' ' .. testnames[i]) + -- print(message) end collectgarbage() end |