'R' to retry failed update/installation tasks
This commit is contained in:
parent
0d7e20c984
commit
74fa6ab9df
2 changed files with 96 additions and 24 deletions
27
plug.vim
27
plug.vim
|
@ -403,6 +403,7 @@ function! s:prepare()
|
||||||
else
|
else
|
||||||
vertical topleft new
|
vertical topleft new
|
||||||
nnoremap <silent> <buffer> q :if b:plug_preview==1<bar>pc<bar>endif<bar>q<cr>
|
nnoremap <silent> <buffer> q :if b:plug_preview==1<bar>pc<bar>endif<bar>q<cr>
|
||||||
|
nnoremap <silent> <buffer> R :silent! call <SID>retry()<cr>
|
||||||
nnoremap <silent> <buffer> D :PlugDiff<cr>
|
nnoremap <silent> <buffer> D :PlugDiff<cr>
|
||||||
nnoremap <silent> <buffer> S :PlugStatus<cr>
|
nnoremap <silent> <buffer> S :PlugStatus<cr>
|
||||||
nnoremap <silent> <buffer> ]] :silent! call <SID>section('')<cr>
|
nnoremap <silent> <buffer> ]] :silent! call <SID>section('')<cr>
|
||||||
|
@ -437,9 +438,22 @@ function! s:finish(pull)
|
||||||
call setline(4, getline(4) . 'Done!')
|
call setline(4, getline(4) . 'Done!')
|
||||||
normal! gg
|
normal! gg
|
||||||
redraw
|
redraw
|
||||||
if a:pull
|
let msgs = []
|
||||||
echo "Press 'D' to see the updated changes."
|
if !empty(s:prev_update.errors)
|
||||||
|
call add(msgs, "Press 'R' to retry.")
|
||||||
endif
|
endif
|
||||||
|
if a:pull
|
||||||
|
call add(msgs, "Press 'D' to see the updated changes.")
|
||||||
|
endif
|
||||||
|
echo join(msgs, ' ')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:retry()
|
||||||
|
if empty(s:prev_update.errors)
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
call s:update_impl(s:prev_update.pull,
|
||||||
|
\ extend(copy(s:prev_update.errors), [s:prev_update.threads]))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:is_managed(name)
|
function! s:is_managed(name)
|
||||||
|
@ -473,6 +487,7 @@ function! s:update_impl(pull, args) abort
|
||||||
redraw
|
redraw
|
||||||
|
|
||||||
let len = len(g:plugs)
|
let len = len(g:plugs)
|
||||||
|
let s:prev_update = { 'errors': [], 'pull': a:pull, 'threads': threads }
|
||||||
if has('ruby') && threads > 1
|
if has('ruby') && threads > 1
|
||||||
try
|
try
|
||||||
let imd = &imd
|
let imd = &imd
|
||||||
|
@ -566,6 +581,9 @@ function! s:update_serial(pull, todo)
|
||||||
let error = v:shell_error != 0
|
let error = v:shell_error != 0
|
||||||
endif
|
endif
|
||||||
let bar .= error ? 'x' : '='
|
let bar .= error ? 'x' : '='
|
||||||
|
if error
|
||||||
|
call add(s:prev_update.errors, name)
|
||||||
|
endif
|
||||||
call append(3, s:format_message(!error, name, result))
|
call append(3, s:format_message(!error, name, result))
|
||||||
call s:update_progress(a:pull, len(done), bar, total)
|
call s:update_progress(a:pull, len(done), bar, total)
|
||||||
endfor
|
endfor
|
||||||
|
@ -640,7 +658,10 @@ function! s:update_parallel(pull, todo, threads)
|
||||||
bar += type ? '=' : 'x' unless ing
|
bar += type ? '=' : 'x' unless ing
|
||||||
b = case type
|
b = case type
|
||||||
when :install then '+' when :update then '*'
|
when :install then '+' when :update then '*'
|
||||||
when true, nil then '-' else 'x' end
|
when true, nil then '-' else
|
||||||
|
VIM::command("call add(s:prev_update.errors, '#{name}')")
|
||||||
|
'x'
|
||||||
|
end
|
||||||
result =
|
result =
|
||||||
if type || type.nil?
|
if type || type.nil?
|
||||||
["#{b} #{name}: #{result.lines.to_a.last}"]
|
["#{b} #{name}: #{result.lines.to_a.last}"]
|
||||||
|
|
|
@ -27,6 +27,12 @@ Execute (Initialize test environment):
|
||||||
g/^$/d
|
g/^$/d
|
||||||
endfunction
|
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>)
|
||||||
|
|
||||||
let g:vimrc_reloaded = 0
|
let g:vimrc_reloaded = 0
|
||||||
let vimrc = tempname()
|
let vimrc = tempname()
|
||||||
call writefile(['let g:vimrc_reloaded += 1'], vimrc)
|
call writefile(['let g:vimrc_reloaded += 1'], vimrc)
|
||||||
|
@ -112,12 +118,12 @@ Execute (Plug command with dictionary option):
|
||||||
|
|
||||||
Execute (PlugStatus before installation):
|
Execute (PlugStatus before installation):
|
||||||
PlugStatus
|
PlugStatus
|
||||||
AssertEqual 4, len(filter(getline(1, '$'), 'v:val =~ "Not found"'))
|
AssertExpect 'Not found', 4
|
||||||
q
|
q
|
||||||
|
|
||||||
Execute (PlugClean before installation):
|
Execute (PlugClean before installation):
|
||||||
PlugClean
|
PlugClean
|
||||||
AssertEqual 1, len(filter(getline(1, '$'), 'v:val =~ "Already clean"'))
|
AssertExpect 'Already clean', 1
|
||||||
q
|
q
|
||||||
|
|
||||||
Execute (plug#end() updates &rtp):
|
Execute (plug#end() updates &rtp):
|
||||||
|
@ -139,12 +145,13 @@ Execute (Plugin available after installation):
|
||||||
|
|
||||||
Execute (PlugClean after installation):
|
Execute (PlugClean after installation):
|
||||||
PlugClean
|
PlugClean
|
||||||
AssertEqual 1, len(filter(getline(1, '$'), 'v:val =~ "Already clean"'))
|
AssertExpect 'Already clean', 1
|
||||||
q
|
q
|
||||||
|
|
||||||
Execute (PlugStatus after installation):
|
Execute (PlugStatus after installation):
|
||||||
PlugStatus
|
PlugStatus
|
||||||
AssertEqual 4, len(filter(getline(1, '$'), 'v:val =~ "OK"'))
|
Log getline(1, '$')
|
||||||
|
AssertExpect 'OK', 4
|
||||||
q
|
q
|
||||||
|
|
||||||
Execute (Change tag of goyo.vim):
|
Execute (Change tag of goyo.vim):
|
||||||
|
@ -215,8 +222,8 @@ Expect:
|
||||||
Execute (PlugClean! to remove seoul256.vim):
|
Execute (PlugClean! to remove seoul256.vim):
|
||||||
PlugClean!
|
PlugClean!
|
||||||
" Three removed, emoji left
|
" Three removed, emoji left
|
||||||
AssertEqual 3, len(filter(getline(1, '$'), 'v:val =~ "^- "'))
|
AssertExpect '^- ', 3
|
||||||
AssertEqual 1, len(filter(getline(1, '$'), 'v:val =~ "Removed"'))
|
AssertExpect 'Removed', 1
|
||||||
Assert empty(globpath(&rtp, 'colors/seoul256.vim'))
|
Assert empty(globpath(&rtp, 'colors/seoul256.vim'))
|
||||||
Assert !empty(globpath(&rtp, 'autoload/emoji.vim'))
|
Assert !empty(globpath(&rtp, 'autoload/emoji.vim'))
|
||||||
q
|
q
|
||||||
|
@ -242,15 +249,15 @@ Expect:
|
||||||
|
|
||||||
Execute (PlugClean! to remove vim-emoji):
|
Execute (PlugClean! to remove vim-emoji):
|
||||||
PlugClean!
|
PlugClean!
|
||||||
AssertEqual 1, len(filter(getline(1, '$'), 'v:val =~ "^- "'))
|
AssertExpect '^- ', 1
|
||||||
AssertEqual 1, len(filter(getline(1, '$'), 'v:val =~ "Removed"'))
|
AssertExpect 'Removed', 1
|
||||||
Assert empty(globpath(&rtp, 'colors/seoul256.vim'))
|
Assert empty(globpath(&rtp, 'colors/seoul256.vim'))
|
||||||
Assert empty(globpath(&rtp, 'autoload/emoji.vim'))
|
Assert empty(globpath(&rtp, 'autoload/emoji.vim'))
|
||||||
q
|
q
|
||||||
|
|
||||||
Execute (PlugUpdate to install both again):
|
Execute (PlugUpdate to install both again):
|
||||||
PlugUpdate
|
PlugUpdate
|
||||||
AssertEqual 2, len(filter(getline(1, '$'), 'v:val =~ "^- [^:]*:"'))
|
AssertExpect '^- [^:]*:', 2
|
||||||
AssertEqual 3, g:vimrc_reloaded
|
AssertEqual 3, g:vimrc_reloaded
|
||||||
Assert !empty(globpath(&rtp, 'colors/seoul256.vim')), 'seoul256.vim should be found'
|
Assert !empty(globpath(&rtp, 'colors/seoul256.vim')), 'seoul256.vim should be found'
|
||||||
Assert !empty(globpath(&rtp, 'autoload/emoji.vim')), 'vim-emoji should be found'
|
Assert !empty(globpath(&rtp, 'autoload/emoji.vim')), 'vim-emoji should be found'
|
||||||
|
@ -258,7 +265,7 @@ Execute (PlugUpdate to install both again):
|
||||||
|
|
||||||
Execute (PlugUpdate only to find out plugins are up-to-date, D key to check):
|
Execute (PlugUpdate only to find out plugins are up-to-date, D key to check):
|
||||||
PlugUpdate
|
PlugUpdate
|
||||||
AssertEqual 2, len(filter(getline(1, '$'), 'v:val =~ "Already up-to-date"'))
|
AssertExpect 'Already up-to-date', 2
|
||||||
AssertEqual 4, g:vimrc_reloaded
|
AssertEqual 4, g:vimrc_reloaded
|
||||||
normal D
|
normal D
|
||||||
AssertEqual 'No updates.', getline(1)
|
AssertEqual 'No updates.', getline(1)
|
||||||
|
@ -365,9 +372,9 @@ Execute (Check commands):
|
||||||
|
|
||||||
Execute (Partial PlugInstall):
|
Execute (Partial PlugInstall):
|
||||||
PlugInstall vim-fnr vim-easy-align
|
PlugInstall vim-fnr vim-easy-align
|
||||||
AssertEqual 1, len(filter(getline(1, '$'), 'v:val =~ "vim-pseudocl"'))
|
AssertExpect 'vim-pseudocl', 1
|
||||||
PlugInstall vim-fnr vim-easy-align 1
|
PlugInstall vim-fnr vim-easy-align 1
|
||||||
AssertEqual 1, len(filter(getline(1, '$'), 'v:val =~ "vim-pseudocl"'))
|
AssertExpect 'vim-pseudocl', 1
|
||||||
q
|
q
|
||||||
|
|
||||||
Execute (Check dependent plugin):
|
Execute (Check dependent plugin):
|
||||||
|
@ -438,26 +445,26 @@ Execute (Plug block for following tests):
|
||||||
Execute (PlugInstall will only install vim-easy-align):
|
Execute (PlugInstall will only install vim-easy-align):
|
||||||
PlugInstall
|
PlugInstall
|
||||||
Log getline(1, '$')
|
Log getline(1, '$')
|
||||||
AssertEqual 0, len(filter(getline(1, '$'), 'v:val =~ "fzf"'))
|
AssertExpect 'fzf', 0
|
||||||
q
|
q
|
||||||
|
|
||||||
Execute (PlugUpdate will only update vim-easy-align):
|
Execute (PlugUpdate will only update vim-easy-align):
|
||||||
PlugUpdate
|
PlugUpdate
|
||||||
Log getline(1, '$')
|
Log getline(1, '$')
|
||||||
AssertEqual 0, len(filter(getline(1, '$'), 'v:val =~ "fzf"'))
|
AssertExpect 'fzf', 0
|
||||||
q
|
q
|
||||||
|
|
||||||
Execute (PlugClean should not care about unmanaged plugins):
|
Execute (PlugClean should not care about unmanaged plugins):
|
||||||
PlugClean
|
PlugClean
|
||||||
Log getline(1, '$')
|
Log getline(1, '$')
|
||||||
AssertEqual 0, len(filter(getline(1, '$'), 'v:val =~ "fzf"'))
|
AssertExpect 'fzf', 0
|
||||||
q
|
q
|
||||||
|
|
||||||
Execute (PlugStatus should point out that the plugin is missing):
|
Execute (PlugStatus should point out that the plugin is missing):
|
||||||
PlugStatus
|
PlugStatus
|
||||||
Log getline(1, '$')
|
Log getline(1, '$')
|
||||||
AssertEqual 1, len(filter(getline(1, '$'), 'v:val =~ "x fzf"'))
|
AssertExpect 'x fzf', 1
|
||||||
AssertEqual 1, len(filter(getline(1, '$'), 'v:val =~ "Not found"'))
|
AssertExpect 'Not found', 1
|
||||||
q
|
q
|
||||||
|
|
||||||
Execute (Deploy unmanaged plugin):
|
Execute (Deploy unmanaged plugin):
|
||||||
|
@ -467,14 +474,14 @@ Execute (Deploy unmanaged plugin):
|
||||||
Execute (PlugUpdate still should not care):
|
Execute (PlugUpdate still should not care):
|
||||||
PlugUpdate
|
PlugUpdate
|
||||||
Log getline(1, '$')
|
Log getline(1, '$')
|
||||||
AssertEqual 0, len(filter(getline(1, '$'), 'v:val =~ "fzf"'))
|
AssertExpect 'fzf', 0
|
||||||
q
|
q
|
||||||
|
|
||||||
Execute (PlugStatus with no error):
|
Execute (PlugStatus with no error):
|
||||||
PlugStatus
|
PlugStatus
|
||||||
Log getline(1, '$')
|
Log getline(1, '$')
|
||||||
AssertEqual 0, len(filter(getline(1, '$'), 'v:val =~ "x fzf"'))
|
AssertExpect 'x fzf', 0
|
||||||
AssertEqual 0, len(filter(getline(1, '$'), 'v:val =~ "Not found"'))
|
AssertExpect 'Not found', 0
|
||||||
q
|
q
|
||||||
|
|
||||||
Execute (Check &rtp after SomeCommand):
|
Execute (Check &rtp after SomeCommand):
|
||||||
|
@ -494,7 +501,7 @@ Execute (Common parent):
|
||||||
|
|
||||||
PlugInstall
|
PlugInstall
|
||||||
Log getline(1, '$')
|
Log getline(1, '$')
|
||||||
AssertEqual 1, len(filter(getline(1, '$'), 'v:val == "[===]"'))
|
AssertExpect! '[===]', 1
|
||||||
q
|
q
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
|
@ -527,6 +534,48 @@ Execute (But you can still install it if the name is given as the argument):
|
||||||
AssertEqual 1, len(filter(getline(1, '$'), 'v:val =~ "vim-easy-align"'))
|
AssertEqual 1, len(filter(getline(1, '$'), 'v:val =~ "vim-easy-align"'))
|
||||||
q
|
q
|
||||||
|
|
||||||
|
**********************************************************************
|
||||||
|
~ Retry
|
||||||
|
**********************************************************************
|
||||||
|
|
||||||
|
Execute (Retry failed tasks):
|
||||||
|
call plug#begin()
|
||||||
|
Plug 'junegunn/vim-easy-align'
|
||||||
|
Plug 'junegunn/aaaaaaaaaaaaaa'
|
||||||
|
call plug#end()
|
||||||
|
|
||||||
|
PlugInstall
|
||||||
|
Log getline(1, '$')
|
||||||
|
AssertExpect 'x aaa', 1
|
||||||
|
AssertExpect '- vim-easy-align', 1
|
||||||
|
normal R
|
||||||
|
Log getline(1, '$')
|
||||||
|
AssertExpect 'x aaa', 1
|
||||||
|
AssertExpect '- vim-easy-align', 0
|
||||||
|
AssertExpect! '[x]', 1
|
||||||
|
q
|
||||||
|
|
||||||
|
call plug#begin()
|
||||||
|
Plug 'junegunn/vim-easy-align'
|
||||||
|
Plug 'junegunn/aaaaaaaaaaaaaa'
|
||||||
|
Plug 'junegunn/bbbbbbbbbbbbbb'
|
||||||
|
Plug 'junegunn/cccccccccccccc'
|
||||||
|
call plug#end()
|
||||||
|
|
||||||
|
" Ruby installer
|
||||||
|
PlugUpdate
|
||||||
|
normal R
|
||||||
|
AssertExpect '- vim-easy-align', 0
|
||||||
|
AssertExpect! '[xxx]', 1
|
||||||
|
q
|
||||||
|
|
||||||
|
" Vim installer
|
||||||
|
PlugUpdate 1
|
||||||
|
normal R
|
||||||
|
AssertExpect '- vim-easy-align', 0
|
||||||
|
AssertExpect! '[xxx]', 1
|
||||||
|
q
|
||||||
|
|
||||||
Execute (Cleanup):
|
Execute (Cleanup):
|
||||||
call system('rm -rf '.temp_plugged)
|
call system('rm -rf '.temp_plugged)
|
||||||
call rename('fzf', 'fzf-staged')
|
call rename('fzf', 'fzf-staged')
|
||||||
|
@ -536,5 +585,7 @@ Execute (Cleanup):
|
||||||
unlet g:vimrc_reloaded
|
unlet g:vimrc_reloaded
|
||||||
unlet temp_plugged vader plug basertp save_rtp repo lnum fzf
|
unlet temp_plugged vader plug basertp save_rtp repo lnum fzf
|
||||||
delf PlugStatusSorted
|
delf PlugStatusSorted
|
||||||
|
delf AssertExpect
|
||||||
|
delc AssertExpect
|
||||||
|
|
||||||
Restore
|
Restore
|
||||||
|
|
Loading…
Reference in a new issue