summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2017-08-03 10:31:41 -0400
committerDaniel Silverstone <dsilvers@digital-scurf.org>2017-08-03 10:31:50 -0400
commita66f14bbdb23023a66eff7ad9072ce4eb597c6d2 (patch)
tree06d8e0b66d263e50c661d68ffd6c5665cf6b6545
parentb8ed8cbb5be0c21990b293454a70add5c9b3723e (diff)
downloadgitano-a66f14bbdb23023a66eff7ad9072ce4eb597c6d2.tar.gz
Rework stats merger to map test inst paths back to git pathsdsilvers/testing-improvement
-rw-r--r--utils/merge-luacov-stats38
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