Mercurial > vim
diff src/testdir/test_packadd.vim @ 8388:f5972de59001 v7.4.1486
commit https://github.com/vim/vim/commit/f3654827368e6204608036353a0360e9e7c21e02
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Mar 4 22:12:23 2016 +0100
patch 7.4.1486
Problem: ":loadplugin" is not optimal, some people find it confusing.
Solution: Only use ":packadd" with an optional "!".
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 04 Mar 2016 22:15:04 +0100 |
parents | |
children | eed1ca42f9aa |
line wrap: on
line diff
new file mode 100644 --- /dev/null +++ b/src/testdir/test_packadd.vim @@ -0,0 +1,57 @@ +" Tests for 'packpath' and :packadd + +func SetUp() + let s:topdir = expand('%: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_equal(42, g:plugin_works) + call assert_equal(17, g:ftdetect_works) + call assert_true(len(&rtp) > len(rtp)) + call assert_true(&rtp =~ 'testdir/Xdir/pack/mine/opt/mytest\($\|,\)') +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 =~ 'testdir/Xdir/pack/mine/opt/mytest\($\|,\)') + 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