diff options
author | James McCoy <jamessan@jamessan.com> | 2016-04-28 22:58:24 -0400 |
---|---|---|
committer | James McCoy <jamessan@jamessan.com> | 2016-07-08 01:43:36 -0400 |
commit | 2f72f34f0407dcdf189bb4f3a4b79b51e96744bf (patch) | |
tree | b78d4294ec2c485f91df73db98365f675ba3496a /test/functional/legacy/packadd_spec.lua | |
parent | 67d8e586318a3f2f13df22f9a3b25c6d8a109e6c (diff) | |
download | rneovim-2f72f34f0407dcdf189bb4f3a4b79b51e96744bf.tar.gz rneovim-2f72f34f0407dcdf189bb4f3a4b79b51e96744bf.tar.bz2 rneovim-2f72f34f0407dcdf189bb4f3a4b79b51e96744bf.zip |
vim-patch:7.4.1486
Problem: ":loadplugin" is not optimal, some people find it confusing.
Solution: Only use ":packadd" with an optional "!".
https://github.com/vim/vim/commit/f3654827368e6204608036353a0360e9e7c21e02
Diffstat (limited to 'test/functional/legacy/packadd_spec.lua')
-rw-r--r-- | test/functional/legacy/packadd_spec.lua | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/test/functional/legacy/packadd_spec.lua b/test/functional/legacy/packadd_spec.lua new file mode 100644 index 0000000000..94b5336b9f --- /dev/null +++ b/test/functional/legacy/packadd_spec.lua @@ -0,0 +1,88 @@ +-- Tests for 'packpath' and :packadd + +local helpers = require('test.functional.helpers')(after_each) +local clear, source = helpers.clear, helpers.source +local call, eq, nvim = helpers.call, helpers.eq, helpers.meths + +local function expected_empty() + eq({}, nvim.get_vvar('errors')) +end + +describe('packadd', function() + before_each(function() + clear() + + source([=[ + func SetUp() + let s:topdir = expand('%:p:h') . '/Xdir' + exe 'set packpath=' . s:topdir + let s:plugdir = s:topdir . '/pack/mine/opt/mytest' + endfunc + + func TearDown() + call delete(s:topdir, 'rf') + endfunc + + func Test_packadd() + call mkdir(s:plugdir . '/plugin', 'p') + call mkdir(s:plugdir . '/ftdetect', 'p') + set rtp& + let rtp = &rtp + filetype on + + exe 'split ' . s:plugdir . '/plugin/test.vim' + call setline(1, 'let g:plugin_works = 42') + wq + + exe 'split ' . s:plugdir . '/ftdetect/test.vim' + call setline(1, 'let g:ftdetect_works = 17') + wq + + packadd mytest + + call assert_true(42, g:plugin_works) + call assert_true(17, g:ftdetect_works) + call assert_true(len(&rtp) > len(rtp)) + call assert_true(&rtp =~ (s:plugdir . '\($\|,\)')) + endfunc + + func Test_packadd_noload() + call mkdir(s:plugdir . '/plugin', 'p') + call mkdir(s:plugdir . '/syntax', 'p') + set rtp& + let rtp = &rtp + + exe 'split ' . s:plugdir . '/plugin/test.vim' + call setline(1, 'let g:plugin_works = 42') + wq + let g:plugin_works = 0 + + packadd! mytest + + call assert_true(len(&rtp) > len(rtp)) + call assert_true(&rtp =~ (s:plugdir . '\($\|,\)')) + call assert_equal(0, g:plugin_works) + + " check the path is not added twice + let new_rtp = &rtp + packadd! mytest + call assert_equal(new_rtp, &rtp) + endfunc + ]=]) + call('SetUp') + end) + + after_each(function() + call('TearDown') + end) + + it('is working', function() + call('Test_packadd') + expected_empty() + end) + + it('works with packadd!', function() + call('Test_packadd_noload') + expected_empty() + end) +end) |