From 66459b7c98c67f8a9d39de8f08e8e8f1fca0e359 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 6 Aug 2016 19:01:55 +0200 Subject: patch 7.4.2164 Problem: It is not possible to use plugins in an "after" directory to tune the behavior of a package. Solution: First load plugins from non-after directories, then packages and finally plugins in after directories. Reset 'loadplugins' before executing --cmd arguments. --- src/testdir/Makefile | 4 +++- src/testdir/setup.vim | 3 ++- src/testdir/shared.vim | 21 +++++++++++++++++++ src/testdir/test_startup.vim | 50 +++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 75 insertions(+), 3 deletions(-) (limited to 'src/testdir') diff --git a/src/testdir/Makefile b/src/testdir/Makefile index 5c629ed3f7..2153039d56 100644 --- a/src/testdir/Makefile +++ b/src/testdir/Makefile @@ -127,4 +127,6 @@ newtestssilent: $(NEW_TESTS) .vim.res: - $(RUN_VIMTEST) -u NONE -U NONE -S runtest.vim $*.vim + @echo "$(RUN_VIMTEST)" > vimcmd + $(RUN_VIMTEST) -U NONE -S runtest.vim $*.vim + @rm vimcmd diff --git a/src/testdir/setup.vim b/src/testdir/setup.vim index f7e475a81a..dee3de2120 100644 --- a/src/testdir/setup.vim +++ b/src/testdir/setup.vim @@ -1,7 +1,8 @@ " Common preparations for running tests. -" Make sure 'runtimepath' does not include $HOME. +" Make sure 'runtimepath' and 'packpath' does not include $HOME. set rtp=$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after +let &packpath = &rtp " Only when the +eval feature is present. if 1 diff --git a/src/testdir/shared.vim b/src/testdir/shared.vim index b28a26c0ba..d0be24166a 100644 --- a/src/testdir/shared.vim +++ b/src/testdir/shared.vim @@ -120,3 +120,24 @@ func WaitFor(expr) sleep 10m endfor endfunc + +" Run Vim, using the "vimcmd" file and "-u NORC". +" "before" is a list of commands to be executed before loading plugins. +" "after" is a list of commands to be executed after loading plugins. +" Plugins are not loaded, unless 'loadplugins' is set in "before". +" Return 1 if Vim could be executed. +func RunVim(before, after) + if !filereadable('vimcmd') + return 0 + endif + call writefile(a:before, 'Xbefore.vim') + call writefile(a:after, 'Xafter.vim') + + let cmd = readfile('vimcmd')[0] + let cmd = substitute(cmd, '-u \f\+', '-u NONE', '') + exe "silent !" . cmd . " --cmd 'so Xbefore.vim' -S Xafter.vim" + + call delete('Xbefore.vim') + call delete('Xafter.vim') + return 1 +endfunc diff --git a/src/testdir/test_startup.vim b/src/testdir/test_startup.vim index 0630b2a841..26e7b9f8ee 100644 --- a/src/testdir/test_startup.vim +++ b/src/testdir/test_startup.vim @@ -1,8 +1,56 @@ -" Check that loading startup.vim works. +" Tests for startup. + +source shared.vim +" Check that loading startup.vim works. func Test_startup_script() set compatible source $VIMRUNTIME/defaults.vim call assert_equal(0, &compatible) endfunc + +" Verify the order in which plugins are loaded: +" 1. plugins in non-after directories +" 2. packages +" 3. plugins in after directories +func Test_after_comes_later() + let before = [ + \ 'let $HOME = "/does/not/exist"', + \ 'set loadplugins', + \ 'set rtp=Xhere,Xafter', + \ 'set packpath=Xhere,Xafter', + \ 'set nomore', + \ ] + let after = [ + \ 'redir! > Xtestout', + \ 'scriptnames', + \ 'redir END', + \ 'quit', + \ ] + call mkdir('Xhere/plugin', 'p') + call writefile(['let done = 1'], 'Xhere/plugin/here.vim') + call mkdir('Xhere/pack/foo/start/foobar/plugin', 'p') + call writefile(['let done = 1'], 'Xhere/pack/foo/start/foobar/plugin/foo.vim') + + call mkdir('Xafter/plugin', 'p') + call writefile(['let done = 1'], 'Xafter/plugin/later.vim') + + call RunVim(before, after) + + let lines = readfile('Xtestout') + let expected = ['Xbefore.vim', 'here.vim', 'foo.vim', 'later.vim', 'Xafter.vim'] + let found = [] + for line in lines + for one in expected + if line =~ one + call add(found, one) + endif + endfor + endfor + call assert_equal(expected, found) + + call delete('Xtestout') + call delete('Xhere', 'rf') + call delete('Xafter', 'rf') +endfunc -- cgit v1.2.3