aboutsummaryrefslogtreecommitdiff
path: root/test/functional/legacy/packadd_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/legacy/packadd_spec.lua')
-rw-r--r--test/functional/legacy/packadd_spec.lua60
1 files changed, 53 insertions, 7 deletions
diff --git a/test/functional/legacy/packadd_spec.lua b/test/functional/legacy/packadd_spec.lua
index 7c3d48317b..a73beef0cd 100644
--- a/test/functional/legacy/packadd_spec.lua
+++ b/test/functional/legacy/packadd_spec.lua
@@ -14,6 +14,10 @@ describe('packadd', function()
clear()
source([=[
+ func Escape(s)
+ return escape(a:s, '\~')
+ endfunc
+
func SetUp()
let s:topdir = expand(getcwd() . '/Xdir')
exe 'set packpath=' . s:topdir
@@ -50,8 +54,8 @@ describe('packadd', function()
call assert_equal(77, g:plugin_also_works)
call assert_true(17, g:ftdetect_works)
call assert_true(len(&rtp) > len(rtp))
- call assert_true(&rtp =~ (escape(s:plugdir, '\') . '\($\|,\)'))
- call assert_true(&rtp =~ escape(expand(s:plugdir . '/after$'), '\'))
+ call assert_match(Escape(s:plugdir) . '\($\|,\)', &rtp)
+ call assert_match(Escape(expand(s:plugdir . '/after$')), &rtp)
" Check exception
call assert_fails("packadd directorynotfound", 'E919:')
@@ -73,7 +77,7 @@ describe('packadd', function()
call assert_equal(24, g:plugin_works)
call assert_true(len(&rtp) > len(rtp))
- call assert_true(&rtp =~ (escape(plugdir, '\') . '\($\|,\)'))
+ call assert_match(Escape(plugdir) . '\($\|,\)', &rtp)
endfunc
func Test_packadd_noload()
@@ -90,7 +94,7 @@ describe('packadd', function()
packadd! mytest
call assert_true(len(&rtp) > len(rtp))
- call assert_true(&rtp =~ (escape(s:plugdir, '\') . '\($\|,\)'))
+ call assert_match(Escape(s:plugdir) . '\($\|,\)', &rtp)
call assert_equal(0, g:plugin_works)
" check the path is not added twice
@@ -122,7 +126,7 @@ describe('packadd', function()
packadd mytest
" Must have been inserted in the middle, not at the end
- call assert_true(&rtp =~ escape(expand('/pack/mine/opt/mytest').',', '\'))
+ call assert_match(Escape(expand('/pack/mine/opt/mytest').','), &rtp)
call assert_equal(44, g:plugin_works)
" No change when doing it again.
@@ -135,6 +139,48 @@ describe('packadd', function()
exec "silent !" (has('win32') ? "rd /q/s" : "rm") top2_dir
endfunc
+ func Test_packadd_symlink_dir2()
+ let top2_dir = expand(s:topdir . '/Xdir2')
+ let real_dir = expand(s:topdir . '/Xsym/pack')
+ call mkdir(top2_dir, 'p')
+ call mkdir(real_dir, 'p')
+ let &rtp = top2_dir . ',' . top2_dir . '/after'
+ let &packpath = &rtp
+
+ if has('win32')
+ exec "silent! !mklink /d" top2_dir "Xsym"
+ else
+ exec "silent !ln -s ../Xsym/pack" top2_dir . '/pack'
+ endif
+ let s:plugdir = expand(top2_dir . '/pack/mine/opt/mytest')
+ call mkdir(s:plugdir . '/plugin', 'p')
+
+ exe 'split ' . s:plugdir . '/plugin/test.vim'
+ call setline(1, 'let g:plugin_works = 48')
+ wq
+ let g:plugin_works = 0
+
+ packadd mytest
+
+ " Must have been inserted in the middle, not at the end
+ call assert_match(Escape(expand('/Xdir2/pack/mine/opt/mytest').','), &rtp)
+ call assert_equal(48, g:plugin_works)
+
+ " No change when doing it again.
+ let rtp_before = &rtp
+ packadd mytest
+ call assert_equal(rtp_before, &rtp)
+
+ set rtp&
+ let rtp = &rtp
+ if has('win32')
+ exec "silent !rd /q/s" top2_dir
+ else
+ exec "silent !rm" top2_dir . '/pack'
+ exec "silent !rmdir" top2_dir
+ endif
+ endfunc
+
func Test_packloadall()
" plugin foo with an autoload directory
let fooplugindir = &packpath . '/pack/mine/start/foo/plugin'
@@ -190,9 +236,9 @@ describe('packadd', function()
helptags ALL
let tags1 = readfile(docdir1 . '/tags')
- call assert_true(tags1[0] =~ 'look-here')
+ call assert_match('look-here', tags1[0])
let tags2 = readfile(docdir2 . '/tags')
- call assert_true(tags2[0] =~ 'look-away')
+ call assert_match('look-away', tags2[0])
endfunc
func Test_colorscheme()