workflow.vader 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750
  1. Execute (plug#end() before plug#begin() should fail):
  2. redir => out
  3. silent! AssertEqual 0, plug#end()
  4. redir END
  5. Assert stridx(out, 'plug#end() called without calling plug#begin() first') >= 0
  6. Execute (plug#begin() without path argument):
  7. call plug#begin()
  8. AssertEqual split(&rtp, ',')[0].'/plugged', g:plug_home
  9. unlet g:plug_home
  10. Execute (plug#begin() without path argument with empty &rtp):
  11. let save_rtp = &rtp
  12. set rtp=
  13. redir => out
  14. AssertEqual 0, plug#begin()
  15. redir END
  16. Assert stridx(out, 'Unable to determine plug home') >= 0
  17. let &rtp = save_rtp
  18. unlet save_rtp
  19. Execute (Standard runtime path is not allowed):
  20. redir => out
  21. silent! AssertEqual 0, plug#begin(split(&rtp, ',')[0].'/plugin')
  22. redir END
  23. Log out
  24. Assert stridx(out, 'Invalid plug home') >= 0
  25. Execute (plug#begin(path)):
  26. call plug#begin(g:temp_plugged.'/')
  27. Assert g:plug_home !~ '[/\\]$', 'Trailing / should be stripped from g:plug_home'
  28. AssertEqual 0, len(g:plugs)
  29. AssertEqual g:temp_plugged, g:plug_home
  30. AssertEqual g:base_rtp, &rtp
  31. Execute (Subsequent plug#begin() calls will reuse g:plug_home):
  32. call plug#begin()
  33. AssertEqual g:temp_plugged, g:plug_home
  34. Execute (Test Plug command):
  35. ^ Git repo with branch (DEPRECATED. USE BRANCH OPTION)
  36. Plug 'junegunn/seoul256.vim', { 'branch': 'yes-t_co' }
  37. AssertEqual 'file:///tmp/vim-plug-test/junegunn/seoul256.vim', g:plugs['seoul256.vim'].uri
  38. AssertEqual join([g:temp_plugged, 'seoul256.vim/'], '/'), g:plugs['seoul256.vim'].dir
  39. AssertEqual 'yes-t_co', g:plugs['seoul256.vim'].branch
  40. Plug 'junegunn/seoul256.vim', { 'branch': 'no-t_co' } " Using branch option
  41. AssertEqual 'no-t_co', g:plugs['seoul256.vim'].branch
  42. ^ Git repo with tag (DEPRECATED. USE TAG OPTION)
  43. redir => out
  44. silent Plug 'foo/bar.vim', ''
  45. redir END
  46. Assert out =~ 'Invalid argument for "tag" option of :Plug (expected: string)'
  47. Plug 'junegunn/goyo.vim', '1.5.2'
  48. AssertEqual 'file:///tmp/vim-plug-test/junegunn/goyo.vim', g:plugs['goyo.vim'].uri
  49. AssertEqual join([g:temp_plugged, 'goyo.vim/'], '/'), g:plugs['goyo.vim'].dir
  50. AssertEqual '1.5.2', g:plugs['goyo.vim'].tag
  51. redir => out
  52. silent Plug 'foo/bar.vim', {'tag': ''}
  53. redir END
  54. Assert out =~ 'Invalid argument for "tag" option of :Plug (expected: string)'
  55. Plug 'junegunn/goyo.vim', { 'tag': '1.5.3' } " Using tag option
  56. AssertEqual '1.5.3', g:plugs['goyo.vim'].tag
  57. " Git URI
  58. Plug 'file:///tmp/vim-plug-test/jg/vim-emoji'
  59. AssertEqual 'file:///tmp/vim-plug-test/jg/vim-emoji', g:plugs['vim-emoji'].uri
  60. AssertEqual '', g:plugs['vim-emoji'].branch
  61. AssertEqual join([g:temp_plugged, 'vim-emoji/'], '/'), g:plugs['vim-emoji'].dir
  62. " vim-scripts/
  63. Plug 'vim-scripts/beauty256'
  64. AssertEqual 'file:///tmp/vim-plug-test/vim-scripts/beauty256', g:plugs.beauty256.uri
  65. AssertEqual '', g:plugs.beauty256.branch
  66. AssertEqual 4, len(g:plugs)
  67. redir => out
  68. Plug 'beauty256'
  69. redir END
  70. Assert out =~ 'Invalid argument: beauty256'
  71. Execute (Plug command with dictionary option):
  72. Log string(g:plugs)
  73. for opt in ['branch', 'tag', 'commit', 'rtp', 'dir', 'as']
  74. let opts = {}
  75. let opts[opt] = ''
  76. redir => out
  77. silent Plug 'foo/bar.vim', opts
  78. redir END
  79. Assert out =~ 'Invalid argument for "'.opt.'" option of :Plug (expected: string)'
  80. endfor
  81. for opt in ['on', 'for']
  82. let opts = {}
  83. let opts[opt] = ''
  84. redir => out
  85. silent Plug 'foo/bar.vim', opts
  86. redir END
  87. Assert out =~ 'Invalid argument for "'.opt.'" option of :Plug (expected: string or list)'
  88. endfor
  89. redir => out
  90. silent Plug 'foo/bar.vim', {'do': ''}
  91. redir END
  92. Assert out =~ 'Invalid argument for "do" option of :Plug (expected: string or funcref)'
  93. Plug 'junegunn/seoul256.vim', { 'branch': 'no-t_co', 'rtp': '././' }
  94. AssertEqual join([g:temp_plugged, 'seoul256.vim/'], '/'), g:plugs['seoul256.vim'].dir
  95. AssertEqual '././', g:plugs['seoul256.vim'].rtp
  96. Log string(g:plugs)
  97. AssertEqual 4, len(g:plugs)
  98. Execute (PlugStatus before installation):
  99. PlugStatus
  100. AssertExpect 'Not found', 4
  101. q
  102. Execute (PlugClean before installation):
  103. PlugClean
  104. AssertExpect 'Already clean', 1
  105. q
  106. Execute (plug#end() updates &rtp):
  107. " Plug 'junegunn/goyo.vim', { 'tag': '1.5.3' }
  108. " Plug 'file:///tmp/vim-plug-test/jg/vim-emoji'
  109. " Plug 'beauty256'
  110. " Plug 'junegunn/seoul256.vim', { 'branch': 'no-t_co', 'rtp': '././' }
  111. call plug#end()
  112. Assert len(&rtp) > len(g:base_rtp)
  113. AssertEqual g:first_rtp, split(&rtp, ',')[0]
  114. AssertEqual g:last_rtp, split(&rtp, ',')[-1]
  115. Execute (Yet, plugins are not available):
  116. Assert empty(globpath(&rtp, 'autoload/emoji.vim'))
  117. Execute (PlugInstall):
  118. PlugInstall
  119. q
  120. Execute (Plugin available after installation):
  121. Assert !empty(globpath(&rtp, 'autoload/emoji.vim'))
  122. Execute (PlugClean after installation):
  123. PlugClean
  124. AssertExpect 'Already clean', 1
  125. q
  126. Execute (PlugStatus after installation):
  127. PlugStatus
  128. Log getline(1, '$')
  129. AssertExpect 'OK', 4
  130. q
  131. Execute (PlugUpdate - tagged plugin should not fail (#174)):
  132. PlugUpdate goyo.vim
  133. Log getline(1, '$')
  134. AssertExpect '^- goyo.vim', 1
  135. q
  136. Execute (Change tag of goyo.vim):
  137. call plug#begin()
  138. Plug 'junegunn/goyo.vim', { 'tag': '9.9.9' }
  139. call plug#end()
  140. Execute (PlugStatus):
  141. call PlugStatusSorted()
  142. Expect:
  143. Invalid tag: 1.5.3 (expected: 9.9.9). Try PlugUpdate.
  144. Finished. 1 error(s).
  145. [=]
  146. x goyo.vim:
  147. Execute (Remove tag of goyo.vim):
  148. call plug#begin()
  149. Plug 'junegunn/goyo.vim'
  150. call plug#end()
  151. Execute (PlugStatus):
  152. call PlugStatusSorted()
  153. Expect:
  154. Invalid branch: HEAD (expected: master). Try PlugUpdate.
  155. Finished. 1 error(s).
  156. [=]
  157. x goyo.vim:
  158. Execute (PlugUpdate to set the right branch):
  159. PlugUpdate
  160. call PlugStatusSorted()
  161. Expect:
  162. - goyo.vim: OK
  163. Finished. 0 error(s).
  164. [=]
  165. Execute (Change branch of seoul256.vim):
  166. call plug#begin()
  167. Plug 'junegunn/seoul256.vim'
  168. Plug 'file:///tmp/vim-plug-test/jg/vim-emoji'
  169. call plug#end()
  170. Execute (PlugStatus):
  171. call PlugStatusSorted()
  172. Expect:
  173. Invalid branch: no-t_co (expected: master). Try PlugUpdate.
  174. - vim-emoji: OK
  175. Finished. 1 error(s).
  176. [==]
  177. x seoul256.vim:
  178. Execute (PlugUpdate to switch branch, then PlugStatus):
  179. PlugUpdate
  180. call PlugStatusSorted()
  181. Expect:
  182. - seoul256.vim: OK
  183. - vim-emoji: OK
  184. Finished. 0 error(s).
  185. [==]
  186. Execute (Change tag of seoul256.vim):
  187. call plug#begin()
  188. Plug 'junegunn/seoul256.vim', { 'tag': 'no-such-tag' }
  189. call plug#end()
  190. call PlugStatusSorted()
  191. Expect:
  192. Invalid tag: N/A (expected: no-such-tag). Try PlugUpdate.
  193. Finished. 1 error(s).
  194. [=]
  195. x seoul256.vim:
  196. Execute (Change URI of seoul256.vim):
  197. call plug#begin()
  198. Plug 'junegunn.choi/seoul256.vim'
  199. Plug 'file:///tmp/vim-plug-test/jg/vim-emoji'
  200. call plug#end()
  201. Execute (PlugStatus):
  202. call PlugStatusSorted()
  203. Expect:
  204. Expected: file:///tmp/vim-plug-test/junegunn.choi/seoul256.vim
  205. Invalid URI: file:///tmp/vim-plug-test/junegunn/seoul256.vim
  206. PlugClean required.
  207. - vim-emoji: OK
  208. Finished. 1 error(s).
  209. [==]
  210. x seoul256.vim:
  211. Execute (Corrected the URI but ahead of upstream):
  212. call plug#begin()
  213. Plug 'junegunn/seoul256.vim'
  214. Plug 'file:///tmp/vim-plug-test/jg/vim-emoji'
  215. call plug#end()
  216. for _ in range(3)
  217. call system(printf('cd "%s" && git commit --allow-empty -m "dummy"', g:plugs['seoul256.vim'].dir))
  218. endfor
  219. call PlugStatusSorted()
  220. Expect:
  221. Ahead of origin/master by 3 commit(s).
  222. Cannot update until local changes are pushed.
  223. - vim-emoji: OK
  224. Finished. 1 error(s).
  225. [==]
  226. x seoul256.vim:
  227. # TODO: does not work due to inputsave()
  228. # Do (PlugClean):
  229. # :PlugClean\<Enter>y\<Enter>
  230. # ggyG
  231. # q
  232. # PGdd
  233. Execute (PlugClean! keeps seoul256.vim):
  234. PlugClean!
  235. " Two removed, emoji and seoul256 left
  236. AssertEqual 'Removed 2 directories.', getline(4)
  237. AssertExpect '^\~ ', 2
  238. AssertExpect 'Diverged', 0
  239. Assert !empty(globpath(&rtp, 'colors/seoul256.vim'))
  240. Assert !empty(globpath(&rtp, 'autoload/emoji.vim'))
  241. q
  242. Execute (Make seoul256 to be diverged):
  243. call plug#begin()
  244. Plug 'junegunn/seoul256.vim'
  245. Plug 'file:///tmp/vim-plug-test/jg/vim-emoji'
  246. call plug#end()
  247. call system(printf(join([
  248. \ 'cd "%s"',
  249. \ 'git fetch --unshallow',
  250. \ 'git reset "@{u}~1"',
  251. \ 'git commit --allow-empty -m "diverged1"',
  252. \ 'git commit --allow-empty -m "diverged2"'], ' && '),
  253. \ g:plugs['seoul256.vim'].dir))
  254. Assert empty(v:shell_error), 'Got shell error: '.v:shell_error
  255. call PlugStatusSorted()
  256. Expect:
  257. Backup local changes and run PlugClean and PlugUpdate to reinstall it.
  258. Diverged from origin/master (2 commit(s) ahead and 1 commit(s) behind!
  259. - vim-emoji: OK
  260. Finished. 1 error(s).
  261. [==]
  262. x seoul256.vim:
  263. Execute (PlugClean! removes seoul256.vim):
  264. PlugClean!
  265. " One removed, emoji left
  266. AssertEqual 'Removed 1 directories.', getline(4)
  267. AssertExpect '^\~ ', 1
  268. AssertExpect 'Diverged', 1
  269. Assert empty(globpath(&rtp, 'colors/seoul256.vim'))
  270. Assert !empty(globpath(&rtp, 'autoload/emoji.vim'))
  271. q
  272. Execute (Change GIT URI of vim-emoji):
  273. call plug#begin()
  274. Plug 'junegunn/seoul256.vim'
  275. Plug 'junegunn/vim-emoji'
  276. call plug#end()
  277. Execute (PlugStatus):
  278. call PlugStatusSorted()
  279. Expect:
  280. Expected: file:///tmp/vim-plug-test/junegunn/vim-emoji
  281. Invalid URI: file:///tmp/vim-plug-test/jg/vim-emoji
  282. Not found. Try PlugInstall.
  283. PlugClean required.
  284. Finished. 2 error(s).
  285. [==]
  286. x seoul256.vim:
  287. x vim-emoji:
  288. Execute (PlugClean! to remove vim-emoji):
  289. PlugClean!
  290. AssertExpect '^\~ ', 1
  291. AssertEqual 'Removed 1 directories.', getline(4)
  292. Assert empty(globpath(&rtp, 'colors/seoul256.vim')), 'seoul256.vim was removed'
  293. Assert empty(globpath(&rtp, 'autoload/emoji.vim')), 'emoji was removed'
  294. q
  295. Execute (PlugUpdate to install both again):
  296. PlugUpdate
  297. AssertExpect '^- [^:]*:', 2
  298. Assert !empty(globpath(&rtp, 'colors/seoul256.vim')), 'seoul256.vim should be found'
  299. Assert !empty(globpath(&rtp, 'autoload/emoji.vim')), 'vim-emoji should be found'
  300. q
  301. Execute (PlugUpdate only to find out plugins are up-to-date, D key to check):
  302. PlugUpdate
  303. AssertExpect 'Already up.to.date', 2, 'Expected 2 times "Already up-to-date", but got: '.string(getline(1, '$'))
  304. normal D
  305. AssertEqual '0 plugin(s) updated.', getline(1)
  306. q
  307. Execute (PlugDiff - 'No updates.'):
  308. PlugDiff
  309. Log getline(1, '$')
  310. AssertEqual '0 plugin(s) updated.', getline(1)
  311. Assert empty(mapcheck('o'))
  312. Assert empty(mapcheck('X'))
  313. Assert empty(mapcheck("\<cr>"))
  314. q
  315. Execute (New commits on remote, PlugUpdate, then PlugDiff):
  316. for repo in ['seoul256.vim', 'vim-emoji']
  317. for _ in range(2)
  318. call system(printf('cd /tmp/vim-plug-test/junegunn/%s && git commit --allow-empty -m "update"', repo))
  319. endfor
  320. endfor
  321. unlet repo
  322. PlugUpdate
  323. " Now we have updates
  324. normal D
  325. AssertEqual '2 plugin(s) updated.', getline(1)
  326. AssertThrows execute('/gpg')
  327. " Preview commit
  328. silent! wincmd P
  329. AssertEqual 0, &previewwindow
  330. " ]] motion
  331. execute 'normal ]]'
  332. let lnum = line('.')
  333. AssertEqual 3, col('.')
  334. " Open commit preview
  335. execute "normal j\<cr>"
  336. wincmd P
  337. AssertEqual 1, &previewwindow
  338. AssertEqual 'git', &filetype
  339. " Close preview window
  340. pclose
  341. " Open and go to preview window with a custom mapping
  342. nmap <buffer> <c-o> <plug>(plug-preview)<c-w>P
  343. execute "normal \<c-o>"
  344. AssertEqual 1, &previewwindow, 'Should be on preview window'
  345. normal q
  346. AssertEqual 0, &previewwindow, 'Should not be on preview window'
  347. " ]] motion
  348. execute 'normal $]]'
  349. Assert line('.') >= 4
  350. " 5+ for merge commit
  351. AssertEqual 3, col('.')
  352. " [[ motion
  353. execute 'normal 0[['
  354. AssertEqual lnum, line('.')
  355. unlet lnum
  356. AssertEqual 3, col('.')
  357. " X key to revert the update
  358. AssertExpect '^- ', 2
  359. execute "normal Xn\<cr>"
  360. AssertExpect '^- ', 2
  361. execute "normal Xy\<cr>"
  362. AssertExpect '^- ', 1
  363. " q will close preview window as well
  364. normal q
  365. " We no longer have preview window
  366. silent! wincmd P
  367. AssertEqual 0, &previewwindow
  368. " q should not close preview window if it's already open
  369. pedit
  370. PlugDiff
  371. AssertExpect '^- ', 1
  372. execute "normal ]]j\<cr>"
  373. normal q
  374. silent! wincmd P
  375. AssertEqual 1, &previewwindow
  376. pclose
  377. Execute (Test g:plug_pwindow):
  378. let g:plug_pwindow = 'below 5new'
  379. PlugDiff
  380. AssertExpect '^- ', 1
  381. execute "normal ]]jo"
  382. AssertEqual 0, &previewwindow
  383. AssertEqual 1, winnr()
  384. wincmd P
  385. AssertEqual 1, &previewwindow
  386. AssertEqual 2, winnr()
  387. AssertEqual 5, winheight('.')
  388. wincmd p
  389. normal q
  390. unlet g:plug_pwindow
  391. Execute (#572 - Commit preview should work with non-POSIX-compliant &shell):
  392. " Invalid shell
  393. let shell = &shell
  394. set shell=shellfish
  395. try
  396. " Preview commit should still work
  397. PlugDiff
  398. execute "normal ]]jo"
  399. wincmd P
  400. Log getline(1, '$')
  401. Assert getline(1) =~ 'commit', 'Preview window is empty'
  402. AssertEqual 'shellfish', &shell
  403. finally
  404. " Restore &shell
  405. let &shell = shell
  406. unlet shell
  407. pclose
  408. q
  409. endtry
  410. Execute (Reuse Plug window in another tab):
  411. let tabnr = tabpagenr()
  412. PlugDiff
  413. tab new new-tab
  414. set buftype=nofile
  415. PlugUpdate
  416. normal D
  417. AssertExpect '^- ', 1
  418. normal q
  419. AssertEqual tabnr, tabpagenr()
  420. normal! gt
  421. q
  422. unlet tabnr
  423. Execute (contd. PlugDiff should not show inverted history):
  424. " Additional PlugUpdate to clear diff
  425. PlugUpdate
  426. PlugDiff
  427. Log getline(1, '$')
  428. " Checking out older revisions
  429. for repo in values(g:plugs)
  430. call system(printf('cd %s && git reset HEAD^ --hard', shellescape(repo.dir)))
  431. endfor
  432. unlet repo
  433. " PlugDiff should not report the changes i.e. git log --left-only
  434. PlugDiff
  435. Log getline(1, '$')
  436. AssertEqual '0 plugin(s) updated.', getline(1)
  437. q
  438. **********************************************************************
  439. ~ PlugDiff to see the pending changes
  440. **********************************************************************
  441. Execute (PlugDiff):
  442. call plug#begin()
  443. call plug#end()
  444. PlugClean!
  445. call plug#begin()
  446. Plug 'file://'.expand('$PLUG_FIXTURES').'/xxx'
  447. Plug 'file://'.expand('$PLUG_FIXTURES').'/yyy'
  448. call plug#end()
  449. PlugInstall
  450. Log getline(1, '$')
  451. call system('cd "$PLUG_FIXTURES/xxx" && git commit --allow-empty -m update-xxx && git tag -f xxx')
  452. call system('cd "$PLUG_FIXTURES/yyy" && git tag -f yyy && git commit --allow-empty -m update-yyy && git tag -f zzz')
  453. let g:plugs.yyy.tag = 'yyy'
  454. PlugUpdate
  455. Log getline(1, '$')
  456. PlugDiff
  457. " 1 plugin(s) updated. 1 plugin(s) have pending updates.
  458. " [==]
  459. "
  460. " Last update:
  461. " ------------
  462. "
  463. " - xxx:
  464. " 166cfff (tag: xxx) update-xxx (1 second ago)
  465. "
  466. " Pending updates:
  467. " ----------------
  468. "
  469. " - yyy: (tag: yyy)
  470. " c0a064b (tag: zzz) update-yyy (1 second ago)
  471. "
  472. Log getline(1, '$')
  473. AssertEqual 15, line('$')
  474. AssertEqual '1 plugin(s) updated. 1 plugin(s) have pending updates.', getline(1)
  475. AssertEqual '[==]', getline(2)
  476. AssertEqual '- yyy: (tag: yyy)', getline(13)
  477. Assert getline(8) =~ '(tag: xxx)'
  478. Assert getline(14) =~ '(tag: zzz)'
  479. Assert !empty(mapcheck('o'))
  480. Assert !empty(mapcheck('X'))
  481. Assert !empty(mapcheck("\<cr>"))
  482. q
  483. Execute (Do not show diff for commits outside of rtp):
  484. call plug#begin()
  485. call plug#end()
  486. PlugClean!
  487. call plug#begin()
  488. Plug 'file://'.expand('$PLUG_FIXTURES').'/xxx'
  489. Plug 'file://'.expand('$PLUG_FIXTURES').'/yyy', { 'rtp': 'rtp' }
  490. call plug#end()
  491. PlugInstall
  492. Log getline(1, '$')
  493. call system('cd "$PLUG_FIXTURES/xxx" && git commit --allow-empty -m update-xxx && git tag -f xxx')
  494. call system('cd "$PLUG_FIXTURES/yyy" && git commit --allow-empty -m update-yyy && git tag -f yyy')
  495. let g:plugs.yyy.tag = 'yyy'
  496. PlugUpdate
  497. Log getline(1, '$')
  498. PlugDiff
  499. " 1 plugin(s) updated.
  500. " [==]
  501. "
  502. " Last update:
  503. " ------------
  504. "
  505. " - xxx:
  506. " * 7faa9b2 update-xxx (0 seconds ago)
  507. "
  508. " Pending updates:
  509. " ----------------
  510. "
  511. " N/A
  512. "
  513. Log getline(1, '$')
  514. AssertEqual 14, line('$')
  515. AssertEqual '1 plugin(s) updated.', getline(1)
  516. AssertEqual '[==]', getline(2)
  517. AssertEqual 'Last update:', getline(4)
  518. AssertEqual '- xxx:', getline(7)
  519. Assert !empty(mapcheck('o'))
  520. Assert !empty(mapcheck('X'))
  521. Assert !empty(mapcheck("\<cr>"))
  522. q
  523. **********************************************************************
  524. ~ On-demand loading / Partial installation/update ~
  525. **********************************************************************
  526. Execute (Trying to execute on-demand commands when plugin is not installed):
  527. call ReloadPlug()
  528. call plug#begin()
  529. Plug 'junegunn/vim-easy-align', { 'on': ['EasyAlign', 'LiveEasyAlign!'] }
  530. call plug#end()
  531. Assert exists(':EasyAlign')
  532. Assert exists(':LiveEasyAlign')
  533. AssertThrows EasyAlign
  534. AssertThrows LiveEasyAlign
  535. Assert !exists(':EasyAlign')
  536. Assert !exists(':LiveEasyAlign')
  537. Execute (New set of plugins):
  538. call ReloadPlug()
  539. call plug#begin()
  540. Plug 'junegunn/vim-fnr'
  541. Plug 'junegunn/vim-pseudocl'
  542. Plug 'junegunn/vim-easy-align', { 'on': 'EasyAlign' }
  543. Plug 'junegunn/vim-redis', { 'for': 'redis' }
  544. let user_autocmd = {}
  545. autocmd! User vim-fnr let user_autocmd.fnr = 1
  546. autocmd! User vim-easy-align let user_autocmd.easy_align = 1
  547. autocmd! User vim-redis let user_autocmd.redis = 1
  548. call plug#end()
  549. Execute (Check commands):
  550. Assert !exists(':FNR'), 'FNR command should not be found'
  551. Assert !exists(':RedisExecute'), 'RedisExecute command should not be found'
  552. Assert empty(user_autocmd)
  553. Execute (Partial PlugInstall):
  554. PlugInstall vim-fnr vim-easy-align
  555. AssertExpect 'vim-fnr', 1
  556. q
  557. PlugInstall vim-fnr vim-easy-align 1
  558. AssertExpect 'vim-fnr', 1
  559. AssertExpect 'vim-easy-align', 1
  560. AssertEqual g:first_rtp, split(&rtp, ',')[0]
  561. AssertEqual g:last_rtp, split(&rtp, ',')[-1]
  562. q
  563. Given (Unaligned code):
  564. a=1
  565. aa=2
  566. Execute (Check installed plugins):
  567. call EnsureLoaded()
  568. Assert exists(':FNR'), 'FNR command should be found'
  569. Assert !exists(':RedisExecute'), 'RedisExecute command still should not be found'
  570. Assert exists(':EasyAlign'), 'EasyAlign command should be found'
  571. %EasyAlign=
  572. Expect (Aligned code):
  573. a = 1
  574. aa = 2
  575. Then (autocmd executed):
  576. Assert user_autocmd.easy_align
  577. AssertEqual 1, len(user_autocmd)
  578. Given:
  579. Execute (Partial PlugUpdate):
  580. PlugUpdate vim-redis
  581. q
  582. Execute (On-demand loading based on filetypes):
  583. Assert !exists(':RedisExecute'), 'RedisExecute command still should not be found'
  584. set ft=redis
  585. Assert exists(':RedisExecute'), 'RedisExecute command is now found'
  586. Assert user_autocmd.redis
  587. AssertEqual 2, len(user_autocmd)
  588. autocmd! User
  589. unlet user_autocmd
  590. **********************************************************************
  591. ~ Local (unmanaged) plugins
  592. **********************************************************************
  593. Execute (Add unmanaged plugin):
  594. let fzf = expand('$PLUG_FIXTURES/fzf')
  595. call RmRf(fzf)
  596. Log fzf
  597. call plug#begin()
  598. Plug fzf, { 'on': 'SomeCommand' }
  599. call plug#end()
  600. " Check uri field
  601. Assert !has_key(g:plugs.fzf, 'uri'), 'Should not have uri field'
  602. " Check dir field
  603. AssertEqual fzf.'/', g:plugs.fzf.dir
  604. " Trailing slashes and backslashes should be stripped
  605. for suffix in ['///', '/\/\/']
  606. call plug#begin()
  607. Plug fzf.suffix, { 'on': 'SomeCommand' }
  608. call plug#end()
  609. " Check dir field
  610. AssertEqual fzf.'/', g:plugs.fzf.dir
  611. endfor
  612. Execute (Plug block for following tests):
  613. call plug#begin()
  614. Plug 'junegunn/vim-easy-align'
  615. Plug fzf, { 'on': 'SomeCommand' }
  616. call plug#end()
  617. " Remove plugins from previous tests
  618. PlugClean!
  619. q
  620. Execute (PlugInstall will only install vim-easy-align):
  621. PlugInstall
  622. Log getline(1, '$')
  623. AssertExpect 'fzf', 0
  624. q
  625. Execute (PlugUpdate will only update vim-easy-align):
  626. PlugUpdate
  627. Log getline(1, '$')
  628. AssertExpect 'fzf', 0
  629. q
  630. Execute (PlugClean should not care about unmanaged plugins):
  631. PlugClean
  632. Log getline(1, '$')
  633. AssertExpect 'fzf', 0
  634. q
  635. Execute (PlugStatus should point out that the plugin is missing):
  636. PlugStatus
  637. Log getline(1, '$')
  638. AssertExpect 'x fzf', 1
  639. AssertExpect 'Not found', 1
  640. q
  641. Execute (Deploy unmanaged plugin):
  642. Assert !exists(':FZF'), ':FZF command should not exist'
  643. call RmRf(fzf)
  644. Log system(printf('cp -r "/tmp/vim-plug-test/fzf" "%s"', fzf))
  645. Execute (PlugUpdate still should not care):
  646. PlugUpdate
  647. Log getline(1, '$')
  648. AssertExpect 'fzf', 0
  649. q
  650. Execute (PlugStatus with no error):
  651. PlugStatus
  652. Log getline(1, '$')
  653. AssertExpect 'x fzf', 0
  654. AssertExpect 'Not found', 0
  655. q
  656. Execute (Check &rtp after SomeCommand):
  657. Log &rtp
  658. Assert &rtp !~ 'fzf'
  659. silent! SomeCommand
  660. Assert &rtp =~ 'fzf'
  661. AssertEqual g:first_rtp, split(&rtp, ',')[0]
  662. AssertEqual g:last_rtp, split(&rtp, ',')[-1]
  663. Execute (Common parent):
  664. call plug#begin()
  665. Plug 'junegunn/vim-pseudocl'
  666. Plug 'junegunn/vim-fnr'
  667. Plug 'junegunn/vim-oblique'
  668. call plug#end()
  669. PlugInstall
  670. Log getline(1, '$')
  671. AssertExpect! '[===]', 1
  672. q
  673. unlet fzf
  674. **********************************************************************
  675. ~ Frozen plugins
  676. **********************************************************************
  677. - We've decided to install plugins that are frozen: see #113
  678. Execute (Frozen plugin are not ~~installed nor~~ updated):
  679. " Remove plugins
  680. call plug#begin()
  681. call plug#end()
  682. PlugClean!
  683. q
  684. " vim-easy-align is not found, so it will be installed even though it's frozen
  685. call plug#begin()
  686. Plug 'junegunn/vim-easy-align', { 'frozen': 1 }
  687. call plug#end()
  688. PlugInstall
  689. AssertEqual 1, len(filter(getline(1, '$'), 'v:val =~ "vim-easy-align"'))
  690. q
  691. " Remove plugins again
  692. call plug#begin()
  693. call plug#end()
  694. PlugClean!
  695. q
  696. " PlugUpdate will do the same
  697. call plug#begin()
  698. Plug 'junegunn/vim-easy-align', { 'frozen': 1 }
  699. call plug#end()
  700. PlugInstall
  701. AssertEqual 1, len(filter(getline(1, '$'), 'v:val =~ "vim-easy-align"'))
  702. q
  703. " Since vim-easy-align already exists, PlugInstall or PlugUpdate will skip it
  704. redir => out
  705. silent PlugInstall
  706. redir END
  707. Assert out =~ 'No plugin to install'
  708. redir => out
  709. silent PlugUpdate
  710. redir END
  711. Assert out =~ 'No plugin to update'
  712. Execute (But you can still install it if the name is given as the argument):
  713. PlugInstall vim-easy-align
  714. Log getline(1, '$')
  715. AssertEqual 1, len(filter(getline(1, '$'), 'v:val =~ "vim-easy-align"'))
  716. q
  717. PlugUpdate vim-easy-align
  718. Log getline(1, '$')
  719. AssertEqual 1, len(filter(getline(1, '$'), 'v:val =~ "vim-easy-align"'))
  720. q
  721. **********************************************************************
  722. ~ Retry
  723. **********************************************************************
  724. Execute (Retry failed tasks):
  725. call plug#begin()
  726. Plug 'junegunn/vim-easy-align'
  727. Plug 'junegunn/aaaaaaaaaaaaaa'
  728. call plug#end()
  729. PlugInstall
  730. Log getline(1, '$')
  731. AssertExpect 'x aaa', 1
  732. AssertExpect '- vim-easy-align', 1
  733. normal R
  734. Log getline(1, '$')
  735. AssertExpect 'x aaa', 1
  736. AssertExpect '- vim-easy-align', 0
  737. AssertExpect! '[x]', 1
  738. q
  739. call plug#begin()
  740. Plug 'junegunn/vim-easy-align'
  741. Plug 'junegunn/aaaaaaaaaaaaaa'
  742. Plug 'junegunn/bbbbbbbbbbbbbb'
  743. Plug 'junegunn/cccccccccccccc'
  744. call plug#end()
  745. " Ruby installer
  746. PlugUpdate
  747. normal R
  748. AssertExpect '- vim-easy-align', 0
  749. AssertExpect! '[xxx]', 1
  750. q
  751. " Vim installer
  752. PlugUpdate 1
  753. normal R
  754. AssertExpect '- vim-easy-align', 0
  755. AssertExpect! '[xxx]', 1
  756. q
  757. **********************************************************************
  758. ~ Post-update hook (`do` option)
  759. **********************************************************************
  760. Execute (Cleanup):
  761. call plug#begin()
  762. call plug#end()
  763. PlugClean!
  764. q
  765. Execute (On install):
  766. call plug#begin()
  767. Plug 'junegunn/vim-easy-align', { 'do': 'touch installed' }
  768. Plug 'junegunn/vim-pseudocl'
  769. Plug 'junegunn/seoul256.vim'
  770. Plug 'junegunn/goyo.vim'
  771. Plug 'yous/subsubmodule'
  772. call plug#end()
  773. silent PlugInstall
  774. q
  775. Assert filereadable(g:plugs['vim-easy-align'].dir.'/installed'),
  776. \ 'vim-easy-align/installed should exist'
  777. Assert !filereadable(g:plugs['vim-pseudocl'].dir.'/installed'),
  778. \ 'vim-pseudocl/installed should not exist'
  779. AssertEqual ' ', system('cd '.g:plugs['subsubmodule'].dir.' && git submodule status')[0],
  780. \ 'subsubmodule/subsubmodule should be initialized'
  781. Execute (On update):
  782. call plug#begin()
  783. Plug 'junegunn/vim-easy-align', { 'do': 'touch updated' }
  784. Plug 'junegunn/vim-pseudocl', { 'do': 'touch updated' }
  785. Plug 'junegunn/seoul256.vim'
  786. Plug 'junegunn/goyo.vim'
  787. Plug 'yous/subsubmodule'
  788. call plug#end()
  789. " New commits on remote
  790. call system('cd /tmp/vim-plug-test/junegunn/vim-pseudocl && git commit --allow-empty -m "update"')
  791. silent PlugUpdate
  792. Log getline(1, '$')
  793. q
  794. Assert !filereadable(g:plugs['vim-easy-align'].dir.'/updated'),
  795. \ 'vim-easy-align/updated should not exist'
  796. Assert filereadable(g:plugs['vim-pseudocl'].dir.'/updated'),
  797. \ 'vim-pseudocl/updated should exist'
  798. Execute (When already installed):
  799. call plug#begin()
  800. Plug 'junegunn/vim-easy-align', { 'do': 'touch installed2' }
  801. Plug 'junegunn/vim-pseudocl', { 'commit': '7f8cd78' }
  802. Plug 'junegunn/seoul256.vim', { 'branch': 'no-t_co' }
  803. Plug 'junegunn/goyo.vim', { 'tag': '1.5.3' }
  804. Plug 'yous/subsubmodule'
  805. call plug#end()
  806. PlugInstall
  807. q
  808. Assert !filereadable(g:plugs['vim-easy-align'].dir.'/installed2'),
  809. \ 'vim-easy-align/installed2 should not exist'
  810. AssertNotEqual '7f8cd78cb1fe52185b98b16a3749811f0cc508af', GitCommit('vim-pseudocl')
  811. AssertNotEqual 'no-t_co', GitBranch('seoul256.vim')
  812. AssertNotEqual '1.5.3', GitTag('goyo.vim')
  813. Execute (PlugInstall!):
  814. silent PlugInstall!
  815. q
  816. Assert filereadable(g:plugs['vim-easy-align'].dir.'/installed2'),
  817. \ 'vim-easy-align/installed2 should exist'
  818. AssertEqual '7f8cd78cb1fe52185b98b16a3749811f0cc508af', GitCommit('vim-pseudocl')
  819. AssertEqual 'no-t_co', GitBranch('seoul256.vim')
  820. AssertEqual '1.5.3', GitTag('goyo.vim')
  821. Execute (When submodules are not initialized):
  822. call system(printf('cd %s && git submodule deinit subsubmodule', g:plugs['subsubmodule'].dir))
  823. silent PlugInstall!
  824. q
  825. AssertEqual ' ', system(printf('cd %s && git submodule status', g:plugs['subsubmodule'].dir))[0],
  826. \ 'subsubmodule/subsubmodule should be initialized'
  827. Execute (When already updated):
  828. call plug#begin()
  829. Plug 'junegunn/vim-easy-align', { 'do': 'touch updated2' }
  830. Plug 'junegunn/vim-pseudocl', { 'commit': 'dd507ca' }
  831. Plug 'junegunn/seoul256.vim', { 'branch': 'master' }
  832. Plug 'junegunn/goyo.vim', { 'tag': '1.6.0' }
  833. Plug 'yous/subsubmodule'
  834. call plug#end()
  835. PlugUpdate
  836. q
  837. Assert !filereadable(g:plugs['vim-easy-align'].dir.'/updated2'),
  838. \ 'vim-easy-align/updated2 should not exist'
  839. AssertEqual 'dd507ca0d5f3fdf0d522558cc5ecffdabf824469', GitCommit('vim-pseudocl')
  840. AssertEqual 'master', GitBranch('seoul256.vim')
  841. AssertEqual '1.6.0', GitTag('goyo.vim')
  842. Execute (PlugUpdate!):
  843. silent PlugUpdate!
  844. q
  845. Assert filereadable(g:plugs['vim-easy-align'].dir.'/updated2'),
  846. \ 'vim-easy-align/updated2 should exist'
  847. Execute (When submodules are not initialized):
  848. call system(printf('cd %s && git submodule deinit subsubmodule', g:plugs['subsubmodule'].dir))
  849. ^ #481 submodule update should use standard shell
  850. let sh = &shell
  851. set sh=/bin/echo
  852. silent PlugUpdate!
  853. let &shell = sh
  854. unlet sh
  855. q
  856. AssertEqual ' ', system(printf('cd %s && git submodule status', g:plugs['subsubmodule'].dir))[0],
  857. \ 'subsubmodule/subsubmodule should be initialized'
  858. Execute (Using Funcref):
  859. function! PlugUpdated(info)
  860. call system('touch '. a:info.name . a:info.status . a:info.force . len(a:info))
  861. endfunction
  862. call plug#begin()
  863. Plug 'junegunn/vim-easy-align', { 'do': function('PlugUpdated') }
  864. Plug 'junegunn/vim-pseudocl', { 'do': function('PlugUpdated') }
  865. call plug#end()
  866. call system('cd /tmp/vim-plug-test/junegunn/vim-easy-align && git commit --allow-empty -m "update"')
  867. call system('cd '.g:plugs['vim-easy-align'].dir.' && git reset --hard HEAD^')
  868. call RmRf(g:plugs['vim-pseudocl'].dir)
  869. PlugUpdate
  870. Log getline(1, '$')
  871. q
  872. Assert filereadable(g:plugs['vim-easy-align'].dir.'/vim-easy-alignupdated03'),
  873. \ 'vim-easy-align/vim-easy-alignupdated03 should exist'
  874. Assert filereadable(g:plugs['vim-pseudocl'].dir.'/vim-pseudoclinstalled03'),
  875. \ 'vim-pseudocl/vim-pseudoclinstalled03 should exist'
  876. call RmRf(g:plugs['vim-pseudocl'].dir)
  877. PlugInstall!
  878. q
  879. Assert filereadable(g:plugs['vim-easy-align'].dir.'/vim-easy-alignunchanged13'),
  880. \ 'vim-easy-align/vim-easy-alignunchanged13 should exist'
  881. Assert filereadable(g:plugs['vim-pseudocl'].dir.'/vim-pseudoclinstalled13'),
  882. \ 'vim-pseudocl/vim-pseudoclinstalled13 should exist'
  883. call system('cd '.g:plugs['vim-easy-align'].dir.' && git reset --hard HEAD^')
  884. PlugUpdate!
  885. q
  886. Assert filereadable(g:plugs['vim-easy-align'].dir.'/vim-easy-alignupdated13'),
  887. \ 'vim-easy-align/vim-easy-alignupdated13 should exist'
  888. Assert filereadable(g:plugs['vim-pseudocl'].dir.'/vim-pseudoclunchanged13'),
  889. \ 'vim-pseudocl/vim-pseudoclunchanged13 should exist'
  890. Execute (Post-update hook output; success and failure):
  891. call plug#begin()
  892. Plug 'junegunn/vim-easy-align', { 'do': 'xxx-non-existent-command-xxx' }
  893. Plug 'junegunn/vim-pseudocl', { 'do': 'true' }
  894. call plug#end()
  895. silent PlugInstall! 1
  896. AssertEqual '- Post-update hook for vim-pseudocl ... OK', getline(5)
  897. AssertEqual 'x Post-update hook for vim-easy-align ... Exit status: 127', getline(6)
  898. q
  899. Execute (Post-update hook output; invalid type or funcref):
  900. call plug#begin()
  901. Plug 'junegunn/vim-easy-align', { 'do': ':echo 1' }
  902. Plug 'junegunn/vim-pseudocl', { 'do': function('call') }
  903. call plug#end()
  904. let g:plugs['vim-easy-align'].do = 1
  905. silent PlugInstall! 1
  906. AssertEqual 'x Post-update hook for vim-pseudocl ... Vim(call):E119: Not enough arguments for function: call', getline(5)
  907. AssertEqual 'x Post-update hook for vim-easy-align ... Invalid hook type', getline(6)
  908. q
  909. Execute (Should not run when failed to update):
  910. call plug#begin()
  911. Plug 'junegunn/vim-easy-align', { 'do': 'touch failed' }
  912. Plug 'junegunn/vim-pseudocl', { 'do': 'touch not-failed' }
  913. call plug#end()
  914. " Invalid remote URL
  915. call system(printf('cd %s && git remote set-url origin xxx', g:plugs['vim-easy-align'].dir))
  916. " New commits on remote
  917. call system('cd /tmp/vim-plug-test/junegunn/vim-easy-align && git commit --allow-empty -m "update"')
  918. call system('cd /tmp/vim-plug-test/junegunn/vim-pseudocl && git commit --allow-empty -m "update"')
  919. silent PlugUpdate
  920. Log getline(1, '$')
  921. q
  922. Assert !filereadable(g:plugs['vim-easy-align'].dir.'/failed'),
  923. \ 'vim-easy-align/failed should not exist'
  924. Assert filereadable(g:plugs['vim-pseudocl'].dir.'/not-failed'),
  925. \ 'vim-pseudocl/not-failed should exist'
  926. Execute (Vim command with : prefix):
  927. call plug#begin()
  928. Plug 'junegunn/vim-pseudocl', { 'do': ':call setline(2, 12345)' }
  929. call plug#end()
  930. PlugInstall!
  931. Log getline(1, '$')
  932. AssertEqual '12345', getline(2)
  933. q
  934. Execute (Vim command with : prefix closing the window):
  935. call plug#begin()
  936. Plug 'junegunn/vim-pseudocl', { 'do': ':close' }
  937. call plug#end()
  938. redir => out
  939. PlugInstall!
  940. redir END
  941. Assert out =~ 'vim-plug was terminated'
  942. Assert out =~ 'of vim-pseudocl'
  943. Execute (Invalid vim command in post-update hook):
  944. call plug#begin()
  945. Plug 'junegunn/vim-pseudocl', { 'do': ':nosuchcommand' }
  946. call plug#end()
  947. PlugInstall!
  948. Log getline(1, '$')
  949. AssertExpect! 'x Post-update hook for vim-pseudocl ... Vim:E492: Not an editor command: nosuchcommand', 1
  950. q
  951. **********************************************************************
  952. ~ Overriding `dir`
  953. **********************************************************************
  954. Execute (Using custom dir):
  955. call plug#begin()
  956. Plug 'junegunn/vim-easy-align'
  957. call plug#end()
  958. Assert isdirectory(g:plugs['vim-easy-align'].dir)
  959. call RmRf('/tmp/vim-plug-test/easy-align')
  960. call plug#begin()
  961. Plug 'junegunn/vim-easy-align', { 'dir': '/tmp/vim-plug-test/easy-align' }
  962. call plug#end()
  963. AssertEqual '/tmp/vim-plug-test/easy-align/', g:plugs['vim-easy-align'].dir
  964. PlugClean!
  965. Assert !isdirectory(g:plugs['vim-easy-align'].dir)
  966. q
  967. PlugInstall
  968. q
  969. Assert isdirectory(g:plugs['vim-easy-align'].dir)
  970. **********************************************************************
  971. ~ On-demand loading load order
  972. **********************************************************************
  973. Before (Clear global vars):
  974. let g:xxx = []
  975. set rtp-=$PLUG_FIXTURES/xxx/
  976. set rtp-=$PLUG_FIXTURES/xxx/after
  977. Execute (Immediate loading):
  978. call ReloadPlug()
  979. call plug#begin()
  980. Plug '$PLUG_FIXTURES/xxx'
  981. call plug#end()
  982. " FIXME:
  983. " Different result when Vader is run from commandline with `-c` option
  984. Log g:xxx
  985. if has('vim_starting')
  986. AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect'], g:xxx
  987. else
  988. AssertEqual ['xxx/plugin', 'xxx/after/plugin', 'xxx/ftdetect', 'xxx/after/ftdetect'], g:xxx
  989. endif
  990. Execute (Command-based on-demand loading):
  991. call ReloadPlug()
  992. call plug#begin()
  993. Plug '$PLUG_FIXTURES/xxx', { 'on': 'XXX' }
  994. call plug#end()
  995. AssertEqual [], g:xxx
  996. silent! XXX
  997. AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect', 'xxx/plugin', 'xxx/after/plugin'], g:xxx
  998. setf xxx
  999. AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect', 'xxx/plugin', 'xxx/after/plugin', 'xxx/ftplugin', 'xxx/after/ftplugin', 'xxx/indent', 'xxx/after/indent', 'xxx/syntax', 'xxx/after/syntax'], g:xxx
  1000. Execute (Filetype-based on-demand loading):
  1001. call ReloadPlug()
  1002. call plug#begin()
  1003. Plug '$PLUG_FIXTURES/xxx', { 'for': 'xxx' }
  1004. Plug '$PLUG_FIXTURES/yyy', { 'for': 'yyy' }
  1005. call plug#end()
  1006. AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect'], g:xxx
  1007. setf xxx
  1008. AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect', 'xxx/plugin', 'xxx/after/plugin', 'xxx/syntax', 'xxx/after/syntax', 'xxx/ftplugin', 'xxx/after/ftplugin', 'xxx/indent', 'xxx/after/indent'], g:xxx
  1009. " syntax/xxx.vim and after/syntax/xxx.vim should not be loaded (#410)
  1010. setf yyy
  1011. AssertEqual ['yyy/ftdetect', 'yyy/after/ftdetect', 'yyy/plugin', 'yyy/after/plugin'], g:yyy
  1012. Before:
  1013. **********************************************************************
  1014. ~ plug#helptags()
  1015. **********************************************************************
  1016. Execute (plug#helptags):
  1017. call plug#begin()
  1018. Plug '$PLUG_FIXTURES/xxx'
  1019. Plug '$PLUG_FIXTURES/yyy', { 'rtp': 'rtp' }
  1020. call plug#end()
  1021. silent! call delete(expand('$PLUG_FIXTURES/xxx/doc/tags'))
  1022. silent! call delete(expand('$PLUG_FIXTURES/yyy/rtp/doc/tags'))
  1023. Assert !filereadable(expand('$PLUG_FIXTURES/xxx/doc/tags'))
  1024. Assert !filereadable(expand('$PLUG_FIXTURES/yyy/rtp/doc/tags'))
  1025. AssertEqual 1, plug#helptags()
  1026. Assert filereadable(expand('$PLUG_FIXTURES/xxx/doc/tags'))
  1027. Assert filereadable(expand('$PLUG_FIXTURES/yyy/rtp/doc/tags'))
  1028. **********************************************************************
  1029. ~ Manual loading
  1030. **********************************************************************
  1031. Execute (plug#load - invalid arguments):
  1032. call ResetPlug()
  1033. call plug#begin()
  1034. Plug '$PLUG_FIXTURES/xxx', { 'for': 'xxx' }
  1035. Plug '$PLUG_FIXTURES/yyy', { 'for': 'yyy' }
  1036. call plug#end()
  1037. AssertEqual 0, plug#load()
  1038. AssertEqual 0, plug#load('non-existent-plugin')
  1039. AssertEqual 0, plug#load('non-existent-plugin', 'another-non-existent-plugin')
  1040. AssertEqual 1, plug#load('xxx')
  1041. AssertEqual 0, plug#load('xxx', 'non-existent-plugin')
  1042. AssertEqual 0, plug#load('non-existent-plugin', 'xxx')
  1043. Execute (plug#load - list argument (#638)):
  1044. redir => out
  1045. call plug#load(keys(g:plugs))
  1046. redir END
  1047. AssertEqual '', out
  1048. Execute (on: []):
  1049. call plug#begin()
  1050. Plug 'junegunn/rust.vim', { 'on': [] }
  1051. call plug#end()
  1052. PlugInstall
  1053. q
  1054. Execute (PlugStatus reports (not loaded)):
  1055. PlugStatus
  1056. AssertExpect 'not loaded', 1
  1057. q
  1058. Execute (plug#load to load it):
  1059. tabnew test.rs
  1060. " Vader will switch tab to [Vader-workbench] after Log
  1061. " Log &filetype
  1062. AssertEqual 1, plug#load('rust.vim')
  1063. AssertEqual 'rust', &filetype
  1064. q
  1065. Execute (PlugStatus should not contain (not loaded)):
  1066. PlugStatus
  1067. AssertExpect 'not loaded', 0
  1068. q
  1069. Execute (Load plugin from PlugStatus screen with L key in normal mode):
  1070. call ResetPlug()
  1071. unlet! g:yyy
  1072. call plug#begin()
  1073. Plug '$PLUG_FIXTURES/yyy', { 'on': [] }
  1074. call plug#end()
  1075. PlugStatus
  1076. AssertExpect 'not loaded', 1
  1077. Assert !exists('g:yyy'), 'yyy not loaded'
  1078. /not loaded
  1079. normal L
  1080. AssertExpect 'not loaded', 0
  1081. Assert exists('g:yyy'), 'yyy loaded'
  1082. q
  1083. Execute (Load plugin from PlugStatus screen with L key in visual mode):
  1084. call plug#begin()
  1085. Plug '$PLUG_FIXTURES/z1', { 'on': [] }
  1086. Plug '$PLUG_FIXTURES/z2', { 'for': [] }
  1087. call plug#end()
  1088. PlugStatus
  1089. AssertExpect 'not loaded', 2
  1090. Assert !exists('g:z1'), 'z1 not loaded'
  1091. Assert !exists('g:z2'), 'z2 not loaded'
  1092. normal ggVGL
  1093. AssertExpect 'not loaded', 0
  1094. Assert exists('g:z1'), 'z1 loaded'
  1095. Assert exists('g:z2'), 'z2 loaded'
  1096. q
  1097. **********************************************************************
  1098. ~ g:plug_window
  1099. **********************************************************************
  1100. Execute (Open plug window in a new tab):
  1101. " Without g:plug_window, plug window is open on the left split
  1102. let tabnr = tabpagenr()
  1103. PlugStatus
  1104. AssertEqual tabnr, tabpagenr()
  1105. AssertEqual 1, winnr()
  1106. " PlugStatus again inside the window should not change the view
  1107. normal S
  1108. AssertEqual tabnr, tabpagenr()
  1109. AssertEqual 1, winnr()
  1110. q
  1111. " Define g:plug_window so that plug window is open in a new tab
  1112. let g:plug_window = 'tabnew'
  1113. PlugStatus
  1114. AssertNotEqual tabnr, tabpagenr()
  1115. " PlugStatus again inside the window should not change the view
  1116. let tabnr = tabpagenr()
  1117. normal S
  1118. AssertEqual tabnr, tabpagenr()
  1119. q
  1120. unlet g:plug_window tabnr
  1121. **********************************************************************
  1122. ~ g:plug_url_format
  1123. **********************************************************************
  1124. Execute (Using g:plug_url_format):
  1125. let prev_plug_url_format = g:plug_url_format
  1126. call plug#begin()
  1127. let g:plug_url_format = 'git@bitbucket.org:%s.git'
  1128. Plug 'junegunn/seoul256.vim'
  1129. let g:plug_url_format = 'git@bitsocket.org:%s.git'
  1130. Plug 'vim-scripts/beauty256'
  1131. AssertEqual 'git@bitbucket.org:junegunn/seoul256.vim.git', g:plugs['seoul256.vim'].uri
  1132. AssertEqual 'git@bitsocket.org:vim-scripts/beauty256.git', g:plugs['beauty256'].uri
  1133. let g:plug_url_format = prev_plug_url_format
  1134. **********************************************************************
  1135. ~ U
  1136. **********************************************************************
  1137. Execute (Plug block):
  1138. call plug#begin()
  1139. Plug 'junegunn/vim-easy-align'
  1140. Plug 'junegunn/vim-emoji'
  1141. call plug#end()
  1142. Execute (Update plugin with U key in normal mode):
  1143. PlugStatus
  1144. /emoji
  1145. normal U
  1146. Log getline(1, '$')
  1147. AssertExpect 'Updated', 1
  1148. AssertExpect 'vim-emoji', 1
  1149. AssertExpect 'vim-easy-align', 0
  1150. AssertExpect! '[=]', 1
  1151. " From PlugInstall screen
  1152. PlugInstall
  1153. /easy-align
  1154. normal U
  1155. AssertExpect 'Updated', 1
  1156. AssertExpect 'vim-emoji', 0
  1157. AssertExpect 'vim-easy-align', 1
  1158. AssertExpect! '[=]', 1
  1159. q
  1160. Execute (Update plugins with U key in visual mode):
  1161. silent! call RmRf(g:plugs['vim-easy-align'].dir)
  1162. PlugStatus
  1163. normal VGU
  1164. Log getline(1, '$')
  1165. AssertExpect 'Updated', 1
  1166. AssertExpect 'vim-emoji', 1
  1167. AssertExpect 'vim-easy-align', 1
  1168. AssertExpect! '[==]', 1
  1169. " From PlugUpdate screen
  1170. normal VGU
  1171. Log getline(1, '$')
  1172. AssertExpect 'Updated', 1
  1173. AssertExpect 'vim-emoji', 1
  1174. AssertExpect 'vim-easy-align', 1
  1175. AssertExpect! '[==]', 1
  1176. q
  1177. **********************************************************************
  1178. Execute (plug#begin should expand env vars):
  1179. AssertNotEqual '$HOME/.emacs/plugged', expand('$HOME/.emacs/plugged')
  1180. call plug#begin('$HOME/.emacs/plugged')
  1181. AssertEqual expand('$HOME/.emacs/plugged'), g:plug_home
  1182. **********************************************************************
  1183. Execute (Plug directory with comma):
  1184. call plug#begin(g:temp_plugged . '/p,l,u,g,g,e,d')
  1185. Plug 'junegunn/vim-emoji'
  1186. call plug#end()
  1187. Log &rtp
  1188. PlugInstall
  1189. q
  1190. let found = filter(split(globpath(&rtp, 'README.md'), '\n'), 'v:val =~ ","')
  1191. Log found
  1192. AssertEqual 1, len(found)
  1193. unlet found
  1194. **********************************************************************
  1195. Execute (Strict load order):
  1196. let g:total_order = []
  1197. call ReloadPlug()
  1198. call plug#begin()
  1199. Plug '$PLUG_FIXTURES/xxx'
  1200. Plug '$PLUG_FIXTURES/yyy', { 'for': ['xxx'] }
  1201. call plug#end()
  1202. call EnsureLoaded()
  1203. setf xxx
  1204. Log 'Case 1: ' . &rtp
  1205. AssertEqual ['yyy/ftdetect', 'yyy/after/ftdetect', 'xxx/ftdetect', 'xxx/after/ftdetect'], g:total_order[0:3]
  1206. Assert index(g:total_order, 'xxx/plugin') < index(g:total_order, 'yyy/plugin')
  1207. Assert index(g:total_order, 'xxx/after/plugin') < index(g:total_order, 'yyy/after/plugin')
  1208. let len = len(split(&rtp, ','))
  1209. let g:total_order = []
  1210. call ReloadPlug()
  1211. call plug#begin()
  1212. Plug '$PLUG_FIXTURES/xxx', { 'for': ['xxx'] }
  1213. Plug '$PLUG_FIXTURES/yyy'
  1214. call plug#end()
  1215. call EnsureLoaded()
  1216. set rtp^=manually-prepended
  1217. set rtp+=manually-appended
  1218. setf xxx
  1219. Log 'Case 2: ' . &rtp
  1220. AssertEqual 'manually-prepended', split(&rtp, ',')[3]
  1221. AssertEqual 'manually-appended', split(&rtp, ',')[-4]
  1222. AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect', 'yyy/ftdetect', 'yyy/after/ftdetect'], g:total_order[0:3]
  1223. Assert index(g:total_order, 'yyy/plugin') < index(g:total_order, 'xxx/plugin')
  1224. Assert index(g:total_order, 'yyy/after/plugin') < index(g:total_order, 'xxx/after/plugin')
  1225. AssertEqual len + 2, len(split(&rtp, ','))
  1226. let g:total_order = []
  1227. call ReloadPlug()
  1228. set rtp^=manually-prepended
  1229. set rtp+=manually-appended
  1230. call plug#begin()
  1231. Plug '$PLUG_FIXTURES/xxx', { 'for': ['xxx'] }
  1232. Plug '$PLUG_FIXTURES/yyy', { 'for': ['xxx'] }
  1233. call plug#end()
  1234. call EnsureLoaded()
  1235. setf xxx
  1236. Log 'Case 3: ' . &rtp
  1237. AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect', 'yyy/ftdetect', 'yyy/after/ftdetect'], g:total_order[0:3]
  1238. Assert index(g:total_order, 'xxx/plugin') < index(g:total_order, 'yyy/plugin')
  1239. Assert index(g:total_order, 'xxx/after/plugin') < index(g:total_order, 'yyy/after/plugin')
  1240. AssertEqual len + 2, len(split(&rtp, ','))
  1241. **********************************************************************
  1242. Execute (PlugClean should not try to remove unmanaged plugins inside g:plug_home):
  1243. call plug#begin('$PLUG_FIXTURES')
  1244. Plug '$PLUG_FIXTURES/ftplugin-msg', { 'for': [] }
  1245. Plug '$PLUG_FIXTURES/fzf'
  1246. Plug '$PLUG_FIXTURES/xxx'
  1247. Plug '$PLUG_FIXTURES/yyy'
  1248. Plug '$PLUG_FIXTURES/cant-delete'
  1249. call plug#end()
  1250. " Remove z1, z2
  1251. PlugClean!
  1252. AssertExpect '^\~ ', 2
  1253. AssertExpect 'Already clean', 0
  1254. PlugClean!
  1255. AssertExpect '^\~ ', 0
  1256. AssertExpect 'Already clean', 1
  1257. q
  1258. **********************************************************************
  1259. Execute (PlugSnapshot / #154 issues with paths containing spaces):
  1260. let $TMPDIR = '/tmp'
  1261. call plug#begin('$TMPDIR/plug with spaces')
  1262. Plug 'junegunn/vim-easy-align'
  1263. Plug 'junegunn/seoul256.vim'
  1264. call plug#end()
  1265. PlugClean!
  1266. PlugInstall
  1267. call plug#load('vim-easy-align') " Should properly handle paths with spaces
  1268. PlugSnapshot
  1269. AssertEqual '" Generated by vim-plug', getline(1)
  1270. AssertEqual 0, stridx(getline(6), "silent! let g:plugs['seoul256.vim'].commit = '")
  1271. AssertEqual 0, stridx(getline(7), "silent! let g:plugs['vim-easy-align'].commit = '")
  1272. AssertEqual 'vim', &filetype
  1273. call delete(g:plug_home.'/snapshot.vim')
  1274. execute 'PlugSnapshot' escape(g:plug_home.'/snapshot.vim', ' ')
  1275. AssertEqual 'vim', &filetype
  1276. AssertEqual 'snapshot.vim', fnamemodify(expand('%'), ':t')
  1277. q
  1278. Execute(PlugSnapshot! to overwrite existing file):
  1279. call writefile(['foobar'], g:plug_home.'/snapshot.vim')
  1280. AssertEqual 'foobar', readfile(g:plug_home.'/snapshot.vim')[0]
  1281. execute 'PlugSnapshot!' escape(g:plug_home.'/snapshot.vim', ' ')
  1282. AssertEqual '" Generated by vim-plug', readfile(g:plug_home.'/snapshot.vim')[0]
  1283. q
  1284. **********************************************************************
  1285. Execute (#221 Shallow-clone and tag option):
  1286. call plug#begin(g:temp_plugged)
  1287. Plug 'junegunn/goyo.vim'
  1288. call plug#end()
  1289. PlugInstall
  1290. execute 'cd' g:plugs['goyo.vim'].dir
  1291. Assert len(split(system('git log --oneline'), '\n')) == 1
  1292. Assert filereadable('.git/shallow')
  1293. Plug 'junegunn/goyo.vim', { 'tag': '1.5.3' }
  1294. PlugUpdate
  1295. q
  1296. Assert len(split(system('git log --oneline'), '\n')) > 1
  1297. Assert system('git describe --tag') =~ '^1.5.3'
  1298. Assert !filereadable('.git/shallow')
  1299. cd -
  1300. Execute (#221 Shallow-clone disabled by g:plug_shallow = 0):
  1301. call plug#begin(g:temp_plugged)
  1302. call plug#end()
  1303. PlugClean!
  1304. let g:plug_shallow = 0
  1305. call plug#begin(g:temp_plugged)
  1306. Plug 'junegunn/goyo.vim'
  1307. call plug#end()
  1308. PlugInstall
  1309. q
  1310. execute 'cd' g:plugs['goyo.vim'].dir
  1311. Assert len(split(system('git log --oneline'), '\n')) > 1, 'not shallow'
  1312. Assert !filereadable('.git/shallow'), 'not shallow'
  1313. cd -
  1314. unlet g:plug_shallow
  1315. Execute (#221 Shallow-clone disabled by tag):
  1316. call plug#begin(g:temp_plugged)
  1317. call plug#end()
  1318. PlugClean!
  1319. call plug#begin(g:temp_plugged)
  1320. Plug 'junegunn/goyo.vim', { 'tag': '1.5.3' }
  1321. call plug#end()
  1322. Assert !isdirectory(g:plugs['goyo.vim'].dir)
  1323. PlugInstall
  1324. Assert isdirectory(g:plugs['goyo.vim'].dir)
  1325. q
  1326. execute 'cd' g:plugs['goyo.vim'].dir
  1327. Assert system('git describe --tag') =~ '^1.5.3'
  1328. Assert len(split(system('git log --oneline'), '\n')) > 1
  1329. Assert !filereadable('.git/shallow')
  1330. cd -
  1331. Execute (Commit hash support):
  1332. " Get goyo back to master
  1333. call plug#begin(g:temp_plugged)
  1334. Plug 'junegunn/goyo.vim'
  1335. call plug#end()
  1336. PlugUpdate
  1337. call plug#begin(g:temp_plugged)
  1338. Plug 'junegunn/goyo.vim', { 'commit': 'ffffffff' }
  1339. Plug 'junegunn/vim-emoji', { 'commit': '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a' }
  1340. call plug#end()
  1341. PlugUpdate
  1342. Log getline(1, '$')
  1343. AssertEqual 'x goyo.vim:', getline(5)
  1344. AssertEqual ' fatal: invalid reference: ffffffff', getline(6)
  1345. AssertEqual 0, stridx(getline(7), '- vim-emoji: HEAD is now at 9db7fcf')
  1346. let hash = system(printf('cd %s && git rev-parse HEAD', g:plugs['vim-emoji'].dir))[:-2]
  1347. AssertEqual '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a', hash
  1348. " Validate error formatting
  1349. PlugStatus
  1350. Log getline(1, '$')
  1351. AssertEqual ['Finished. 1 error(s).',
  1352. \'[==]',
  1353. \'',
  1354. \'x goyo.vim:'], getline(1, 4)
  1355. Assert getline(5) =~ ' Invalid HEAD (expected: fffffff, actual: [0-9a-f]\{7})'
  1356. AssertEqual [' PlugUpdate required.',
  1357. \'- vim-emoji: OK'], getline(6, '$')
  1358. " PlugDiff should show pending updates for vim-emoji
  1359. PlugDiff
  1360. Log getline(1, '$')
  1361. AssertEqual '0 plugin(s) updated. 1 plugin(s) have pending updates.', getline(1)
  1362. Assert !empty(mapcheck('o'))
  1363. Assert empty(mapcheck('X'))
  1364. Assert !empty(mapcheck("\<cr>"))
  1365. " Nor in PlugSnapshot output
  1366. PlugSnapshot
  1367. Log getline(1, '$')
  1368. AssertEqual 8, line('$')
  1369. q
  1370. Execute (Commit hash support - cleared):
  1371. call plug#begin(g:temp_plugged)
  1372. Plug 'junegunn/goyo.vim'
  1373. Plug 'junegunn/vim-emoji'
  1374. call plug#end()
  1375. PlugInstall
  1376. let hash = system(printf('cd %s && git rev-parse HEAD', g:plugs['vim-emoji'].dir))[:-2]
  1377. AssertEqual '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a', hash
  1378. PlugUpdate
  1379. let hash = system(printf('cd %s && git rev-parse HEAD', g:plugs['vim-emoji'].dir))[:-2]
  1380. AssertNotEqual '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a', hash
  1381. q
  1382. Execute (#371 - 'as' option):
  1383. call plug#begin()
  1384. Plug 'jg/goyo.vim'
  1385. Plug 'junegunn/goyo.vim', {'as': 'yogo'}
  1386. call plug#end()
  1387. AssertEqual ['goyo.vim', 'yogo'], sort(keys(g:plugs))
  1388. Log g:plugs
  1389. Assert g:plugs.yogo.dir =~# '/yogo/$'
  1390. call plug#begin()
  1391. Plug 'junegunn/goyo.vim', {'as': 'yogo', 'dir': '/tmp/vim-plug-test/gogo'}
  1392. call plug#end()
  1393. AssertEqual ['yogo'], sort(keys(g:plugs))
  1394. AssertEqual '/tmp/vim-plug-test/gogo/', g:plugs.yogo.dir
  1395. Execute (#427 - Tag option with wildcard (requires git 1.9.2 or above)):
  1396. if str2nr(split(split(system('git --version'))[-1], '\.')[0]) < 2
  1397. Log 'tag with wildcard requires git 1.9.2 or above'
  1398. else
  1399. call plug#begin()
  1400. Plug 'junegunn/vim-easy-align', { 'tag': '2.9.*' }
  1401. call plug#end()
  1402. PlugInstall!
  1403. Log getline(1, '$')
  1404. AssertExpect! '- Latest tag for 2.9.* -> 2.9.7 (vim-easy-align)', 1
  1405. q
  1406. AssertEqual '2.9.7', GitTag('vim-easy-align')
  1407. endif
  1408. Execute (#530 - Comparison of compatible git URIs):
  1409. " .git suffix
  1410. Assert CompareURI('https://github.com/junegunn/vim-plug.git', 'https://github.com/junegunn/vim-plug')
  1411. " user@
  1412. Assert CompareURI('https://github.com/junegunn/vim-plug.git', 'https://user@github.com/junegunn/vim-plug.git')
  1413. " git::@
  1414. Assert CompareURI('https://github.com/junegunn/vim-plug.git', 'https://git::@github.com/junegunn/vim-plug.git')
  1415. " https and ssh
  1416. Assert CompareURI('https://github.com/junegunn/vim-plug.git', 'git@github.com:junegunn/vim-plug.git')
  1417. " file://
  1418. Assert CompareURI('file:///tmp/vim-plug', '/tmp/vim-plug')
  1419. Assert CompareURI('file:///tmp/vim-plug', '/tmp/vim-plug/')
  1420. Execute (#530 - Comparison of incompatible git URIs):
  1421. " Different hostname
  1422. Assert !CompareURI('https://github.com/junegunn/vim-plug.git', 'https://bitbucket.com/junegunn/vim-plug.git')
  1423. " Different repository
  1424. Assert !CompareURI('https://github.com/junegunn/vim-plug.git', 'https://github.com/junegunn/emacs-plug.git')
  1425. " Different port
  1426. Assert !CompareURI('https://github.com/junegunn/vim-plug.git', 'https://github.com:12345/junegunn/vim-plug.git')
  1427. Execute (#532 - Reuse plug window):
  1428. call plug#begin()
  1429. Plug 'junegunn/goyo.vim'
  1430. call plug#end()
  1431. PlugInstall
  1432. call system(printf('cd "%s" && git commit --allow-empty -m "dummy"', g:plugs['goyo.vim'].dir))
  1433. PlugDiff
  1434. AssertEqual 1, winnr(), 'Current window is #1 after PlugDiff (but is '.winnr().')'
  1435. AssertEqual 2, winnr('$'), 'Two windows after PlugDiff (but got '.winnr('$').')'
  1436. " Open preview window
  1437. execute "normal ]]jo"
  1438. AssertEqual 2, winnr(), 'Current window is #2 after opening preview (but is '.winnr().')'
  1439. AssertEqual 3, winnr('$'), 'Three windows with preview (but got '.winnr('$').')'
  1440. " Move plug window to the right
  1441. wincmd L
  1442. AssertEqual 3, winnr(), 'Current window is #3 after moving window (but is '.winnr().')'
  1443. AssertEqual 3, winnr('$'), 'Three windows after moving window (but got '.winnr('$').')'
  1444. " Reuse plug window. Preview window is closed.
  1445. PlugStatus
  1446. AssertEqual 2, winnr(), 'Current window is #2 after PlugStatus (but is '.winnr().')'
  1447. AssertEqual 2, winnr('$'), 'Three windows after PlugStatus (but got '.winnr('$').')'
  1448. q
  1449. Execute (#766 - Allow cloning into an empty directory):
  1450. let d = '/tmp/vim-plug-test/goyo-already'
  1451. call system('rm -rf ' . d)
  1452. call mkdir(d)
  1453. call plug#begin()
  1454. Plug 'junegunn/goyo.vim', { 'dir': d }
  1455. call plug#end()
  1456. PlugInstall
  1457. AssertExpect! '[=]', 1
  1458. q
  1459. unlet d
  1460. Execute (#982 - PlugClean should report when directories cannot be removed):
  1461. call plug#begin('$PLUG_FIXTURES')
  1462. Plug '$PLUG_FIXTURES/ftplugin-msg', { 'for': [] }
  1463. Plug '$PLUG_FIXTURES/fzf'
  1464. Plug '$PLUG_FIXTURES/xxx'
  1465. Plug '$PLUG_FIXTURES/yyy'
  1466. call plug#end()
  1467. " Fail to remove cant-delete
  1468. PlugClean!
  1469. AssertEqual 'Removed 0 directories. Failed to remove 1 directories.', getline(4)
  1470. AssertExpect '^x ', 1
  1471. q
  1472. " Delete tmp but fail to remove cant-delete
  1473. call mkdir(expand('$PLUG_FIXTURES/tmp'))
  1474. PlugClean!
  1475. AssertEqual 'Removed 1 directories. Failed to remove 1 directories.', getline(4)
  1476. AssertExpect '^x ', 1
  1477. AssertExpect '^\~ ', 1
  1478. q