fix importing luacov for tests running

This commit is contained in:
Roman
2022-12-29 20:22:47 +06:00
parent 89005d4e34
commit 89c123afa7
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