workflow.vader 46 KB

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