Merge pull request #38 from vxcontrol/fix-luacov-import

fix importing luacov for tests running
This commit is contained in:
Dmitry Ng
2023-01-16 11:23:41 +03:00
committed by GitHub
3 changed files with 33 additions and 1 deletions
+2 -1
View File
@@ -19,5 +19,6 @@ tmpdir/*
luacov-html
luacov.*
!luacov.lua
coverage-report
junit.xml
junit.xml
@@ -0,0 +1,23 @@
return function()
-- Function to initialize luacov if available
local loadLuaCov = function(config)
local result, luacov = pcall(require, 'luacov.runner')
if not result then
return nil, 'LuaCov not found on the system, try running without --coverage option, or install LuaCov first'
end
-- call it to start
luacov(config)
-- exclude busted files
table.insert(luacov.configuration.exclude, 'busted_bootstrap$')
table.insert(luacov.configuration.exclude, 'busted%.')
table.insert(luacov.configuration.exclude, 'luassert%.')
table.insert(luacov.configuration.exclude, 'say%.')
table.insert(luacov.configuration.exclude, 'pl%.')
return true
end
return loadLuaCov
end
+8
View File
@@ -0,0 +1,8 @@
--- Loads `luacov.runner` and immediately starts it.
-- Useful for launching scripts from the command-line. Returns the `luacov.runner` module.
-- @class module
-- @name luacov
-- @usage lua -lluacov sometest.lua
local runner = require("luacov.runner")
runner.init()
return runner