diff src/testdir/test_mksession.vim @ 15613:90f01701ecad v8.1.0814

patch 8.1.0814: :mksession cannot handle a very long 'runtimepath' commit https://github.com/vim/vim/commit/ed18f2c03ae4786b489943cb575bb781a70356e4 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jan 24 20:30:52 2019 +0100 patch 8.1.0814: :mksession cannot handle a very long 'runtimepath' Problem: :mksession cannot handle a very long 'runtimepath'. (Timothy Madden) Solution: Expand each part separately, instead of the whole option at once. (Christian Brabandt, closes #3466)
author Bram Moolenaar <Bram@vim.org>
date Thu, 24 Jan 2019 20:45:06 +0100
parents 9da8ae285a02
children c91618229f99
line wrap: on
line diff
--- a/src/testdir/test_mksession.vim
+++ b/src/testdir/test_mksession.vim
@@ -3,7 +3,7 @@
 set encoding=latin1
 scriptencoding latin1
 
-if !has('multi_byte') || !has('mksession')
+if !has('mksession')
   finish
 endif
 
@@ -126,6 +126,29 @@ func Test_mksession_large_winheight()
   call delete('Xtest_mks_winheight.out')
 endfunc
 
+func Test_mksession_rtp()
+  new
+  let _rtp=&rtp
+  " Make a real long (invalid) runtimepath value,
+  " that should exceed PATH_MAX (hopefully)
+  let newrtp=&rtp.',~'.repeat('/foobar', 1000)
+  let newrtp.=",".expand("$HOME")."/.vim"
+  let &rtp=newrtp
+
+  " determine expected value
+  let expected=split(&rtp, ',')
+  let expected = map(expected, '"set runtimepath+=".v:val')
+  let expected = ['set runtimepath='] + expected
+  let expected = map(expected, {v,w -> substitute(w, $HOME, "~", "g")})
+
+  mksession! Xtest_mks.out
+  let &rtp=_rtp
+  let li = filter(readfile('Xtest_mks.out'), 'v:val =~# "runtimepath"')
+  call assert_equal(expected, li)
+
+  call delete('Xtest_mks.out')
+endfunc
+
 func Test_mksession_arglist()
   argdel *
   next file1 file2 file3 file4