mirror of
https://github.com/junegunn/vim-plug.git
synced 2024-12-19 10:35:38 -07:00
90 lines
2.2 KiB
Plaintext
90 lines
2.2 KiB
Plaintext
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:base_rtp = &rtp
|
|
let g:first_rtp = split(&rtp, ',')[0]
|
|
let g:last_rtp = split(&rtp, ',')[-1]
|
|
let g:temp_plugged = tempname()
|
|
if !exists('$PLUG_SRC')
|
|
let $PLUG_SRC = globpath(&rtp, 'autoload/plug.vim')
|
|
endif
|
|
|
|
set t_Co=256
|
|
colo default
|
|
pclose
|
|
|
|
function! PlugStatusSorted()
|
|
PlugStatus
|
|
%y
|
|
q
|
|
normal! P
|
|
%sort
|
|
g/^$/d
|
|
endfunction
|
|
|
|
function! AssertExpect(bang, pat, cnt)
|
|
let op = a:bang ? '==#' : '=~#'
|
|
AssertEqual a:cnt, len(filter(getline(1, '$'), "v:val ".op." '".a:pat."'"))
|
|
endfunction
|
|
command! -nargs=+ -bang AssertExpect call AssertExpect('<bang>' == '!', <args>)
|
|
|
|
function! EnsureLoaded()
|
|
if has('vim_starting')
|
|
runtime! plugin/**/*.vim
|
|
endif
|
|
endfunction
|
|
|
|
function! RmRf(file)
|
|
call system(printf('rm -rf "%s"', a:file))
|
|
endfunction
|
|
|
|
" Reload vim-plug to reset s:-variables
|
|
function! ReloadPlug()
|
|
let tmpdir = tempname()
|
|
let tmp = tmpdir.'/plug.vim'
|
|
call mkdir(tmpdir, 'p')
|
|
try
|
|
call writefile(readfile($PLUG_SRC), tmp)
|
|
unlet! g:loaded_plug
|
|
execute 'source' tmp
|
|
let &rtp = g:base_rtp
|
|
finally
|
|
call RmRf(tmpdir)
|
|
endtry
|
|
endfunction
|
|
|
|
call ReloadPlug()
|
|
|
|
Execute (Print Interpreter Version):
|
|
redir => out
|
|
if has('ruby')
|
|
silent ruby puts 'Ruby: ' + RUBY_VERSION
|
|
elseif has('python')
|
|
silent python import sys; svi = sys.version_info; print 'Python: {}.{}.{}'.format(svi[0], svi[1], svi[2])
|
|
elseif has('python3')
|
|
silent python3 import sys; svi = sys.version_info; print('Python: {}.{}.{}'.format(svi[0], svi[1], svi[2]))
|
|
endif
|
|
redir END
|
|
Log substitute(out, '\n', '', 'g')
|
|
|
|
Include: workflow.vader
|
|
Include: regressions.vader
|
|
|
|
Execute (Cleanup):
|
|
silent! call RmRf(g:temp_plugged)
|
|
silent! unlet g:plugs g:plug_home g:plug_url_format
|
|
silent! unlet g:temp_plugged g:first_rtp g:last_rtp g:base_rtp out
|
|
silent! delf PlugStatusSorted
|
|
silent! delf AssertExpect
|
|
silent! delf PlugUpdated
|
|
silent! delf EnsureLoaded
|
|
silent! delf ReloadPlug
|
|
silent! delc AssertExpect
|
|
silent! unmap /
|
|
silent! unmap ?
|
|
|
|
Restore
|
|
|