diff options
Diffstat (limited to 'utils/merge-luacov-stats')
-rw-r--r-- | utils/merge-luacov-stats | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/utils/merge-luacov-stats b/utils/merge-luacov-stats index f4b28ae..080115d 100644 --- a/utils/merge-luacov-stats +++ b/utils/merge-luacov-stats @@ -31,6 +31,43 @@ local infiles = {...} local stats = require("luacov.stats") +local instpfx = assert(io.popen("pwd", "r")):read("*l") +if instpfx:sub(-1) ~= "/" then instpfx = instpfx .. "/" end +instpfx = instpfx .. "testing/inst/" + +local inst_prefix_map = { + { "etc/gitano/plugins/", "plugins/" }, + { "lib/gitano/plugins/", "plugins/" }, + { "lib/gitano/bin/../../../bin/", "bin/", ".in" }, + { "lib/gitano/bin/", "bin/", ".in" }, + { "share/lua/5.1/", "lib/" }, +} + +local noninst_prefix_map = { + { "hooks/", "bin/gitano-", "-hook.in" }, +} + +local function remap_prefixes(fname, map) + for _, mapentry in ipairs(map) do + local pfx, replace, suffix = mapentry[1], mapentry[2], mapentry[3] + if fname:sub(1, #pfx) == pfx then + fname = replace .. fname:sub(#pfx+1, -1) + if suffix then + fname = fname .. suffix + end + end + end + return fname +end + +local function remap_fname(fname) + if fname:sub(1, #instpfx) ~= instpfx then + return remap_prefixes(fname, noninst_prefix_map) + end + fname = fname:sub(#instpfx+1, -1) + return remap_prefixes(fname, inst_prefix_map) +end + -- Step 1, merge all the coverage files together into a single one... local merged = {} @@ -38,6 +75,7 @@ local merged = {} function merge_data(fname) local subdata = stats.load(fname) for fname, fdat in pairs(subdata) do + fname = remap_fname(fname) if not merged[fname] then merged[fname] = fdat else |