workflow.vader 46 KB

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