chore: setup luacov for test coverage (#85)

This commit is contained in:
Shadman 2021-10-13 21:51:19 +06:00 committed by GitHub
parent b9e06deb33
commit 632a11fa33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 6 deletions

6
.gitignore vendored
View File

@ -47,3 +47,9 @@ doc/tags
# panvimdoc # panvimdoc
/panvimdoc/ /panvimdoc/
# luacov
luacov.report
luacov.report.index
luacov.stats

20
.luacov Normal file
View File

@ -0,0 +1,20 @@
return {
include = {
"lua/lualine$",
"lua/lualine_require$",
"lua/lualine%/.+$",
},
exclude = {
"lua/lualine/themes%/.+$",
"lua/lualine/extensions%/.+$",
},
modules = {
["lualine"] = "lua/lualine.lua",
["lualine_require"] = "lua/lualine_require.lua",
["lualine.*"] = "lua/",
},
statsfile = 'luacov.stats',
reportfile = 'luacov.report',
includeuntestedfiles = true,
}
-- vim:ft=lua

View File

@ -9,7 +9,25 @@ format:
@stylua --config-path=.stylua.toml lua/ examples/ @stylua --config-path=.stylua.toml lua/ examples/
test: test:
@nvim --headless -u lua/tests/minimal_init.lua -c "PlenaryBustedDirectory lua/tests/ { minimal_init = './lua/tests/minimal_init.lua' }" @mkdir -p tmp_home
@export XDG_DATA_HOME='./tmp_home' && \
export XDG_CONFIG_HOME='./tmp_home' && \
nvim --headless --noplugin --clean -u lua/tests/minimal_init.lua -c "lua require'plenary.test_harness'.test_directory( 'lua/tests/', { minimal_init = './lua/tests/minimal_init.lua' })"
@rmdir tmp_home
# Install luacov & luacov-console from luarocks
testcov:
@mkdir -p tmp_home
@export XDG_DATA_HOME='./tmp_home' && \
export XDG_CONFIG_HOME='./tmp_home' && \
export TEST_COV=true && \
nvim --headless --noplugin --clean -u lua/tests/minimal_init.lua -c "lua require'plenary.test_harness'.test_directory( 'lua/tests/', { minimal_init = './lua/tests/minimal_init.lua' })"
@luacov-console lua/
@luacov-console -s
ifeq ($(NOCLEAN), )
@rm luacov.*
endif
@rmdir tmp_home
docgen: docgen:
@bash ./scripts/docgen.sh @bash ./scripts/docgen.sh

View File

@ -1,11 +1,12 @@
-- Copyright (c) 2020-2021 shadmansaleh -- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details. -- MIT license, see LICENSE for more details.
if os.getenv('TEST_COV') then
require('luacov')
end
-- load lualine and plenary -- load lualine and plenary
vim.api.nvim_exec( vim.cmd [[
[[
set rtp+=. set rtp+=.
set rtp+=../plenary.nvim set rtp+=../plenary.nvim
]], runtime plugin/plenary.vim
false ]]
)