Просмотр исходного кода

Put cursor inside the installer window after post-update hook

https://github.com/chrisbra/unicode.vim/issues/16
Junegunn Choi 9 лет назад
Родитель
Сommit
05a1620bb1
5 измененных файлов с 78 добавлено и 59 удалено
  1. 1 0
      plug.vim
  2. 41 26
      test/regressions.vader
  3. 11 8
      test/run
  4. 1 1
      test/test.vader
  5. 24 24
      test/workflow.vader

+ 1 - 0
plug.vim

@@ -793,6 +793,7 @@ function! s:do(pull, force, todo)
       else
         let error = 'Invalid hook type'
       endif
+      call s:switch_in()
       call setline(4, empty(error) ? (getline(4) . 'OK')
                                  \ : ('x' . getline(4)[1:] . error))
       if !empty(error)

+ 41 - 26
test/regressions.vader

@@ -19,7 +19,7 @@ Execute (#112 On-demand loading should not suppress messages from ftplugin):
 
 **********************************************************************
 Execute (#114 Should not contain empty path in &rtp):
-  call plug#begin('/tmp/plugged')
+  call plug#begin('/tmp/vim-plug-test/plugged')
   call plug#end()
 
   Log &rtp
@@ -35,7 +35,7 @@ Execute (#130 Proper cleanup of on-demand loading triggers):
 
   " Cleared on command
   call ReloadPlug()
-  call plug#begin('/tmp/plugged')
+  call plug#begin('/tmp/vim-plug-test/plugged')
   Plug 'junegunn/vim-emoji', { 'on':  ['EmojiCommand', 'EmojiCommand2', '<Plug>(EmojiMapping)'] }
   call plug#end()
   PlugInstall | q
@@ -52,7 +52,7 @@ Execute (#130 Proper cleanup of on-demand loading triggers):
 
   " Cleared on FileType
   call ReloadPlug()
-  call plug#begin('/tmp/plugged')
+  call plug#begin('/tmp/vim-plug-test/plugged')
   Plug 'junegunn/vim-emoji', { 'on': ['EmojiCommandExtra', '<Plug>(EmojiMappingExtra)'], 'for': ['emoji'] }
   call plug#end()
 
@@ -78,13 +78,13 @@ Execute (#131 Syntax error):
 **********************************************************************
 Execute (#139-1 Using new remote branch):
   " Make sure to remove the clone
-  call plug#begin('/tmp/plugged')
+  call plug#begin('/tmp/vim-plug-test/plugged')
   call plug#end()
   PlugClean!
 
   " Install master branch
-  call plug#begin('/tmp/plugged')
-  Plug expand('file:////tmp/new-branch')
+  call plug#begin('/tmp/vim-plug-test/plugged')
+  Plug expand('file:////tmp/vim-plug-test/new-branch')
   call plug#end()
   PlugUpdate
 
@@ -95,14 +95,14 @@ Execute (#139-1 Using new remote branch):
   Assert !exists('g:baz'), 'g:baz should not be found'
 
   " Create a new branch on origin
-  call system('cd /tmp/new-branch && git checkout -b new &&'
+  call system('cd /tmp/vim-plug-test/new-branch && git checkout -b new &&'
       \. 'echo "let g:bar = 1" > plugin/bar.vim && git add plugin/bar.vim &&'
       \. 'git commit -m second')
 
   " We're setting up two plugins so that parallel installer is used
-  call plug#begin('/tmp/plugged')
+  call plug#begin('/tmp/vim-plug-test/plugged')
   Plug 'junegunn/seoul256.vim'
-  Plug expand('file:////tmp/new-branch'), { 'branch': 'new' }
+  Plug expand('file:////tmp/vim-plug-test/new-branch'), { 'branch': 'new' }
   call plug#end()
   PlugUpdate
   silent %y
@@ -125,14 +125,14 @@ Expect:
 
 Execute (#139-2 Using yet another new remote branch):
   " Create another branch on origin
-  call system('cd /tmp/new-branch && git checkout master &&'
+  call system('cd /tmp/vim-plug-test/new-branch && git checkout master &&'
       \. 'git checkout -b brand-new &&'
       \. 'echo "let g:baz = 1" > plugin/baz.vim && git add plugin/baz.vim &&'
       \. 'git commit -m third')
 
   " Test Vim installer here
-  call plug#begin('/tmp/plugged')
-  Plug expand('file:////tmp/new-branch'), { 'branch': 'brand-new' }
+  call plug#begin('/tmp/vim-plug-test/plugged')
+  Plug expand('file:////tmp/vim-plug-test/new-branch'), { 'branch': 'brand-new' }
   call plug#end()
   PlugUpdate
   silent %y
@@ -154,19 +154,19 @@ Expect:
 
 Execute (#139-3 Should fail when not possible to fast-forward):
   " Commit on cloned repo
-  call system('cd /tmp/plugged/new-branch && git checkout master &&'
+  call system('cd /tmp/vim-plug-test/plugged/new-branch && git checkout master &&'
       \. 'touch foobar && git add foobar && git commit -m foobar')
 
   " Different commit on remote
-  call system('cd /tmp/new-branch && git checkout master &&'
+  call system('cd /tmp/vim-plug-test/new-branch && git checkout master &&'
       \. 'touch foobaz && git add foobaz && git commit -m foobaz')
 
   for multi in [0, 1]
-    call plug#begin('/tmp/plugged')
+    call plug#begin('/tmp/vim-plug-test/plugged')
     if multi
       Plug 'junegunn/seoul256.vim'
     endif
-    Plug expand('file:////tmp/new-branch')
+    Plug expand('file:////tmp/vim-plug-test/new-branch')
     call plug#end()
     PlugUpdate
     silent %y
@@ -210,7 +210,7 @@ Execute (#159: shell=/bin/tcsh):
   let org = &shell
   try
     set shell=/bin/tcsh
-    call plug#begin('/tmp/plugged')
+    call plug#begin('/tmp/vim-plug-test/plugged')
     Plug 'junegunn/seoul256.vim'
     call plug#end()
 
@@ -224,7 +224,7 @@ Execute (#159: shell=/bin/tcsh):
 
 **********************************************************************
 Execute (#154: Spaces in &rtp should not be escaped):
-  call plug#begin('/tmp/plug it')
+  call plug#begin('/tmp/vim-plug-test/plug it')
   Plug 'seoul256 vim'
   call plug#end()
   Log &rtp
@@ -232,7 +232,7 @@ Execute (#154: Spaces in &rtp should not be escaped):
 
 **********************************************************************
 Execute (#184: Duplicate entries in &rtp):
-  call plug#begin('/tmp/plugged')
+  call plug#begin('/tmp/vim-plug-test/plugged')
   Plug 'plugin1'
     \| Plug 'plugin0'
 
@@ -250,7 +250,7 @@ Execute (#236: Plugin removed from &rtp when .vimrc is reloaded):
   silent! delc EasyAlign
 
   call ReloadPlug()
-  call plug#begin('/tmp/plugged')
+  call plug#begin('/tmp/vim-plug-test/plugged')
   Plug 'junegunn/vim-easy-align', { 'on': 'EasyAlign' }
   call plug#end()
   PlugInstall | q
@@ -259,19 +259,19 @@ Execute (#236: Plugin removed from &rtp when .vimrc is reloaded):
   %EasyAlign=
   Assert &rtp =~ '/vim-easy-align', 'Plugin should be in &rtp'
 
-  call plug#begin('/tmp/plugged')
+  call plug#begin('/tmp/vim-plug-test/plugged')
   Plug 'junegunn/vim-easy-align', { 'on': 'EasyAlign' }
   call plug#end()
   Assert &rtp =~ '/vim-easy-align', 'Plugin should still be in &rtp'
 
 **********************************************************************
 Execute (#350: Ruby installer failed to unshallow tagged plugin on update):
-  call plug#begin('/tmp/plugged')
+  call plug#begin('/tmp/vim-plug-test/plugged')
   call plug#end()
   PlugClean!
 
   " Shallow clone. We should have at least 2 plugins to enable parallel installer.
-  call plug#begin('/tmp/plugged')
+  call plug#begin('/tmp/vim-plug-test/plugged')
   Plug 'junegunn/vim-easy-align'
   Plug 'junegunn/seoul256.vim'
   call plug#end()
@@ -279,7 +279,7 @@ Execute (#350: Ruby installer failed to unshallow tagged plugin on update):
   Assert filereadable(g:plugs['vim-easy-align'].dir.'/.git/shallow')
 
   " Now unshallowed
-  call plug#begin('/tmp/plugged')
+  call plug#begin('/tmp/vim-plug-test/plugged')
   Plug 'junegunn/vim-easy-align', { 'tag': '2.9.0' }
   Plug 'junegunn/seoul256.vim'
   call plug#end()
@@ -289,13 +289,13 @@ Execute (#350: Ruby installer failed to unshallow tagged plugin on update):
 
 **********************************************************************
 Execute (#474: Load ftdetect files in filetypedetect augroup):
-  call plug#begin('/tmp/plugged')
+  call plug#begin('/tmp/vim-plug-test/plugged')
   Plug 'junegunn/rust.vim', { 'for': 'rust', 'commit': '115d321d383eb96d438466c56cc871fcc1bd0faa' }
   call plug#end()
   PlugInstall!
   q
 
-  tabnew /tmp/any.rs
+  tabnew /tmp/vim-plug-test/any.rs
   AssertEqual 'rust', &filetype
   Log &filetype
   filetype detect
@@ -315,3 +315,18 @@ Execute (#489 On-demand loading with 'on' option should trigger BufRead autocmd)
   redir END
   Assert stridx(out, 'ftplugin-java') >= 0
   q
+
+**********************************************************************
+Execute (Cursor moved to another window during post-update hook):
+  function! DoSplit(...)
+    new
+    call setline(1, 'empty')
+  endfunction
+  call plug#begin('/tmp/vim-plug-test/plugged')
+  Plug 'junegunn/rust.vim', { 'do': function('DoSplit') }
+  call plug#end()
+  PlugInstall!
+  AssertEqual 1, line('$')
+  AssertEqual 'empty', getline(1)
+  q!
+  q

+ 11 - 8
test/run

@@ -6,9 +6,12 @@ export BASE="$PWD"
 export PLUG_SRC="$PWD/../plug.vim"
 export PLUG_FIXTURES="$PWD/fixtures"
 mkdir -p "$PLUG_FIXTURES"
+export TEMP=/tmp/vim-plug-test
+rm -rf "$TEMP"
+mkdir -p "$TEMP"
 
-cat > /tmp/mini-vimrc << VIMRC
-set rtp+=/tmp/junegunn/vader.vim
+cat > $TEMP/mini-vimrc << VIMRC
+set rtp+=$TEMP/junegunn/vader.vim
 set shell=/bin/bash
 VIMRC
 
@@ -19,7 +22,7 @@ clone() {
 }
 
 clone_repos() (
-  cd /tmp
+  cd $TEMP
   mkdir -p junegunn vim-scripts jg
   for repo in vader.vim goyo.vim rust.vim seoul256.vim vim-easy-align vim-fnr \
               vim-oblique vim-pseudocl vim-redis vim-emoji; do
@@ -80,8 +83,8 @@ DOC
   echo "echomsg 'ftplugin-c'" > "$PLUG_FIXTURES/ftplugin-msg/ftplugin/c.vim"
   echo "echomsg 'ftplugin-java'" > "$PLUG_FIXTURES/ftplugin-msg/ftplugin/java.vim"
 
-  rm -rf /tmp/new-branch
-  cd /tmp
+  rm -rf $TEMP/new-branch
+  cd $TEMP
   git init new-branch
   cd new-branch
   mkdir plugin
@@ -109,10 +112,10 @@ git --version
 VIM=$(select_vim)
 echo "Selected Vim: $VIM"
 if [ "$1" = '!' ]; then
-  $VIM -Nu /tmp/mini-vimrc -c 'Vader! test.vader' > /dev/null &&
+  $VIM -Nu $TEMP/mini-vimrc -c 'Vader! test.vader' > /dev/null &&
   prepare &&
-  $VIM -Nu /tmp/mini-vimrc -c 'let g:plug_threads = 1 | Vader! test.vader' > /dev/null
+  $VIM -Nu $TEMP/mini-vimrc -c 'let g:plug_threads = 1 | Vader! test.vader' > /dev/null
 else
-  $VIM -Nu /tmp/mini-vimrc -c 'Vader test.vader'
+  $VIM -Nu $TEMP/mini-vimrc -c 'Vader test.vader'
 fi
 

+ 1 - 1
test/test.vader

@@ -2,7 +2,7 @@ Execute (Initialize test environment):
   Save &rtp, g:plugs, g:plug_home, g:plug_window
   unlet! g:plugs g:plug_home g:plug_window
 
-  let g:plug_url_format = 'file:///tmp/%s'
+  let g:plug_url_format = 'file:///tmp/vim-plug-test/%s'
   let g:base_rtp        = &rtp
   let g:first_rtp       = split(&rtp, ',')[0]
   let g:last_rtp        = split(&rtp, ',')[-1]

+ 24 - 24
test/workflow.vader

@@ -34,7 +34,7 @@ Execute (Subsequent plug#begin() calls will reuse g:plug_home):
 Execute (Test Plug command):
 ^ Git repo with branch (DEPRECATED. USE BRANCH OPTION)
   Plug 'junegunn/seoul256.vim', { 'branch': 'yes-t_co' }
-  AssertEqual 'file:///tmp/junegunn/seoul256.vim', g:plugs['seoul256.vim'].uri
+  AssertEqual 'file:///tmp/vim-plug-test/junegunn/seoul256.vim', g:plugs['seoul256.vim'].uri
   AssertEqual join([g:temp_plugged, 'seoul256.vim/'], '/'), g:plugs['seoul256.vim'].dir
   AssertEqual 'yes-t_co', g:plugs['seoul256.vim'].branch
 
@@ -43,7 +43,7 @@ Execute (Test Plug command):
 
 ^ Git repo with tag (DEPRECATED. USE TAG OPTION)
   Plug 'junegunn/goyo.vim', '1.5.2'
-  AssertEqual 'file:///tmp/junegunn/goyo.vim', g:plugs['goyo.vim'].uri
+  AssertEqual 'file:///tmp/vim-plug-test/junegunn/goyo.vim', g:plugs['goyo.vim'].uri
   AssertEqual join([g:temp_plugged, 'goyo.vim/'], '/'), g:plugs['goyo.vim'].dir
   AssertEqual '1.5.2', g:plugs['goyo.vim'].tag
 
@@ -51,14 +51,14 @@ Execute (Test Plug command):
   AssertEqual '1.5.3', g:plugs['goyo.vim'].tag
 
   " Git URI
-  Plug 'file:///tmp/jg/vim-emoji'
-  AssertEqual 'file:///tmp/jg/vim-emoji', g:plugs['vim-emoji'].uri
+  Plug 'file:///tmp/vim-plug-test/jg/vim-emoji'
+  AssertEqual 'file:///tmp/vim-plug-test/jg/vim-emoji', g:plugs['vim-emoji'].uri
   AssertEqual 'master', g:plugs['vim-emoji'].branch
   AssertEqual join([g:temp_plugged, 'vim-emoji/'], '/'), g:plugs['vim-emoji'].dir
 
   " vim-scripts/
   Plug 'beauty256'
-  AssertEqual 'file:///tmp/vim-scripts/beauty256', g:plugs.beauty256.uri
+  AssertEqual 'file:///tmp/vim-plug-test/vim-scripts/beauty256', g:plugs.beauty256.uri
   AssertEqual 'master', g:plugs.beauty256.branch
 
   AssertEqual 4, len(g:plugs)
@@ -84,7 +84,7 @@ Execute (PlugClean before installation):
 
 Execute (plug#end() updates &rtp):
   " Plug 'junegunn/goyo.vim', { 'tag': '1.5.3' }
-  " Plug 'file:///tmp/jg/vim-emoji'
+  " Plug 'file:///tmp/vim-plug-test/jg/vim-emoji'
   " Plug 'beauty256'
   " Plug 'junegunn/seoul256.vim', { 'branch': 'no-t_co', 'rtp': '././' }
   call plug#end()
@@ -159,7 +159,7 @@ Expect:
 Execute (Change branch of seoul256.vim):
   call plug#begin()
   Plug 'junegunn/seoul256.vim'
-  Plug 'file:///tmp/jg/vim-emoji'
+  Plug 'file:///tmp/vim-plug-test/jg/vim-emoji'
   call plug#end()
 
 Execute (PlugStatus):
@@ -197,15 +197,15 @@ Expect:
 Execute (Change URI of seoul256.vim):
   call plug#begin()
   Plug 'junegunn.choi/seoul256.vim'
-  Plug 'file:///tmp/jg/vim-emoji'
+  Plug 'file:///tmp/vim-plug-test/jg/vim-emoji'
   call plug#end()
 
 Execute (PlugStatus):
   call PlugStatusSorted()
 
 Expect:
-      Expected:    file:///tmp/junegunn.choi/seoul256.vim
-      Invalid URI: file:///tmp/junegunn/seoul256.vim
+      Expected:    file:///tmp/vim-plug-test/junegunn.choi/seoul256.vim
+      Invalid URI: file:///tmp/vim-plug-test/junegunn/seoul256.vim
       PlugClean required.
   - vim-emoji: OK
   Finished. 1 error(s).
@@ -215,7 +215,7 @@ Expect:
 Execute (Corrected the URI but diverged from master):
   call plug#begin()
   Plug 'junegunn/seoul256.vim'
-  Plug 'file:///tmp/jg/vim-emoji'
+  Plug 'file:///tmp/vim-plug-test/jg/vim-emoji'
   call plug#end()
   for _ in range(3)
     call system(printf('cd "%s" && git commit --allow-empty -m "dummy"', g:plugs['seoul256.vim'].dir))
@@ -257,8 +257,8 @@ Execute (PlugStatus):
   call PlugStatusSorted()
 
 Expect:
-      Expected:    file:///tmp/junegunn/vim-emoji
-      Invalid URI: file:///tmp/jg/vim-emoji
+      Expected:    file:///tmp/vim-plug-test/junegunn/vim-emoji
+      Invalid URI: file:///tmp/vim-plug-test/jg/vim-emoji
       Not found. Try PlugInstall.
       PlugClean required.
   Finished. 2 error(s).
@@ -300,7 +300,7 @@ Execute (PlugDiff - 'No updates.'):
 Execute (New commits on remote, PlugUpdate, then PlugDiff):
   for repo in ['seoul256.vim', 'vim-emoji']
     for _ in range(2)
-      call system(printf('cd /tmp/junegunn/%s && git commit --allow-empty -m "update"', repo))
+      call system(printf('cd /tmp/vim-plug-test/junegunn/%s && git commit --allow-empty -m "update"', repo))
     endfor
   endfor
   unlet repo
@@ -596,7 +596,7 @@ Execute (PlugStatus should point out that the plugin is missing):
 Execute (Deploy unmanaged plugin):
   Assert !exists(':FZF'), ':FZF command should not exist'
   call RmRf(fzf)
-  Log system(printf('cp -r "/tmp/fzf" "%s"', fzf))
+  Log system(printf('cp -r "/tmp/vim-plug-test/fzf" "%s"', fzf))
 
 Execute (PlugUpdate still should not care):
   PlugUpdate
@@ -769,7 +769,7 @@ Execute (On update):
   call plug#end()
 
   " New commits on remote
-  call system('cd /tmp/junegunn/vim-pseudocl && git commit --allow-empty -m "update"')
+  call system('cd /tmp/vim-plug-test/junegunn/vim-pseudocl && git commit --allow-empty -m "update"')
 
   silent PlugUpdate
   Log getline(1, '$')
@@ -861,7 +861,7 @@ Execute (Using Funcref):
   Plug 'junegunn/vim-pseudocl',   { 'do': function('PlugUpdated') }
   call plug#end()
 
-  call system('cd /tmp/junegunn/vim-easy-align && git commit --allow-empty -m "update"')
+  call system('cd /tmp/vim-plug-test/junegunn/vim-easy-align && git commit --allow-empty -m "update"')
   call system('cd '.g:plugs['vim-easy-align'].dir.' && git reset --hard HEAD^')
   call RmRf(g:plugs['vim-pseudocl'].dir)
 
@@ -921,8 +921,8 @@ Execute (Should not run when failed to update):
   call system(printf('cd %s && git remote set-url origin xxx', g:plugs['vim-easy-align'].dir))
 
   " New commits on remote
-  call system('cd /tmp/junegunn/vim-easy-align && git commit --allow-empty -m "update"')
-  call system('cd /tmp/junegunn/vim-pseudocl && git commit --allow-empty -m "update"')
+  call system('cd /tmp/vim-plug-test/junegunn/vim-easy-align && git commit --allow-empty -m "update"')
+  call system('cd /tmp/vim-plug-test/junegunn/vim-pseudocl && git commit --allow-empty -m "update"')
 
   silent PlugUpdate
   Log getline(1, '$')
@@ -940,11 +940,11 @@ Execute (Should not run when failed to update):
 Execute (Using custom dir):
   Assert isdirectory(g:plugs['vim-easy-align'].dir)
 
-  call RmRf('/tmp/easy-align')
+  call RmRf('/tmp/vim-plug-test/easy-align')
   call plug#begin()
-  Plug 'junegunn/vim-easy-align', { 'dir': '/tmp/easy-align' }
+  Plug 'junegunn/vim-easy-align', { 'dir': '/tmp/vim-plug-test/easy-align' }
   call plug#end()
-  AssertEqual '/tmp/easy-align/', g:plugs['vim-easy-align'].dir
+  AssertEqual '/tmp/vim-plug-test/easy-align/', g:plugs['vim-easy-align'].dir
 
   PlugClean!
   Assert !isdirectory(g:plugs['vim-easy-align'].dir)
@@ -1424,10 +1424,10 @@ Execute (#371 - 'as' option):
   Assert g:plugs.yogo.dir =~# '/yogo/$'
 
   call plug#begin()
-  Plug 'junegunn/goyo.vim', {'as': 'yogo', 'dir': '/tmp/gogo'}
+  Plug 'junegunn/goyo.vim', {'as': 'yogo', 'dir': '/tmp/vim-plug-test/gogo'}
   call plug#end()
   AssertEqual ['yogo'], sort(keys(g:plugs))
-  AssertEqual '/tmp/gogo/', g:plugs.yogo.dir
+  AssertEqual '/tmp/vim-plug-test/gogo/', g:plugs.yogo.dir
 
 Execute (#427 - Tag option with wildcard (requires git 1.9.2 or above)):
   if str2nr(split(split(system('git --version'))[-1], '\.')[0]) < 2