diff options
author | James McCoy <jamessan@jamessan.com> | 2020-08-10 19:30:58 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-10 19:30:58 -0400 |
commit | 272389da3278c4c4b5353854edb32dce25b11587 (patch) | |
tree | c6f8df9a723cc7514d4c45f4b1bc7b833303925c /test/functional/ex_cmds | |
parent | 602e7505e2cd47ce0f45236a5175709d8ce2c489 (diff) | |
parent | e797d0658c70c734485f54e070cc7300dc47db57 (diff) | |
download | rneovim-272389da3278c4c4b5353854edb32dce25b11587.tar.gz rneovim-272389da3278c4c4b5353854edb32dce25b11587.tar.bz2 rneovim-272389da3278c4c4b5353854edb32dce25b11587.zip |
Merge pull request #12632 from tjdevries/tjdevries/packadd_lua
[RFC] lua: Force update of rtp more often
Diffstat (limited to 'test/functional/ex_cmds')
-rw-r--r-- | test/functional/ex_cmds/packadd_spec.lua | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/test/functional/ex_cmds/packadd_spec.lua b/test/functional/ex_cmds/packadd_spec.lua new file mode 100644 index 0000000000..2b0810cf9b --- /dev/null +++ b/test/functional/ex_cmds/packadd_spec.lua @@ -0,0 +1,74 @@ +local helpers = require('test.functional.helpers')(after_each) + +local clear = helpers.clear +local eq = helpers.eq +local exec_lua = helpers.exec_lua + +describe('packadd', function() + before_each(function() + -- Primarily taken from test/functional/legacy/packadd_spec.lua + clear() + exec_lua [[ + TopDirectory = vim.fn.expand(vim.fn.getcwd() .. '/Xdir_lua') + PlugDirectory = TopDirectory .. '/pack/mine/opt/mytest' + + vim.o.packpath = TopDirectory + + function FindPathsContainingDir(dir) + return vim.fn.filter( + vim.split(package.path, ';'), + function(k, v) + return string.find(v, 'mytest') ~= nil + end + ) + end + ]] + end) + + after_each(function() + exec_lua [[ + vim.fn.delete(TopDirectory, 'rf') + ]] + end) + + it('should immediately update package.path in lua', function() + local count_of_paths = exec_lua [[ + vim.fn.mkdir(PlugDirectory .. '/lua/', 'p') + + local num_paths_before = #FindPathsContainingDir('mytest') + + vim.cmd("packadd mytest") + + local num_paths_after = #FindPathsContainingDir('mytest') + + return { num_paths_before, num_paths_after } + ]] + + eq({0, 2}, count_of_paths) + end) + + it('should immediately update package.path in lua even if lua directory does not exist', function() + local count_of_paths = exec_lua [[ + vim.fn.mkdir(PlugDirectory .. '/plugin/', 'p') + + local num_paths_before = #FindPathsContainingDir('mytest') + + vim.cmd("packadd mytest") + + local num_paths_after = #FindPathsContainingDir('mytest') + + return { num_paths_before, num_paths_after } + ]] + + eq({0, 2}, count_of_paths) + end) + + it('should error for invalid paths', function() + local count_of_paths = exec_lua [[ + local ok, err = pcall(vim.cmd, "packadd asdf") + return ok + ]] + + eq(false, count_of_paths) + end) +end) |