RsCov.lua:
--[[
Sample:
-- test/test2/t.lua :
function testt()
print("hello world")
print("bad world")
end
-- test.lua :
require("RsCov")
require("test/test2/t")
RsCov.start_cov( "test/test2/t.lua" )
testt()
local dump = RsCov.dump_file("t.lua")
print(dump)
-- output :
hello world
bad world
Cov:3 Uncov:6 Total:9 Pct:0.33333333333333
1 0
2 0
3 0 function testt()
4 1 print("hello world")
5 1 print("bad world")
6 1 end
7 0
8 0
9 0
]]
file_tbl = file_tbl or {}
rawcoroutinecreate = rawcoroutinecreate or coroutine.create
rawcoroutinewrap = rawcoroutinewrap or coroutine.wrap
rawexit = rawexit or os.exit
IsStarted = IsStarted or false
function trim_path( name )
local s1,s2,s3
s1= name:find("/", 1, true )
while s1 do
s2 = s1
s1 = name:find("/", s1+1, true )
end
if s2 then
s1,s3= name:find(".\\", s2+1, true )
else
s1,s3= name:find(".\\", 1, true )
end
while s1 do
s2 = s3
s1 = name:find(".\\", s2+1, true )
end
if s2 then
name = name:sub( s2+1 )
end
return name
end
local function on_line(_, line_nr)
-- get name of processed file; ig