summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeoff Leyland <geoff_leyland@fastmail.fm>2009-11-06 12:49:35 -0300
committerNorman Clarke <norman@njclarke.com>2009-11-06 12:49:35 -0300
commitd77e7f6f6e55befe9689dff26f8dba8a78973a98 (patch)
treeccc00a88ce9668d3a1ab27d2d1e36ea18fc00cf7
parentbcc9d9b6435dfc1c90e87c1d0c64ceb9d3a6239e (diff)
downloadluacov-d77e7f6f6e55befe9689dff26f8dba8a78973a98.tar.gz
Handles os.exit by wrapping coroutine.(create|wrap)
Signed-off-by: Norman Clarke <norman@njclarke.com>
-rw-r--r--src/luacov.lua27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/luacov.lua b/src/luacov.lua
index 0c97674..a2334e3 100644
--- a/src/luacov.lua
+++ b/src/luacov.lua
@@ -54,3 +54,30 @@ if not tick then
end
debug.sethook(on_line, "l")
+
+rawcoroutinecreate = coroutine.create
+
+function coroutine.create(...)
+ local co = rawcoroutinecreate(...)
+ debug.sethook(co, on_line, "l")
+ return co
+end
+
+function coroutine.wrap(...)
+ local co = rawcoroutinecreate(...)
+ debug.sethook(co, on_line, "l")
+ return function()
+ local r = { coroutine.resume(co) }
+ if not r[1] then
+ error(r[2])
+ end
+ return unpack(r, 2)
+ end
+end
+
+
+local rawexit = os.exit
+function os.exit(...)
+ on_exit()
+ rawexit(...)
+end \ No newline at end of file