summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Melnichenko <mpeterval@gmail.com>2016-06-29 13:04:51 +0300
committerPeter Melnichenko <mpeterval@gmail.com>2016-06-29 13:04:51 +0300
commit0c8d64d93139af71810bdba979dd9211a8f6ec55 (patch)
tree412aa6f35ae52fcad5e29a83c0613e4e41e248e1
parent2f8dbf26c944f43a73769d8c451a0090f49ed30f (diff)
downloadluacov-0c8d64d93139af71810bdba979dd9211a8f6ec55.tar.bz2
Use the new util functions in luacov.reporter
-rw-r--r--src/luacov/reporter.lua12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/luacov/reporter.lua b/src/luacov/reporter.lua
index 4e83a33..ac049e3 100644
--- a/src/luacov/reporter.lua
+++ b/src/luacov/reporter.lua
@@ -5,7 +5,7 @@
local reporter = {}
local luacov = require("luacov.runner")
-local load = loadstring or load -- luacheck: compat
+local util = require("luacov.util")
-- Raw version of string.gsub
local function replace(s, old, new)
@@ -479,8 +479,7 @@ function ReporterBase:_run_file(filename)
local file, open_err = io.open(filename)
if not file then
- open_err = open_err:gsub("^" .. filename:gsub("%p", "%%%0") .. ": ", "")
- self:on_file_error(filename, "open", open_err)
+ self:on_file_error(filename, "open", util.unprefix(open_err, filename .. ": "))
return
end
@@ -494,13 +493,10 @@ function ReporterBase:_run_file(filename)
return
end
- local func, load_err = load(src, "@file")
+ local func, load_err = util.load_string(src, nil, "@file")
if not func then
- local line_number
- line_number, load_err = load_err:match("^file:(%d+): (.*)")
- self:on_file_error(filename, "load",
- load_err and ("line %d: %s"):format(line_number, load_err) or "error")
+ self:on_file_error(filename, "load", "line " .. util.unprefix(load_err, "file:"))
return
end