workflow.vader 46 KB

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