2013-10-14 05:51:53 +02:00
|
|
|
Execute (Initialize test environment):
|
|
|
|
Save &rtp, g:plug_home, $MYVIMRC
|
2013-10-13 20:24:00 +02:00
|
|
|
|
|
|
|
let vader = fnamemodify(globpath(&rtp, 'autoload/vader.vim'), ':h:h')
|
|
|
|
let plug = fnamemodify(globpath(&rtp, 'autoload/plug.vim'), ':h:h')
|
|
|
|
set rtp=$HOME/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$HOME/.vim/after
|
|
|
|
execute 'set rtp^='.vader
|
|
|
|
execute 'set rtp^='.plug
|
|
|
|
let basertp = &rtp
|
|
|
|
|
2014-01-18 16:06:23 +01:00
|
|
|
unlet! g:plugs
|
|
|
|
unlet! g:plug_home
|
2013-10-13 20:24:00 +02:00
|
|
|
|
|
|
|
set t_Co=256
|
|
|
|
colo default
|
2014-04-14 14:20:21 +02:00
|
|
|
pclose
|
2013-10-13 20:24:00 +02:00
|
|
|
|
2014-06-23 05:22:25 +02:00
|
|
|
function! PlugStatusSorted()
|
|
|
|
PlugStatus
|
|
|
|
%y
|
|
|
|
q
|
|
|
|
normal! P
|
|
|
|
%sort
|
|
|
|
g/^$/d
|
|
|
|
endfunction
|
|
|
|
|
2013-10-13 20:24:00 +02:00
|
|
|
let g:vimrc_reloaded = 0
|
|
|
|
let vimrc = tempname()
|
|
|
|
call writefile(['let g:vimrc_reloaded += 1'], vimrc)
|
|
|
|
let $MYVIMRC = vimrc
|
|
|
|
|
2014-01-18 16:06:23 +01:00
|
|
|
Execute (plug#end() before plug#begin() should fail):
|
|
|
|
try
|
|
|
|
call plug#end()
|
|
|
|
Assert 0, 'should not reach here'
|
|
|
|
catch
|
|
|
|
Assert stridx(v:exception, 'Call plug#begin() first') >= 0
|
|
|
|
endtry
|
|
|
|
|
2013-10-14 05:51:53 +02:00
|
|
|
Execute (plug#begin() without path argument):
|
|
|
|
call plug#begin()
|
|
|
|
AssertEqual split(&rtp, ',')[0].'/plugged', g:plug_home
|
|
|
|
unlet g:plug_home
|
|
|
|
|
2014-01-18 16:06:23 +01:00
|
|
|
Execute (plug#begin() without path argument with empty &rtp):
|
|
|
|
let save_rtp = &rtp
|
|
|
|
set rtp=
|
|
|
|
try
|
|
|
|
call plug#begin()
|
|
|
|
Assert 0, 'should not reach here'
|
|
|
|
catch
|
|
|
|
Assert stridx(v:exception, 'Unable to determine plug home') >= 0, 'Got: '.v:exception
|
|
|
|
endtry
|
|
|
|
let &rtp = save_rtp
|
|
|
|
|
2013-10-14 05:51:53 +02:00
|
|
|
Execute (plug#begin(path)):
|
2013-10-13 20:24:00 +02:00
|
|
|
let temp_plugged = tempname()
|
2013-10-14 05:51:53 +02:00
|
|
|
call plug#begin(temp_plugged.'/')
|
|
|
|
Assert g:plug_home !~ '[/\\]$', 'Trailing / should be stripped from g:plug_home'
|
2013-10-13 20:24:00 +02:00
|
|
|
|
|
|
|
AssertEqual 0, len(g:plugs)
|
|
|
|
AssertEqual temp_plugged, g:plug_home
|
|
|
|
AssertEqual basertp, &rtp
|
|
|
|
|
2013-10-14 05:51:53 +02:00
|
|
|
Execute (Subsequent plug#begin() calls will reuse g:plug_home):
|
|
|
|
call plug#begin()
|
|
|
|
AssertEqual temp_plugged, g:plug_home
|
|
|
|
|
|
|
|
Execute (Test Plug command):
|
2013-10-13 20:24:00 +02:00
|
|
|
" Git repo with branch
|
|
|
|
Plug 'junegunn/seoul256.vim', 'no-t_co'
|
|
|
|
AssertEqual 'https://git:@github.com/junegunn/seoul256.vim.git', g:plugs['seoul256.vim'].uri
|
|
|
|
AssertEqual join([temp_plugged, 'seoul256.vim/'], '/'), g:plugs['seoul256.vim'].dir
|
|
|
|
AssertEqual 'no-t_co', g:plugs['seoul256.vim'].branch
|
|
|
|
|
2014-06-23 05:22:25 +02:00
|
|
|
" Git repo with tag
|
|
|
|
Plug 'junegunn/goyo.vim', '1.5.3'
|
|
|
|
AssertEqual 'https://git:@github.com/junegunn/goyo.vim.git', g:plugs['goyo.vim'].uri
|
|
|
|
AssertEqual join([temp_plugged, 'goyo.vim/'], '/'), g:plugs['goyo.vim'].dir
|
|
|
|
AssertEqual '1.5.3', g:plugs['goyo.vim'].branch
|
|
|
|
|
2013-10-13 20:24:00 +02:00
|
|
|
" Git URI
|
|
|
|
Plug 'git@github.com:junegunn/vim-emoji.git'
|
|
|
|
AssertEqual 'git@github.com:junegunn/vim-emoji.git', g:plugs['vim-emoji'].uri
|
|
|
|
AssertEqual 'master', g:plugs['vim-emoji'].branch
|
|
|
|
AssertEqual join([temp_plugged, 'vim-emoji/'], '/'), g:plugs['vim-emoji'].dir
|
|
|
|
|
|
|
|
" vim-scripts/
|
|
|
|
Plug 'beauty256'
|
|
|
|
AssertEqual 'https://git:@github.com/vim-scripts/beauty256.git', g:plugs.beauty256.uri
|
|
|
|
AssertEqual 'master', g:plugs.beauty256.branch
|
|
|
|
|
2014-06-23 05:22:25 +02:00
|
|
|
AssertEqual 4, len(g:plugs)
|
2013-10-13 20:24:00 +02:00
|
|
|
|
|
|
|
Execute (Plug command with dictionary option):
|
2014-06-23 05:22:25 +02:00
|
|
|
Log string(g:plugs)
|
2013-10-13 20:24:00 +02:00
|
|
|
Plug 'junegunn/seoul256.vim', { 'branch': 'no-t_co', 'rtp': '././' }
|
|
|
|
AssertEqual join([temp_plugged, 'seoul256.vim/'], '/'), g:plugs['seoul256.vim'].dir
|
|
|
|
AssertEqual '././', g:plugs['seoul256.vim'].rtp
|
|
|
|
|
2014-06-23 05:22:25 +02:00
|
|
|
Log string(g:plugs)
|
|
|
|
AssertEqual 4, len(g:plugs)
|
2013-10-13 20:24:00 +02:00
|
|
|
|
|
|
|
Execute (PlugStatus before installation):
|
|
|
|
PlugStatus
|
2014-06-23 05:22:25 +02:00
|
|
|
AssertEqual 4, len(filter(getline(1, line('$')), 'v:val =~ "Not found"'))
|
2013-10-13 20:24:00 +02:00
|
|
|
q
|
|
|
|
|
|
|
|
Execute (PlugClean before installation):
|
|
|
|
PlugClean
|
|
|
|
AssertEqual 1, len(filter(getline(1, line('$')), 'v:val =~ "Already clean"'))
|
|
|
|
q
|
|
|
|
|
|
|
|
Execute (plug#end() updates &rtp):
|
|
|
|
call plug#end()
|
|
|
|
Assert len(&rtp) > len(basertp)
|
|
|
|
|
|
|
|
Execute (Yet, plugins are not available):
|
|
|
|
Assert empty(globpath(&rtp, 'autoload/emoji.vim'))
|
|
|
|
|
|
|
|
Execute (PlugInstall):
|
|
|
|
PlugInstall
|
|
|
|
AssertEqual 1, g:vimrc_reloaded
|
|
|
|
q
|
|
|
|
|
|
|
|
Execute (Plugin available after installation):
|
|
|
|
Assert !empty(globpath(&rtp, 'autoload/emoji.vim'))
|
|
|
|
|
|
|
|
Execute (PlugClean after installation):
|
|
|
|
PlugClean
|
|
|
|
AssertEqual 1, len(filter(getline(1, line('$')), 'v:val =~ "Already clean"'))
|
|
|
|
q
|
|
|
|
|
|
|
|
Execute (PlugStatus after installation):
|
|
|
|
PlugStatus
|
2014-06-23 05:22:25 +02:00
|
|
|
AssertEqual 4, len(filter(getline(1, line('$')), 'v:val =~ "OK"'))
|
2013-10-13 20:24:00 +02:00
|
|
|
q
|
|
|
|
|
2014-06-23 05:22:25 +02:00
|
|
|
Execute (Change tag of goyo.vim):
|
|
|
|
call plug#begin()
|
|
|
|
Plug 'junegunn/goyo.vim'
|
|
|
|
call plug#end()
|
|
|
|
|
|
|
|
Execute (PlugStatus):
|
|
|
|
call PlugStatusSorted()
|
|
|
|
|
|
|
|
Expect:
|
|
|
|
Invalid branch/tag: 1.5.3 (expected: master). Try PlugUpdate.
|
|
|
|
Finished. 1 error(s).
|
|
|
|
[=]
|
|
|
|
x goyo.vim:
|
|
|
|
|
|
|
|
Execute (PlugUpdate to set the right branch):
|
|
|
|
PlugUpdate
|
|
|
|
call PlugStatusSorted()
|
|
|
|
AssertEqual 2, g:vimrc_reloaded
|
|
|
|
|
|
|
|
Expect:
|
|
|
|
- goyo.vim: OK
|
|
|
|
Finished. 0 error(s).
|
|
|
|
[=]
|
|
|
|
|
2013-10-13 20:24:00 +02:00
|
|
|
Execute (Change branch of seoul256.vim):
|
|
|
|
call plug#begin()
|
|
|
|
Plug 'junegunn/seoul256.vim'
|
|
|
|
Plug 'git@github.com:junegunn/vim-emoji.git'
|
|
|
|
call plug#end()
|
|
|
|
|
|
|
|
Execute (PlugStatus):
|
2014-06-23 05:22:25 +02:00
|
|
|
call PlugStatusSorted()
|
2013-10-13 20:24:00 +02:00
|
|
|
|
|
|
|
Expect:
|
2014-06-23 05:22:25 +02:00
|
|
|
Invalid branch/tag: no-t_co (expected: master). Try PlugUpdate.
|
2013-10-13 20:24:00 +02:00
|
|
|
- vim-emoji: OK
|
|
|
|
Finished. 1 error(s).
|
2014-04-08 14:47:57 +02:00
|
|
|
[==]
|
2014-01-06 05:04:38 +01:00
|
|
|
x seoul256.vim:
|
|
|
|
|
|
|
|
Execute (Change URI of seoul256.vim):
|
|
|
|
call plug#begin()
|
|
|
|
Plug 'junegunn.choi/seoul256.vim'
|
|
|
|
Plug 'git@github.com:junegunn/vim-emoji.git'
|
|
|
|
call plug#end()
|
|
|
|
|
|
|
|
Execute (PlugStatus):
|
2014-06-23 05:22:25 +02:00
|
|
|
call PlugStatusSorted()
|
2014-01-06 05:04:38 +01:00
|
|
|
|
|
|
|
Expect:
|
|
|
|
Expected: https://git:@github.com/junegunn.choi/seoul256.vim.git
|
|
|
|
Invalid URI: https://git:@github.com/junegunn/seoul256.vim.git
|
|
|
|
PlugClean required.
|
|
|
|
- vim-emoji: OK
|
|
|
|
Finished. 1 error(s).
|
2014-04-08 14:47:57 +02:00
|
|
|
[==]
|
2014-01-06 05:04:38 +01:00
|
|
|
x seoul256.vim:
|
2013-10-13 20:24:00 +02:00
|
|
|
|
|
|
|
# TODO: does not work due to inputsave()
|
|
|
|
# Do (PlugClean):
|
|
|
|
# :PlugClean\<Enter>y\<Enter>
|
|
|
|
# ggyG
|
|
|
|
# q
|
|
|
|
# PGdd
|
|
|
|
|
|
|
|
Execute (PlugClean! to remove seoul256.vim):
|
|
|
|
PlugClean!
|
2014-06-23 05:22:25 +02:00
|
|
|
" Three removed, emoji left
|
|
|
|
AssertEqual 3, len(filter(getline(1, line('$')), 'v:val =~ "^- "'))
|
2013-10-13 20:24:00 +02:00
|
|
|
AssertEqual 1, len(filter(getline(1, line('$')), 'v:val =~ "Removed"'))
|
2013-10-14 05:51:53 +02:00
|
|
|
Assert empty(globpath(&rtp, 'colors/seoul256.vim'))
|
|
|
|
Assert !empty(globpath(&rtp, 'autoload/emoji.vim'))
|
2013-10-13 20:24:00 +02:00
|
|
|
q
|
|
|
|
|
|
|
|
Execute (Change GIT URI of vim-emoji):
|
|
|
|
call plug#begin()
|
|
|
|
Plug 'junegunn/seoul256.vim'
|
|
|
|
Plug 'junegunn/vim-emoji'
|
|
|
|
call plug#end()
|
|
|
|
|
|
|
|
Execute (PlugStatus):
|
2014-06-23 05:22:25 +02:00
|
|
|
call PlugStatusSorted()
|
2013-10-13 20:24:00 +02:00
|
|
|
|
|
|
|
Expect:
|
2014-01-06 05:04:38 +01:00
|
|
|
Expected: https://git:@github.com/junegunn/vim-emoji.git
|
|
|
|
Invalid URI: git@github.com:junegunn/vim-emoji.git
|
|
|
|
Not found. Try PlugInstall.
|
|
|
|
PlugClean required.
|
2013-10-13 20:24:00 +02:00
|
|
|
Finished. 2 error(s).
|
2014-04-08 14:47:57 +02:00
|
|
|
[==]
|
2014-01-06 05:04:38 +01:00
|
|
|
x seoul256.vim:
|
|
|
|
x vim-emoji:
|
2013-10-13 20:24:00 +02:00
|
|
|
|
|
|
|
Execute (PlugClean! to remove vim-emoji):
|
|
|
|
PlugClean!
|
2014-06-23 05:22:25 +02:00
|
|
|
AssertEqual 1, len(filter(getline(1, line('$')), 'v:val =~ "^- "'))
|
2013-10-13 20:24:00 +02:00
|
|
|
AssertEqual 1, len(filter(getline(1, line('$')), 'v:val =~ "Removed"'))
|
2013-10-14 05:51:53 +02:00
|
|
|
Assert empty(globpath(&rtp, 'colors/seoul256.vim'))
|
|
|
|
Assert empty(globpath(&rtp, 'autoload/emoji.vim'))
|
2013-10-13 20:24:00 +02:00
|
|
|
q
|
|
|
|
|
|
|
|
Execute (PlugUpdate to install both again):
|
|
|
|
PlugUpdate
|
|
|
|
AssertEqual 2, len(filter(getline(1, line('$')), 'v:val =~ "Cloning into"'))
|
2014-06-23 05:22:25 +02:00
|
|
|
AssertEqual 3, g:vimrc_reloaded
|
2013-10-14 05:51:53 +02:00
|
|
|
Assert !empty(globpath(&rtp, 'colors/seoul256.vim')), 'seoul256.vim should be found'
|
|
|
|
Assert !empty(globpath(&rtp, 'autoload/emoji.vim')), 'vim-emoji should be found'
|
2013-10-13 20:24:00 +02:00
|
|
|
q
|
|
|
|
|
2014-04-14 14:20:21 +02:00
|
|
|
Execute (PlugUpdate only to find out plugins are up-to-date, D key to check):
|
2013-10-13 20:24:00 +02:00
|
|
|
PlugUpdate
|
|
|
|
AssertEqual 2, len(filter(getline(1, line('$')), 'v:val =~ "Already up-to-date"'))
|
2014-06-23 05:22:25 +02:00
|
|
|
AssertEqual 4, g:vimrc_reloaded
|
2014-04-14 14:20:21 +02:00
|
|
|
normal D
|
|
|
|
AssertEqual 'No updates.', getline(1)
|
|
|
|
q
|
|
|
|
|
|
|
|
Execute (PlugDiff - 'No updates.'):
|
|
|
|
PlugDiff
|
|
|
|
AssertEqual 'No updates.', getline(1)
|
|
|
|
q
|
|
|
|
|
|
|
|
Execute (Rollback recent updates, PlugUpdate, then PlugDiff):
|
|
|
|
for repo in ['seoul256.vim', 'vim-emoji']
|
|
|
|
call system(printf('cd %s/%s && git reset HEAD^^ --hard', g:plug_home, repo))
|
|
|
|
endfor
|
|
|
|
PlugUpdate
|
|
|
|
|
|
|
|
" Now we have updates
|
|
|
|
normal D
|
|
|
|
AssertEqual 'Last update:', getline(1)
|
|
|
|
|
|
|
|
" Preview commit
|
|
|
|
silent! wincmd P
|
|
|
|
AssertEqual 0, &previewwindow
|
|
|
|
|
|
|
|
" ]] motion
|
|
|
|
execute 'normal ]]'
|
|
|
|
let lnum = line('.')
|
|
|
|
AssertEqual 3, col('.')
|
|
|
|
|
|
|
|
" Open commit preview
|
|
|
|
execute "normal j\<cr>"
|
|
|
|
wincmd P
|
|
|
|
AssertEqual 1, &previewwindow
|
|
|
|
AssertEqual 'git', &filetype
|
|
|
|
|
|
|
|
" Back to plug window
|
|
|
|
wincmd p
|
|
|
|
|
|
|
|
" ]] motion
|
|
|
|
execute 'normal $]]'
|
|
|
|
AssertEqual lnum + 4, line('.')
|
|
|
|
AssertEqual 3, col('.')
|
|
|
|
|
|
|
|
" [[ motion
|
|
|
|
execute 'normal 0[['
|
|
|
|
AssertEqual lnum, line('.')
|
|
|
|
AssertEqual 3, col('.')
|
|
|
|
|
|
|
|
" q will close preview window as well
|
|
|
|
normal q
|
|
|
|
|
|
|
|
" We no longer have preview window
|
|
|
|
silent! wincmd P
|
|
|
|
AssertEqual 0, &previewwindow
|
|
|
|
|
|
|
|
" q should not close preview window if it's already open
|
|
|
|
pedit
|
|
|
|
PlugDiff
|
|
|
|
execute "normal ]]j\<cr>"
|
|
|
|
normal q
|
|
|
|
|
|
|
|
silent! wincmd P
|
|
|
|
AssertEqual 1, &previewwindow
|
|
|
|
pclose
|
|
|
|
|
|
|
|
Execute (Plug window in a new tab):
|
|
|
|
PlugDiff
|
|
|
|
tab new new-tab
|
|
|
|
set buftype=nofile
|
|
|
|
PlugUpdate
|
|
|
|
normal D
|
|
|
|
AssertEqual 'No updates.', getline(1)
|
|
|
|
q
|
|
|
|
AssertEqual 'new-tab', expand('%')
|
|
|
|
q
|
2013-10-13 20:24:00 +02:00
|
|
|
q
|
|
|
|
|
2014-06-20 13:53:57 +02:00
|
|
|
**********************************************************************
|
|
|
|
~ On-demand loading / Partial installation/update ~
|
|
|
|
**********************************************************************
|
|
|
|
|
|
|
|
Execute (Trying to execute on-demand commands when plugin is not installed):
|
|
|
|
call plug#begin()
|
|
|
|
Plug 'junegunn/vim-easy-align', { 'on': ['EasyAlign', 'LiveEasyAlign'] }
|
|
|
|
call plug#end()
|
|
|
|
|
|
|
|
Assert exists(':EasyAlign')
|
|
|
|
Assert exists(':LiveEasyAlign')
|
|
|
|
AssertThrows EasyAlign
|
|
|
|
AssertThrows LiveEasyAlign
|
|
|
|
Assert !exists(':EasyAlign')
|
|
|
|
Assert !exists(':LiveEasyAlign')
|
|
|
|
|
|
|
|
Execute (New set of plugins):
|
|
|
|
call plug#begin()
|
|
|
|
Plug 'junegunn/vim-fnr' " Depends on vim-pseudocl
|
|
|
|
Plug 'junegunn/vim-easy-align', { 'on': 'EasyAlign' }
|
|
|
|
Plug 'junegunn/vim-redis', { 'for': 'redis' }
|
|
|
|
call plug#end()
|
|
|
|
|
|
|
|
Execute (Check commands):
|
|
|
|
Assert !exists(':FNR'), 'FNR command should not be found'
|
|
|
|
Assert !exists(':RedisExecute'), 'RedisExecute command should not be found'
|
|
|
|
|
|
|
|
Execute (Partial PlugInstall):
|
|
|
|
PlugInstall vim-fnr vim-easy-align
|
|
|
|
PlugInstall vim-fnr vim-easy-align 1
|
|
|
|
q
|
|
|
|
|
2014-06-22 14:49:51 +02:00
|
|
|
Execute (Check dependent plugin):
|
2014-06-20 14:27:46 +02:00
|
|
|
Assert &rtp =~ 'pseudocl', &rtp
|
|
|
|
|
2014-06-20 13:53:57 +02:00
|
|
|
Given (Unaligned code):
|
|
|
|
a=1
|
|
|
|
aa=2
|
|
|
|
|
|
|
|
Execute (Check installed plugins):
|
|
|
|
Assert exists(':FNR'), 'FNR command should be found'
|
|
|
|
Assert exists(':EasyAlign'), 'EasyAlign command should be found'
|
|
|
|
Assert !exists(':RedisExecute'), 'RedisExecute command still should not be found'
|
|
|
|
%EasyAlign=
|
|
|
|
|
|
|
|
Expect (Aligned code):
|
|
|
|
a = 1
|
|
|
|
aa = 2
|
|
|
|
|
|
|
|
Given (nothing):
|
|
|
|
Execute (Partial PlugUpdate):
|
|
|
|
PlugUpdate vim-redis
|
|
|
|
q
|
|
|
|
|
|
|
|
Execute (On-demand loading based on filetypes):
|
|
|
|
Assert !exists(':RedisExecute'), 'RedisExecute command still should not be found'
|
|
|
|
set ft=redis
|
|
|
|
Assert exists(':RedisExecute'), 'RedisExecute command is now found'
|
|
|
|
|
2013-10-14 05:51:53 +02:00
|
|
|
Execute (Cleanup):
|
2013-10-13 20:24:00 +02:00
|
|
|
call system('rm -rf '.temp_plugged)
|
|
|
|
|
|
|
|
unlet g:plugs
|
|
|
|
unlet g:plug_home
|
|
|
|
unlet g:vimrc_reloaded
|
2014-04-14 14:20:21 +02:00
|
|
|
unlet temp_plugged vader plug basertp save_rtp repo lnum
|
2014-06-23 05:22:25 +02:00
|
|
|
delf PlugStatusSorted
|
2013-10-13 20:24:00 +02:00
|
|
|
|
|
|
|
Restore
|
|
|
|
source $MYVIMRC
|