blob: 517680c4909098c339fa3415cfaf092fa457951f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#!/usr/bin/env lua
local luacov = require("luacov.stats")
local data = luacov.load_stats()
if not data then
print("Could not load stats file "..luacov.statsfile..".")
print("Run your Lua program with -lluacov and then rerun luacov.")
os.exit(1)
end
local report = io.open("luacov.report.out", "w")
local names = {}
for filename, _ in pairs(data) do
table.insert(names, filename)
end
table.sort(names)
for _, filename in ipairs(names) do
local filedata = data[filename]
local file = io.open(filename, "r")
if file then
report:write("\n")
report:write("==============================================================================\n")
report:write(filename, "\n")
report:write("==============================================================================\n")
local line_nr = 1
while true do
local line = file:read("*l")
if not line then break end
if line:match("^%s*%-%-") -- Comment line
or line:match("^%s*$") -- Empty line
or line:match("^%s*end,?%s*$") -- Single "end"
or line:match("^%s*else%s*$") -- Single "else"
or line:match("^#!") -- Unix hash-bang magic line
then
report:write("\t", line, "\n")
else
local hits = filedata[line_nr]
if not hits then hits = 0 end
report:write(hits, "\t", line, "\n")
end
line_nr = line_nr + 1
end
end
end
|