aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAsbjørn Sloth Tønnesen <ast@fiberby.net>2017-03-06 10:58:06 +0000
committerAsbjørn Sloth Tønnesen <ast@2e8.dk>2017-03-06 10:58:06 +0000
commit884559d48af1a7c4b8d1aac8058260c58b1cc91c (patch)
tree87b834188a6f7bf149acd2e6abe60cd103b04ab7 /test
parenta2216e14521763e702f69a9bfd046aa15a5b3f52 (diff)
downloadlua-inet-884559d48af1a7c4b8d1aac8058260c58b1cc91c.tar.gz
lua-inet-884559d48af1a7c4b8d1aac8058260c58b1cc91c.tar.xz
lua-inet-884559d48af1a7c4b8d1aac8058260c58b1cc91c.zip
tests: enable tests to be run under plain lua
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
Diffstat (limited to 'test')
-rw-r--r--test/init.lua18
1 files changed, 13 insertions, 5 deletions
diff --git a/test/init.lua b/test/init.lua
index 0a4e05b..97f94ac 100644
--- a/test/init.lua
+++ b/test/init.lua
@@ -1,6 +1,7 @@
-local utils = require 'lem.utils'
+--local utils = require 'lem.utils'
-local updatenow = utils.updatenow
+--local updatenow = utils.updatenow
+local function updatenow() return nil end
local pack = table.pack
local unpack = table.unpack
local format = string.format
@@ -75,7 +76,9 @@ function test:run()
t1 = updatenow()
local ret, msg = xpcall(tester, msg_handler, self)
t2 = updatenow()
- self.runtime = t2 - t1
+ if t1 then
+ self.runtime = t2 - t1
+ end
self:leave()
if not ret then
self.error_msg = msg
@@ -125,8 +128,13 @@ function test:stats()
end
local run, passed, asserts = master.run, master.passed, master.assert_cnt
if run == passed then
- print(format('%d/%d All tests passed, %d assertions in %.3fs',
- run, passed, asserts, master.test.runtime))
+ local runtime = master.test.runtime
+ local runtimestr = ''
+ if runtime then
+ runtimestr = format(' in %.3fs', runtime)
+ end
+ print(format('%d/%d All tests passed, %d assertions%s',
+ run, passed, asserts, runtimestr))
else
print(format('%d/%d %d failed', run, passed, run-passed))
end