diff --git a/.gitignore b/.gitignore index 5f2dd47..bf9a09e 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,9 @@ doc/tags # panvimdoc /panvimdoc/ + +# luacov +luacov.report +luacov.report.index +luacov.stats + diff --git a/.luacov b/.luacov new file mode 100644 index 0000000..1684712 --- /dev/null +++ b/.luacov @@ -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 diff --git a/Makefile b/Makefile index 5d2bf47..4f568ca 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,25 @@ format: @stylua --config-path=.stylua.toml lua/ examples/ 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: @bash ./scripts/docgen.sh diff --git a/lua/tests/minimal_init.lua b/lua/tests/minimal_init.lua index 37b701d..e8052ce 100644 --- a/lua/tests/minimal_init.lua +++ b/lua/tests/minimal_init.lua @@ -1,11 +1,12 @@ -- Copyright (c) 2020-2021 shadmansaleh -- MIT license, see LICENSE for more details. +if os.getenv('TEST_COV') then + require('luacov') +end -- load lualine and plenary -vim.api.nvim_exec( - [[ +vim.cmd [[ set rtp+=. set rtp+=../plenary.nvim -]], - false -) + runtime plugin/plenary.vim +]]