pause and resume coverage

This commit is contained in:
leaf corcoran 2013-10-09 14:24:13 -07:00
parent eb8788cb89
commit 4ccc10d056
3 changed files with 17 additions and 6 deletions

View File

@ -108,6 +108,7 @@ if not opts.d then
else else
if cov then if cov then
cov:stop() cov:stop()
cov:print_results()
end end
end end
else else

View File

@ -59,8 +59,10 @@ end
local CodeCoverage local CodeCoverage
do do
local _base_0 = { local _base_0 = {
start = function(self) reset = function(self)
self.line_counts = create_counter() self.line_counts = create_counter()
end,
start = function(self)
return debug.sethook((function() return debug.sethook((function()
local _base_1 = self local _base_1 = self
local _fn_0 = _base_1.process_line local _fn_0 = _base_1.process_line
@ -70,8 +72,9 @@ do
end)(), "l") end)(), "l")
end, end,
stop = function(self) stop = function(self)
debug.sethook() return debug.sethook()
local line_table = require("moonscript.line_tables") end,
print_results = function(self)
return self:format_results() return self:format_results()
end, end,
process_line = function(self, _, line_no) process_line = function(self, _, line_no)
@ -118,7 +121,9 @@ do
} }
_base_0.__index = _base_0 _base_0.__index = _base_0
local _class_0 = setmetatable({ local _class_0 = setmetatable({
__init = function() end, __init = function(self)
return self:reset()
end,
__base = _base_0, __base = _base_0,
__name = "CodeCoverage" __name = "CodeCoverage"
}, { }, {

View File

@ -40,14 +40,19 @@ format_file = (fname, positions) ->
class CodeCoverage class CodeCoverage
start: => new: =>
@reset!
reset: =>
@line_counts = create_counter! @line_counts = create_counter!
start: =>
debug.sethook @\process_line, "l" debug.sethook @\process_line, "l"
stop: => stop: =>
debug.sethook! debug.sethook!
line_table = require "moonscript.line_tables"
print_results: =>
@format_results! @format_results!
process_line: (_, line_no) => process_line: (_, line_no) =>