diff --git a/.gitignore b/.gitignore index e3a6571..be9af14 100644 --- a/.gitignore +++ b/.gitignore @@ -19,5 +19,6 @@ tmpdir/* luacov-html luacov.* +!luacov.lua coverage-report -junit.xml \ No newline at end of file +junit.xml diff --git a/tests_framework/lua/busted/modules/luacov.lua b/tests_framework/lua/busted/modules/luacov.lua new file mode 100644 index 0000000..c26be48 --- /dev/null +++ b/tests_framework/lua/busted/modules/luacov.lua @@ -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 diff --git a/tests_framework/lua/luacov.lua b/tests_framework/lua/luacov.lua new file mode 100644 index 0000000..8c8ce45 --- /dev/null +++ b/tests_framework/lua/luacov.lua @@ -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