patch 8.0.1469: when package path is a symlink 'runtimepath' is wrong
Problem: When package path is a symlink adding it to 'runtimepath' happens
at the end.
Solution: Do not resolve symlinks before locating the position in
'runtimepath'. (Ozaki Kiichi, closes #2604)
diff --git a/src/testdir/test_packadd.vim b/src/testdir/test_packadd.vim
index 09b9b82..889d77f 100644
--- a/src/testdir/test_packadd.vim
+++ b/src/testdir/test_packadd.vim
@@ -37,8 +37,8 @@
call assert_equal(77, g:plugin_also_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\($\|,\)')
- call assert_true(&rtp =~ '/testdir/Xdir/pack/mine/opt/mytest/after$')
+ call assert_match('/testdir/Xdir/pack/mine/opt/mytest\($\|,\)', &rtp)
+ call assert_match('/testdir/Xdir/pack/mine/opt/mytest/after$', &rtp)
" Check exception
call assert_fails("packadd directorynotfound", 'E919:')
@@ -60,7 +60,7 @@
call assert_equal(24, g:plugin_works)
call assert_true(len(&rtp) > len(rtp))
- call assert_true(&rtp =~ '/testdir/Xdir/pack/mine/start/other\($\|,\)')
+ call assert_match('/testdir/Xdir/pack/mine/start/other\($\|,\)', &rtp)
endfunc
func Test_packadd_noload()
@@ -77,7 +77,7 @@
packadd! mytest
call assert_true(len(&rtp) > len(rtp))
- call assert_true(&rtp =~ 'testdir/Xdir/pack/mine/opt/mytest\($\|,\)')
+ call assert_match('testdir/Xdir/pack/mine/opt/mytest\($\|,\)', &rtp)
call assert_equal(0, g:plugin_works)
" check the path is not added twice
@@ -108,7 +108,7 @@
packadd mytest
" Must have been inserted in the middle, not at the end
- call assert_true(&rtp =~ '/pack/mine/opt/mytest,')
+ call assert_match('/pack/mine/opt/mytest,', &rtp)
call assert_equal(44, g:plugin_works)
" No change when doing it again.
@@ -121,6 +121,43 @@
exec "silent !rm" top2_dir
endfunc
+func Test_packadd_symlink_dir2()
+ if !has('unix')
+ return
+ endif
+ let top2_dir = s:topdir . '/Xdir2'
+ let real_dir = s:topdir . '/Xsym/pack'
+ call mkdir(top2_dir, 'p')
+ call mkdir(real_dir, 'p')
+ let &rtp = top2_dir . ',' . top2_dir . '/after'
+ let &packpath = &rtp
+
+ exec "silent !ln -s ../Xsym/pack" top2_dir . '/pack'
+ let s:plugdir = 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('/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
+ exec "silent !rm" top2_dir . '/pack'
+ exec "silent !rmdir" top2_dir
+endfunc
+
" Check command-line completion for 'packadd'
func Test_packadd_completion()
let optdir1 = &packpath . '/pack/mine/opt'
@@ -196,9 +233,9 @@
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()