workflow.vader 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582
  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 (Reuse Plug window in another tab):
  347. let tabnr = tabpagenr()
  348. PlugDiff
  349. tab new new-tab
  350. set buftype=nofile
  351. PlugUpdate
  352. normal D
  353. AssertExpect '^- ', 1
  354. normal q
  355. AssertEqual tabnr, tabpagenr()
  356. normal! gt
  357. q
  358. unlet tabnr
  359. Execute (contd. PlugDiff should not show inverted history):
  360. " Additional PlugUpdate to clear diff
  361. PlugUpdate
  362. PlugDiff
  363. Log getline(1, '$')
  364. " Checking out older revisions
  365. for repo in values(g:plugs)
  366. call system(printf('cd %s && git reset HEAD^ --hard', shellescape(repo.dir)))
  367. endfor
  368. unlet repo
  369. " PlugDiff should not report the changes i.e. git log --left-only
  370. PlugDiff
  371. Log getline(1, '$')
  372. AssertEqual '0 plugin(s) updated.', getline(1)
  373. q
  374. **********************************************************************
  375. ~ PlugDiff to see the pending changes
  376. **********************************************************************
  377. Execute (PlugDiff):
  378. call plug#begin()
  379. call plug#end()
  380. PlugClean!
  381. call plug#begin()
  382. Plug 'file://'.expand('$PLUG_FIXTURES').'/xxx'
  383. Plug 'file://'.expand('$PLUG_FIXTURES').'/yyy'
  384. call plug#end()
  385. PlugInstall
  386. Log getline(1, '$')
  387. call system('cd "$PLUG_FIXTURES/xxx" && git commit --allow-empty -m update-xxx && git tag -f xxx')
  388. call system('cd "$PLUG_FIXTURES/yyy" && git tag -f yyy && git commit --allow-empty -m update-yyy && git tag -f zzz')
  389. let g:plugs.yyy.tag = 'yyy'
  390. PlugUpdate
  391. Log getline(1, '$')
  392. PlugDiff
  393. " 1 plugin(s) updated. 1 plugin(s) have pending updates.
  394. " [==]
  395. "
  396. " Last update:
  397. " ------------
  398. "
  399. " - xxx:
  400. " 166cfff (tag: xxx) update-xxx (1 second ago)
  401. "
  402. " Pending updates:
  403. " ----------------
  404. "
  405. " - yyy: (tag: yyy)
  406. " c0a064b (tag: zzz) update-yyy (1 second ago)
  407. "
  408. Log getline(1, '$')
  409. AssertEqual 15, line('$')
  410. AssertEqual '1 plugin(s) updated. 1 plugin(s) have pending updates.', getline(1)
  411. AssertEqual '[==]', getline(2)
  412. AssertEqual '- yyy: (tag: yyy)', getline(13)
  413. Assert getline(8) =~ '(tag: xxx)'
  414. Assert getline(14) =~ '(tag: zzz)'
  415. Assert !empty(mapcheck('o'))
  416. Assert !empty(mapcheck('X'))
  417. Assert !empty(mapcheck("\<cr>"))
  418. q
  419. **********************************************************************
  420. ~ On-demand loading / Partial installation/update ~
  421. **********************************************************************
  422. Execute (Trying to execute on-demand commands when plugin is not installed):
  423. call ReloadPlug()
  424. call plug#begin()
  425. Plug 'junegunn/vim-easy-align', { 'on': ['EasyAlign', 'LiveEasyAlign!'] }
  426. call plug#end()
  427. Assert exists(':EasyAlign')
  428. Assert exists(':LiveEasyAlign')
  429. AssertThrows EasyAlign
  430. AssertThrows LiveEasyAlign
  431. Assert !exists(':EasyAlign')
  432. Assert !exists(':LiveEasyAlign')
  433. Execute (New set of plugins):
  434. call ReloadPlug()
  435. call plug#begin()
  436. Plug 'junegunn/vim-fnr'
  437. Plug 'junegunn/vim-pseudocl'
  438. Plug 'junegunn/vim-easy-align', { 'on': 'EasyAlign' }
  439. Plug 'junegunn/vim-redis', { 'for': 'redis' }
  440. let user_autocmd = {}
  441. autocmd! User vim-fnr let user_autocmd.fnr = 1
  442. autocmd! User vim-easy-align let user_autocmd.easy_align = 1
  443. autocmd! User vim-redis let user_autocmd.redis = 1
  444. call plug#end()
  445. Execute (Check commands):
  446. Assert !exists(':FNR'), 'FNR command should not be found'
  447. Assert !exists(':RedisExecute'), 'RedisExecute command should not be found'
  448. Assert empty(user_autocmd)
  449. Execute (Partial PlugInstall):
  450. PlugInstall vim-fnr vim-easy-align
  451. AssertExpect 'vim-fnr', 1
  452. q
  453. PlugInstall vim-fnr vim-easy-align 1
  454. AssertExpect 'vim-fnr', 1
  455. AssertExpect 'vim-easy-align', 1
  456. AssertEqual g:first_rtp, split(&rtp, ',')[0]
  457. AssertEqual g:last_rtp, split(&rtp, ',')[-1]
  458. q
  459. Given (Unaligned code):
  460. a=1
  461. aa=2
  462. Execute (Check installed plugins):
  463. call EnsureLoaded()
  464. Assert exists(':FNR'), 'FNR command should be found'
  465. Assert !exists(':RedisExecute'), 'RedisExecute command still should not be found'
  466. Assert exists(':EasyAlign'), 'EasyAlign command should be found'
  467. %EasyAlign=
  468. Expect (Aligned code):
  469. a = 1
  470. aa = 2
  471. Then (autocmd executed):
  472. Assert user_autocmd.easy_align
  473. AssertEqual 1, len(user_autocmd)
  474. Given:
  475. Execute (Partial PlugUpdate):
  476. PlugUpdate vim-redis
  477. q
  478. Execute (On-demand loading based on filetypes):
  479. Assert !exists(':RedisExecute'), 'RedisExecute command still should not be found'
  480. set ft=redis
  481. Assert exists(':RedisExecute'), 'RedisExecute command is now found'
  482. Assert user_autocmd.redis
  483. AssertEqual 2, len(user_autocmd)
  484. autocmd! User
  485. unlet user_autocmd
  486. **********************************************************************
  487. ~ Local (unmanaged) plugins
  488. **********************************************************************
  489. Execute (Add unmanaged plugin):
  490. let fzf = expand('$PLUG_FIXTURES/fzf')
  491. call RmRf(fzf)
  492. Log fzf
  493. call plug#begin()
  494. Plug fzf, { 'on': 'SomeCommand' }
  495. call plug#end()
  496. " Check uri field
  497. Assert !has_key(g:plugs.fzf, 'uri'), 'Should not have uri field'
  498. " Check dir field
  499. AssertEqual fzf.'/', g:plugs.fzf.dir
  500. " Trailing slashes and backslashes should be stripped
  501. for suffix in ['///', '/\/\/']
  502. call plug#begin()
  503. Plug fzf.suffix, { 'on': 'SomeCommand' }
  504. call plug#end()
  505. " Check dir field
  506. AssertEqual fzf.'/', g:plugs.fzf.dir
  507. endfor
  508. Execute (Plug block for following tests):
  509. call plug#begin()
  510. Plug 'junegunn/vim-easy-align'
  511. Plug fzf, { 'on': 'SomeCommand' }
  512. call plug#end()
  513. " Remove plugins from previous tests
  514. PlugClean!
  515. q
  516. Execute (PlugInstall will only install vim-easy-align):
  517. PlugInstall
  518. Log getline(1, '$')
  519. AssertExpect 'fzf', 0
  520. q
  521. Execute (PlugUpdate will only update vim-easy-align):
  522. PlugUpdate
  523. Log getline(1, '$')
  524. AssertExpect 'fzf', 0
  525. q
  526. Execute (PlugClean should not care about unmanaged plugins):
  527. PlugClean
  528. Log getline(1, '$')
  529. AssertExpect 'fzf', 0
  530. q
  531. Execute (PlugStatus should point out that the plugin is missing):
  532. PlugStatus
  533. Log getline(1, '$')
  534. AssertExpect 'x fzf', 1
  535. AssertExpect 'Not found', 1
  536. q
  537. Execute (Deploy unmanaged plugin):
  538. Assert !exists(':FZF'), ':FZF command should not exist'
  539. call RmRf(fzf)
  540. Log system(printf('cp -r "/tmp/vim-plug-test/fzf" "%s"', fzf))
  541. Execute (PlugUpdate still should not care):
  542. PlugUpdate
  543. Log getline(1, '$')
  544. AssertExpect 'fzf', 0
  545. q
  546. Execute (PlugStatus with no error):
  547. PlugStatus
  548. Log getline(1, '$')
  549. AssertExpect 'x fzf', 0
  550. AssertExpect 'Not found', 0
  551. q
  552. Execute (Check &rtp after SomeCommand):
  553. Log &rtp
  554. Assert &rtp !~ 'fzf'
  555. silent! SomeCommand
  556. Assert &rtp =~ 'fzf'
  557. AssertEqual g:first_rtp, split(&rtp, ',')[0]
  558. AssertEqual g:last_rtp, split(&rtp, ',')[-1]
  559. Execute (Common parent):
  560. call plug#begin()
  561. Plug 'junegunn/vim-pseudocl'
  562. Plug 'junegunn/vim-fnr'
  563. Plug 'junegunn/vim-oblique'
  564. call plug#end()
  565. PlugInstall
  566. Log getline(1, '$')
  567. AssertExpect! '[===]', 1
  568. q
  569. unlet fzf
  570. **********************************************************************
  571. ~ Frozen plugins
  572. **********************************************************************
  573. - We've decided to install plugins that are frozen: see #113
  574. Execute (Frozen plugin are not ~~installed nor~~ updated):
  575. " Remove plugins
  576. call plug#begin()
  577. call plug#end()
  578. PlugClean!
  579. q
  580. " vim-easy-align is not found, so it will be installed even though it's frozen
  581. call plug#begin()
  582. Plug 'junegunn/vim-easy-align', { 'frozen': 1 }
  583. call plug#end()
  584. PlugInstall
  585. AssertEqual 1, len(filter(getline(1, '$'), 'v:val =~ "vim-easy-align"'))
  586. q
  587. " Remove plugins again
  588. call plug#begin()
  589. call plug#end()
  590. PlugClean!
  591. q
  592. " PlugUpdate will do the same
  593. call plug#begin()
  594. Plug 'junegunn/vim-easy-align', { 'frozen': 1 }
  595. call plug#end()
  596. PlugInstall
  597. AssertEqual 1, len(filter(getline(1, '$'), 'v:val =~ "vim-easy-align"'))
  598. q
  599. " Since vim-easy-align already exists, PlugInstall or PlugUpdate will skip it
  600. redir => out
  601. silent PlugInstall
  602. redir END
  603. Assert out =~ 'No plugin to install'
  604. redir => out
  605. silent PlugUpdate
  606. redir END
  607. Assert out =~ 'No plugin to update'
  608. Execute (But you can still install it if the name is given as the argument):
  609. PlugInstall vim-easy-align
  610. Log getline(1, '$')
  611. AssertEqual 1, len(filter(getline(1, '$'), 'v:val =~ "vim-easy-align"'))
  612. q
  613. PlugUpdate vim-easy-align
  614. Log getline(1, '$')
  615. AssertEqual 1, len(filter(getline(1, '$'), 'v:val =~ "vim-easy-align"'))
  616. q
  617. **********************************************************************
  618. ~ Retry
  619. **********************************************************************
  620. Execute (Retry failed tasks):
  621. call plug#begin()
  622. Plug 'junegunn/vim-easy-align'
  623. Plug 'junegunn/aaaaaaaaaaaaaa'
  624. call plug#end()
  625. PlugInstall
  626. Log getline(1, '$')
  627. AssertExpect 'x aaa', 1
  628. AssertExpect '- vim-easy-align', 1
  629. normal R
  630. Log getline(1, '$')
  631. AssertExpect 'x aaa', 1
  632. AssertExpect '- vim-easy-align', 0
  633. AssertExpect! '[x]', 1
  634. q
  635. call plug#begin()
  636. Plug 'junegunn/vim-easy-align'
  637. Plug 'junegunn/aaaaaaaaaaaaaa'
  638. Plug 'junegunn/bbbbbbbbbbbbbb'
  639. Plug 'junegunn/cccccccccccccc'
  640. call plug#end()
  641. " Ruby installer
  642. PlugUpdate
  643. normal R
  644. AssertExpect '- vim-easy-align', 0
  645. AssertExpect! '[xxx]', 1
  646. q
  647. " Vim installer
  648. PlugUpdate 1
  649. normal R
  650. AssertExpect '- vim-easy-align', 0
  651. AssertExpect! '[xxx]', 1
  652. q
  653. **********************************************************************
  654. ~ Post-update hook (`do` option)
  655. **********************************************************************
  656. Execute (Cleanup):
  657. call plug#begin()
  658. call plug#end()
  659. PlugClean!
  660. q
  661. Execute (On install):
  662. call plug#begin()
  663. Plug 'junegunn/vim-easy-align', { 'do': 'touch installed' }
  664. Plug 'junegunn/vim-pseudocl'
  665. Plug 'junegunn/seoul256.vim'
  666. Plug 'junegunn/goyo.vim'
  667. Plug 'yous/subsubmodule'
  668. call plug#end()
  669. silent PlugInstall
  670. q
  671. Assert filereadable(g:plugs['vim-easy-align'].dir.'/installed'),
  672. \ 'vim-easy-align/installed should exist'
  673. Assert !filereadable(g:plugs['vim-pseudocl'].dir.'/installed'),
  674. \ 'vim-pseudocl/installed should not exist'
  675. AssertEqual ' ', system('cd '.g:plugs['subsubmodule'].dir.' && git submodule status')[0],
  676. \ 'subsubmodule/subsubmodule should be initialized'
  677. Execute (On update):
  678. call plug#begin()
  679. Plug 'junegunn/vim-easy-align', { 'do': 'touch updated' }
  680. Plug 'junegunn/vim-pseudocl', { 'do': 'touch updated' }
  681. Plug 'junegunn/seoul256.vim'
  682. Plug 'junegunn/goyo.vim'
  683. Plug 'yous/subsubmodule'
  684. call plug#end()
  685. " New commits on remote
  686. call system('cd /tmp/vim-plug-test/junegunn/vim-pseudocl && git commit --allow-empty -m "update"')
  687. silent PlugUpdate
  688. Log getline(1, '$')
  689. q
  690. Assert !filereadable(g:plugs['vim-easy-align'].dir.'/updated'),
  691. \ 'vim-easy-align/updated should not exist'
  692. Assert filereadable(g:plugs['vim-pseudocl'].dir.'/updated'),
  693. \ 'vim-pseudocl/updated should exist'
  694. Execute (When already installed):
  695. call plug#begin()
  696. Plug 'junegunn/vim-easy-align', { 'do': 'touch installed2' }
  697. Plug 'junegunn/vim-pseudocl', { 'commit': '7f8cd78' }
  698. Plug 'junegunn/seoul256.vim', { 'branch': 'no-t_co' }
  699. Plug 'junegunn/goyo.vim', { 'tag': '1.5.3' }
  700. Plug 'yous/subsubmodule'
  701. call plug#end()
  702. PlugInstall
  703. q
  704. Assert !filereadable(g:plugs['vim-easy-align'].dir.'/installed2'),
  705. \ 'vim-easy-align/installed2 should not exist'
  706. AssertNotEqual '7f8cd78cb1fe52185b98b16a3749811f0cc508af', GitCommit('vim-pseudocl')
  707. AssertNotEqual 'no-t_co', GitBranch('seoul256.vim')
  708. AssertNotEqual '1.5.3', GitTag('goyo.vim')
  709. Execute (PlugInstall!):
  710. silent PlugInstall!
  711. q
  712. Assert filereadable(g:plugs['vim-easy-align'].dir.'/installed2'),
  713. \ 'vim-easy-align/installed2 should exist'
  714. AssertEqual '7f8cd78cb1fe52185b98b16a3749811f0cc508af', GitCommit('vim-pseudocl')
  715. AssertEqual 'no-t_co', GitBranch('seoul256.vim')
  716. AssertEqual '1.5.3', GitTag('goyo.vim')
  717. Execute (When submodules are not initialized):
  718. call system(printf('cd %s && git submodule deinit subsubmodule', g:plugs['subsubmodule'].dir))
  719. silent PlugInstall!
  720. q
  721. AssertEqual ' ', system(printf('cd %s && git submodule status', g:plugs['subsubmodule'].dir))[0],
  722. \ 'subsubmodule/subsubmodule should be initialized'
  723. Execute (When already updated):
  724. call plug#begin()
  725. Plug 'junegunn/vim-easy-align', { 'do': 'touch updated2' }
  726. Plug 'junegunn/vim-pseudocl', { 'commit': 'dd507ca' }
  727. Plug 'junegunn/seoul256.vim', { 'branch': 'master' }
  728. Plug 'junegunn/goyo.vim', { 'tag': '1.6.0' }
  729. Plug 'yous/subsubmodule'
  730. call plug#end()
  731. PlugUpdate
  732. q
  733. Assert !filereadable(g:plugs['vim-easy-align'].dir.'/updated2'),
  734. \ 'vim-easy-align/updated2 should not exist'
  735. AssertEqual 'dd507ca0d5f3fdf0d522558cc5ecffdabf824469', GitCommit('vim-pseudocl')
  736. AssertEqual 'master', GitBranch('seoul256.vim')
  737. AssertEqual '1.6.0', GitTag('goyo.vim')
  738. Execute (PlugUpdate!):
  739. silent PlugUpdate!
  740. q
  741. Assert filereadable(g:plugs['vim-easy-align'].dir.'/updated2'),
  742. \ 'vim-easy-align/updated2 should exist'
  743. Execute (When submodules are not initialized):
  744. call system(printf('cd %s && git submodule deinit subsubmodule', g:plugs['subsubmodule'].dir))
  745. ^ #481 submodule update should use standard shell
  746. let sh = &shell
  747. set sh=/bin/echo
  748. silent PlugUpdate!
  749. let &shell = sh
  750. unlet sh
  751. q
  752. AssertEqual ' ', system(printf('cd %s && git submodule status', g:plugs['subsubmodule'].dir))[0],
  753. \ 'subsubmodule/subsubmodule should be initialized'
  754. Execute (Using Funcref):
  755. function! PlugUpdated(info)
  756. call system('touch '. a:info.name . a:info.status . a:info.force . len(a:info))
  757. endfunction
  758. call plug#begin()
  759. Plug 'junegunn/vim-easy-align', { 'do': function('PlugUpdated') }
  760. Plug 'junegunn/vim-pseudocl', { 'do': function('PlugUpdated') }
  761. call plug#end()
  762. call system('cd /tmp/vim-plug-test/junegunn/vim-easy-align && git commit --allow-empty -m "update"')
  763. call system('cd '.g:plugs['vim-easy-align'].dir.' && git reset --hard HEAD^')
  764. call RmRf(g:plugs['vim-pseudocl'].dir)
  765. PlugUpdate
  766. Log getline(1, '$')
  767. q
  768. Assert filereadable(g:plugs['vim-easy-align'].dir.'/vim-easy-alignupdated03'),
  769. \ 'vim-easy-align/vim-easy-alignupdated03 should exist'
  770. Assert filereadable(g:plugs['vim-pseudocl'].dir.'/vim-pseudoclinstalled03'),
  771. \ 'vim-pseudocl/vim-pseudoclinstalled03 should exist'
  772. call RmRf(g:plugs['vim-pseudocl'].dir)
  773. PlugInstall!
  774. q
  775. Assert filereadable(g:plugs['vim-easy-align'].dir.'/vim-easy-alignunchanged13'),
  776. \ 'vim-easy-align/vim-easy-alignunchanged13 should exist'
  777. Assert filereadable(g:plugs['vim-pseudocl'].dir.'/vim-pseudoclinstalled13'),
  778. \ 'vim-pseudocl/vim-pseudoclinstalled13 should exist'
  779. call system('cd '.g:plugs['vim-easy-align'].dir.' && git reset --hard HEAD^')
  780. PlugUpdate!
  781. q
  782. Assert filereadable(g:plugs['vim-easy-align'].dir.'/vim-easy-alignupdated13'),
  783. \ 'vim-easy-align/vim-easy-alignupdated13 should exist'
  784. Assert filereadable(g:plugs['vim-pseudocl'].dir.'/vim-pseudoclunchanged13'),
  785. \ 'vim-pseudocl/vim-pseudoclunchanged13 should exist'
  786. Execute (Post-update hook output; success and failure):
  787. call plug#begin()
  788. Plug 'junegunn/vim-easy-align', { 'do': 'xxx-non-existent-command-xxx' }
  789. Plug 'junegunn/vim-pseudocl', { 'do': 'true' }
  790. call plug#end()
  791. silent PlugInstall! 1
  792. AssertEqual '- Post-update hook for vim-pseudocl ... OK', getline(5)
  793. AssertEqual 'x Post-update hook for vim-easy-align ... Exit status: 127', getline(6)
  794. q
  795. Execute (Post-update hook output; invalid type or funcref):
  796. call plug#begin()
  797. Plug 'junegunn/vim-easy-align', { 'do': 1 }
  798. Plug 'junegunn/vim-pseudocl', { 'do': function('call') }
  799. call plug#end()
  800. silent PlugInstall! 1
  801. AssertEqual 'x Post-update hook for vim-pseudocl ... Vim(call):E119: Not enough arguments for function: call', getline(5)
  802. AssertEqual 'x Post-update hook for vim-easy-align ... Invalid hook type', getline(6)
  803. q
  804. Execute (Should not run when failed to update):
  805. call plug#begin()
  806. Plug 'junegunn/vim-easy-align', { 'do': 'touch failed' }
  807. Plug 'junegunn/vim-pseudocl', { 'do': 'touch not-failed' }
  808. call plug#end()
  809. " Invalid remote URL
  810. call system(printf('cd %s && git remote set-url origin xxx', g:plugs['vim-easy-align'].dir))
  811. " New commits on remote
  812. call system('cd /tmp/vim-plug-test/junegunn/vim-easy-align && git commit --allow-empty -m "update"')
  813. call system('cd /tmp/vim-plug-test/junegunn/vim-pseudocl && git commit --allow-empty -m "update"')
  814. silent PlugUpdate
  815. Log getline(1, '$')
  816. q
  817. Assert !filereadable(g:plugs['vim-easy-align'].dir.'/failed'),
  818. \ 'vim-easy-align/failed should not exist'
  819. Assert filereadable(g:plugs['vim-pseudocl'].dir.'/not-failed'),
  820. \ 'vim-pseudocl/not-failed should exist'
  821. Execute (Vim command with : prefix):
  822. call plug#begin()
  823. Plug 'junegunn/vim-pseudocl', { 'do': ':call setline(2, 12345)' }
  824. call plug#end()
  825. PlugInstall!
  826. Log getline(1, '$')
  827. AssertEqual '12345', getline(2)
  828. q
  829. Execute (Vim command with : prefix closing the window):
  830. call plug#begin()
  831. Plug 'junegunn/vim-pseudocl', { 'do': ':close' }
  832. call plug#end()
  833. redir => out
  834. PlugInstall!
  835. redir END
  836. Assert out =~ 'vim-plug was terminated'
  837. Assert out =~ 'of vim-pseudocl'
  838. Execute (Invalid vim command in post-update hook):
  839. call plug#begin()
  840. Plug 'junegunn/vim-pseudocl', { 'do': ':nosuchcommand' }
  841. call plug#end()
  842. PlugInstall!
  843. Log getline(1, '$')
  844. AssertExpect! 'x Post-update hook for vim-pseudocl ... Vim:E492: Not an editor command: nosuchcommand', 1
  845. q
  846. **********************************************************************
  847. ~ Overriding `dir`
  848. **********************************************************************
  849. Execute (Using custom dir):
  850. call plug#begin()
  851. Plug 'junegunn/vim-easy-align'
  852. call plug#end()
  853. Assert isdirectory(g:plugs['vim-easy-align'].dir)
  854. call RmRf('/tmp/vim-plug-test/easy-align')
  855. call plug#begin()
  856. Plug 'junegunn/vim-easy-align', { 'dir': '/tmp/vim-plug-test/easy-align' }
  857. call plug#end()
  858. AssertEqual '/tmp/vim-plug-test/easy-align/', g:plugs['vim-easy-align'].dir
  859. PlugClean!
  860. Assert !isdirectory(g:plugs['vim-easy-align'].dir)
  861. q
  862. PlugInstall
  863. q
  864. Assert isdirectory(g:plugs['vim-easy-align'].dir)
  865. **********************************************************************
  866. ~ On-demand loading load order
  867. **********************************************************************
  868. Before (Clear global vars):
  869. let g:xxx = []
  870. set rtp-=$PLUG_FIXTURES/xxx/
  871. set rtp-=$PLUG_FIXTURES/xxx/after
  872. Execute (Immediate loading):
  873. call ReloadPlug()
  874. call plug#begin()
  875. Plug '$PLUG_FIXTURES/xxx'
  876. call plug#end()
  877. " FIXME:
  878. " Different result when Vader is run from commandline with `-c` option
  879. Log g:xxx
  880. if has('vim_starting')
  881. AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect'], g:xxx
  882. else
  883. AssertEqual ['xxx/plugin', 'xxx/after/plugin', 'xxx/ftdetect', 'xxx/after/ftdetect'], g:xxx
  884. endif
  885. Execute (Command-based on-demand loading):
  886. call ReloadPlug()
  887. call plug#begin()
  888. Plug '$PLUG_FIXTURES/xxx', { 'on': 'XXX' }
  889. call plug#end()
  890. AssertEqual [], g:xxx
  891. silent! XXX
  892. AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect', 'xxx/plugin', 'xxx/after/plugin'], g:xxx
  893. setf xxx
  894. 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
  895. Execute (Filetype-based on-demand loading):
  896. call ReloadPlug()
  897. call plug#begin()
  898. Plug '$PLUG_FIXTURES/xxx', { 'for': 'xxx' }
  899. Plug '$PLUG_FIXTURES/yyy', { 'for': 'yyy' }
  900. call plug#end()
  901. AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect'], g:xxx
  902. setf xxx
  903. 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
  904. " syntax/xxx.vim and after/syntax/xxx.vim should not be loaded (#410)
  905. setf yyy
  906. AssertEqual ['yyy/ftdetect', 'yyy/after/ftdetect', 'yyy/plugin', 'yyy/after/plugin'], g:yyy
  907. Before:
  908. **********************************************************************
  909. ~ plug#helptags()
  910. **********************************************************************
  911. Execute (plug#helptags):
  912. silent! call delete(expand('$PLUG_FIXTURES/xxx/doc/tags'))
  913. Assert !filereadable(expand('$PLUG_FIXTURES/xxx/doc/tags'))
  914. AssertEqual 1, plug#helptags()
  915. Assert filereadable(expand('$PLUG_FIXTURES/xxx/doc/tags'))
  916. **********************************************************************
  917. ~ Manual loading
  918. **********************************************************************
  919. Execute (plug#load - invalid arguments):
  920. AssertEqual 0, plug#load()
  921. AssertEqual 0, plug#load('non-existent-plugin')
  922. AssertEqual 0, plug#load('non-existent-plugin', 'another-non-existent-plugin')
  923. AssertEqual 1, plug#load('xxx')
  924. AssertEqual 0, plug#load('xxx', 'non-existent-plugin')
  925. AssertEqual 0, plug#load('non-existent-plugin', 'xxx')
  926. Execute (on: []):
  927. call plug#begin()
  928. Plug 'junegunn/rust.vim', { 'on': [] }
  929. call plug#end()
  930. PlugInstall
  931. q
  932. Execute (PlugStatus reports (not loaded)):
  933. PlugStatus
  934. AssertExpect 'not loaded', 1
  935. q
  936. Execute (plug#load to load it):
  937. tabnew test.rs
  938. " Vader will switch tab to [Vader-workbench] after Log
  939. " Log &filetype
  940. AssertEqual 1, plug#load('rust.vim')
  941. AssertEqual 'rust', &filetype
  942. q
  943. Execute (PlugStatus should not contain (not loaded)):
  944. PlugStatus
  945. AssertExpect 'not loaded', 0
  946. q
  947. Execute (Load plugin from PlugStatus screen with L key in normal mode):
  948. call ResetPlug()
  949. unlet! g:yyy
  950. call plug#begin()
  951. Plug '$PLUG_FIXTURES/yyy', { 'on': [] }
  952. call plug#end()
  953. PlugStatus
  954. AssertExpect 'not loaded', 1
  955. Assert !exists('g:yyy'), 'yyy not loaded'
  956. /not loaded
  957. normal L
  958. AssertExpect 'not loaded', 0
  959. Assert exists('g:yyy'), 'yyy loaded'
  960. q
  961. Execute (Load plugin from PlugStatus screen with L key in visual mode):
  962. call plug#begin()
  963. Plug '$PLUG_FIXTURES/z1', { 'on': [] }
  964. Plug '$PLUG_FIXTURES/z2', { 'for': [] }
  965. call plug#end()
  966. PlugStatus
  967. AssertExpect 'not loaded', 2
  968. Assert !exists('g:z1'), 'z1 not loaded'
  969. Assert !exists('g:z2'), 'z2 not loaded'
  970. normal ggVGL
  971. AssertExpect 'not loaded', 0
  972. Assert exists('g:z1'), 'z1 loaded'
  973. Assert exists('g:z2'), 'z2 loaded'
  974. q
  975. **********************************************************************
  976. ~ g:plug_window
  977. **********************************************************************
  978. Execute (Open plug window in a new tab):
  979. " Without g:plug_window, plug window is open on the left split
  980. let tabnr = tabpagenr()
  981. PlugStatus
  982. AssertEqual tabnr, tabpagenr()
  983. AssertEqual 1, winnr()
  984. " PlugStatus again inside the window should not change the view
  985. normal S
  986. AssertEqual tabnr, tabpagenr()
  987. AssertEqual 1, winnr()
  988. q
  989. " Define g:plug_window so that plug window is open in a new tab
  990. let g:plug_window = 'tabnew'
  991. PlugStatus
  992. AssertNotEqual tabnr, tabpagenr()
  993. " PlugStatus again inside the window should not change the view
  994. let tabnr = tabpagenr()
  995. normal S
  996. AssertEqual tabnr, tabpagenr()
  997. q
  998. unlet g:plug_window tabnr
  999. **********************************************************************
  1000. ~ g:plug_url_format
  1001. **********************************************************************
  1002. Execute (Using g:plug_url_format):
  1003. let prev_plug_url_format = g:plug_url_format
  1004. call plug#begin()
  1005. let g:plug_url_format = 'git@bitbucket.org:%s.git'
  1006. Plug 'junegunn/seoul256.vim'
  1007. let g:plug_url_format = 'git@bitsocket.org:%s.git'
  1008. Plug 'beauty256'
  1009. AssertEqual 'git@bitbucket.org:junegunn/seoul256.vim.git', g:plugs['seoul256.vim'].uri
  1010. AssertEqual 'git@bitsocket.org:vim-scripts/beauty256.git', g:plugs['beauty256'].uri
  1011. let g:plug_url_format = prev_plug_url_format
  1012. **********************************************************************
  1013. ~ U
  1014. **********************************************************************
  1015. Execute (Plug block):
  1016. call plug#begin()
  1017. Plug 'junegunn/vim-easy-align'
  1018. Plug 'junegunn/vim-emoji'
  1019. call plug#end()
  1020. Execute (Update plugin with U key in normal mode):
  1021. PlugStatus
  1022. /emoji
  1023. normal U
  1024. Log getline(1, '$')
  1025. AssertExpect 'Updated', 1
  1026. AssertExpect 'vim-emoji', 1
  1027. AssertExpect 'vim-easy-align', 0
  1028. AssertExpect! '[=]', 1
  1029. " From PlugInstall screen
  1030. PlugInstall
  1031. /easy-align
  1032. normal U
  1033. AssertExpect 'Updated', 1
  1034. AssertExpect 'vim-emoji', 0
  1035. AssertExpect 'vim-easy-align', 1
  1036. AssertExpect! '[=]', 1
  1037. q
  1038. Execute (Update plugins with U key in visual mode):
  1039. silent! call RmRf(g:plugs['vim-easy-align'].dir)
  1040. PlugStatus
  1041. normal VGU
  1042. Log getline(1, '$')
  1043. AssertExpect 'Updated', 1
  1044. AssertExpect 'vim-emoji', 1
  1045. AssertExpect 'vim-easy-align', 1
  1046. AssertExpect! '[==]', 1
  1047. " From PlugUpdate screen
  1048. normal VGU
  1049. Log getline(1, '$')
  1050. AssertExpect 'Updated', 1
  1051. AssertExpect 'vim-emoji', 1
  1052. AssertExpect 'vim-easy-align', 1
  1053. AssertExpect! '[==]', 1
  1054. q
  1055. **********************************************************************
  1056. Execute (plug#begin should expand env vars):
  1057. AssertNotEqual '$HOME/.emacs/plugged', expand('$HOME/.emacs/plugged')
  1058. call plug#begin('$HOME/.emacs/plugged')
  1059. AssertEqual expand('$HOME/.emacs/plugged'), g:plug_home
  1060. **********************************************************************
  1061. Execute (Plug directory with comma):
  1062. call plug#begin(g:temp_plugged . '/p,l,u,g,g,e,d')
  1063. Plug 'junegunn/vim-emoji'
  1064. call plug#end()
  1065. Log &rtp
  1066. PlugInstall
  1067. q
  1068. let found = filter(split(globpath(&rtp, 'README.md'), '\n'), 'v:val =~ ","')
  1069. Log found
  1070. AssertEqual 1, len(found)
  1071. unlet found
  1072. **********************************************************************
  1073. Execute (Strict load order):
  1074. let g:total_order = []
  1075. call ReloadPlug()
  1076. call plug#begin()
  1077. Plug '$PLUG_FIXTURES/xxx'
  1078. Plug '$PLUG_FIXTURES/yyy', { 'for': ['xxx'] }
  1079. call plug#end()
  1080. call EnsureLoaded()
  1081. setf xxx
  1082. Log 'Case 1: ' . &rtp
  1083. AssertEqual ['yyy/ftdetect', 'yyy/after/ftdetect', 'xxx/ftdetect', 'xxx/after/ftdetect'], g:total_order[0:3]
  1084. Assert index(g:total_order, 'xxx/plugin') < index(g:total_order, 'yyy/plugin')
  1085. Assert index(g:total_order, 'xxx/after/plugin') < index(g:total_order, 'yyy/after/plugin')
  1086. let len = len(split(&rtp, ','))
  1087. let g:total_order = []
  1088. call ReloadPlug()
  1089. call plug#begin()
  1090. Plug '$PLUG_FIXTURES/xxx', { 'for': ['xxx'] }
  1091. Plug '$PLUG_FIXTURES/yyy'
  1092. call plug#end()
  1093. call EnsureLoaded()
  1094. set rtp^=manually-prepended
  1095. set rtp+=manually-appended
  1096. setf xxx
  1097. Log 'Case 2: ' . &rtp
  1098. AssertEqual 'manually-prepended', split(&rtp, ',')[3]
  1099. AssertEqual 'manually-appended', split(&rtp, ',')[-4]
  1100. AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect', 'yyy/ftdetect', 'yyy/after/ftdetect'], g:total_order[0:3]
  1101. Assert index(g:total_order, 'yyy/plugin') < index(g:total_order, 'xxx/plugin')
  1102. Assert index(g:total_order, 'yyy/after/plugin') < index(g:total_order, 'xxx/after/plugin')
  1103. AssertEqual len + 2, len(split(&rtp, ','))
  1104. let g:total_order = []
  1105. call ReloadPlug()
  1106. set rtp^=manually-prepended
  1107. set rtp+=manually-appended
  1108. call plug#begin()
  1109. Plug '$PLUG_FIXTURES/xxx', { 'for': ['xxx'] }
  1110. Plug '$PLUG_FIXTURES/yyy', { 'for': ['xxx'] }
  1111. call plug#end()
  1112. call EnsureLoaded()
  1113. setf xxx
  1114. Log 'Case 3: ' . &rtp
  1115. AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect', 'yyy/ftdetect', 'yyy/after/ftdetect'], g:total_order[0:3]
  1116. Assert index(g:total_order, 'xxx/plugin') < index(g:total_order, 'yyy/plugin')
  1117. Assert index(g:total_order, 'xxx/after/plugin') < index(g:total_order, 'yyy/after/plugin')
  1118. AssertEqual len + 2, len(split(&rtp, ','))
  1119. **********************************************************************
  1120. Execute (PlugClean should not try to remove unmanaged plugins inside g:plug_home):
  1121. call plug#begin('$PLUG_FIXTURES')
  1122. Plug '$PLUG_FIXTURES/ftplugin-msg', { 'for': [] }
  1123. Plug '$PLUG_FIXTURES/fzf'
  1124. Plug '$PLUG_FIXTURES/xxx'
  1125. Plug '$PLUG_FIXTURES/yyy'
  1126. call plug#end()
  1127. " Remove z1, z2
  1128. PlugClean!
  1129. AssertExpect '^\~ ', 2
  1130. AssertExpect 'Already clean', 0
  1131. PlugClean!
  1132. AssertExpect '^\~ ', 0
  1133. AssertExpect 'Already clean', 1
  1134. q
  1135. **********************************************************************
  1136. Execute (PlugSnapshot / #154 issues with paths containing spaces):
  1137. let $TMPDIR = '/tmp'
  1138. call plug#begin('$TMPDIR/plug with spaces')
  1139. Plug 'junegunn/vim-easy-align'
  1140. Plug 'junegunn/seoul256.vim'
  1141. call plug#end()
  1142. PlugClean!
  1143. PlugInstall
  1144. call plug#load('vim-easy-align') " Should properly handle paths with spaces
  1145. PlugSnapshot
  1146. AssertEqual '" Generated by vim-plug', getline(1)
  1147. AssertEqual 0, stridx(getline(6), "silent! let g:plugs['seoul256.vim'].commit = '")
  1148. AssertEqual 0, stridx(getline(7), "silent! let g:plugs['vim-easy-align'].commit = '")
  1149. AssertEqual 'vim', &filetype
  1150. call delete(g:plug_home.'/snapshot.vim')
  1151. execute 'PlugSnapshot' escape(g:plug_home.'/snapshot.vim', ' ')
  1152. AssertEqual 'vim', &filetype
  1153. AssertEqual 'snapshot.vim', fnamemodify(expand('%'), ':t')
  1154. q
  1155. Execute(PlugSnapshot! to overwrite existing file):
  1156. call writefile(['foobar'], g:plug_home.'/snapshot.vim')
  1157. AssertEqual 'foobar', readfile(g:plug_home.'/snapshot.vim')[0]
  1158. execute 'PlugSnapshot!' escape(g:plug_home.'/snapshot.vim', ' ')
  1159. AssertEqual '" Generated by vim-plug', readfile(g:plug_home.'/snapshot.vim')[0]
  1160. q
  1161. **********************************************************************
  1162. Execute (#221 Shallow-clone and tag option):
  1163. call plug#begin(g:temp_plugged)
  1164. Plug 'junegunn/goyo.vim'
  1165. call plug#end()
  1166. PlugInstall
  1167. execute 'cd' g:plugs['goyo.vim'].dir
  1168. Assert len(split(system('git log --oneline'), '\n')) == 1
  1169. Assert filereadable('.git/shallow')
  1170. Plug 'junegunn/goyo.vim', { 'tag': '1.5.3' }
  1171. PlugUpdate
  1172. q
  1173. Assert len(split(system('git log --oneline'), '\n')) > 1
  1174. Assert system('git describe --tag') =~ '^1.5.3'
  1175. Assert !filereadable('.git/shallow')
  1176. cd -
  1177. Execute (#221 Shallow-clone disabled by g:plug_shallow = 0):
  1178. call plug#begin(g:temp_plugged)
  1179. call plug#end()
  1180. PlugClean!
  1181. let g:plug_shallow = 0
  1182. call plug#begin(g:temp_plugged)
  1183. Plug 'junegunn/goyo.vim'
  1184. call plug#end()
  1185. PlugInstall
  1186. q
  1187. execute 'cd' g:plugs['goyo.vim'].dir
  1188. Assert len(split(system('git log --oneline'), '\n')) > 1, 'not shallow'
  1189. Assert !filereadable('.git/shallow'), 'not shallow'
  1190. cd -
  1191. unlet g:plug_shallow
  1192. Execute (#221 Shallow-clone disabled by tag):
  1193. call plug#begin(g:temp_plugged)
  1194. call plug#end()
  1195. PlugClean!
  1196. call plug#begin(g:temp_plugged)
  1197. Plug 'junegunn/goyo.vim', { 'tag': '1.5.3' }
  1198. call plug#end()
  1199. Assert !isdirectory(g:plugs['goyo.vim'].dir)
  1200. PlugInstall
  1201. Assert isdirectory(g:plugs['goyo.vim'].dir)
  1202. q
  1203. execute 'cd' g:plugs['goyo.vim'].dir
  1204. Assert system('git describe --tag') =~ '^1.5.3'
  1205. Assert len(split(system('git log --oneline'), '\n')) > 1
  1206. Assert !filereadable('.git/shallow')
  1207. cd -
  1208. Execute (Commit hash support):
  1209. " Get goyo back to master
  1210. call plug#begin(g:temp_plugged)
  1211. Plug 'junegunn/goyo.vim'
  1212. call plug#end()
  1213. PlugUpdate
  1214. call plug#begin(g:temp_plugged)
  1215. Plug 'junegunn/goyo.vim', { 'commit': 'ffffffff' }
  1216. Plug 'junegunn/vim-emoji', { 'commit': '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a' }
  1217. call plug#end()
  1218. PlugUpdate
  1219. Log getline(1, '$')
  1220. AssertEqual 'x goyo.vim:', getline(5)
  1221. AssertEqual ' error: pathspec ''ffffffff'' did not match any file(s) known to git.', getline(6)
  1222. AssertEqual 0, stridx(getline(7), '- vim-emoji: HEAD is now at 9db7fcf...')
  1223. let hash = system(printf('cd %s && git rev-parse HEAD', g:plugs['vim-emoji'].dir))[:-2]
  1224. AssertEqual '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a', hash
  1225. " Validate error formatting
  1226. PlugStatus
  1227. Log getline(1, '$')
  1228. AssertEqual ['Finished. 1 error(s).',
  1229. \'[==]',
  1230. \'',
  1231. \'x goyo.vim:'], getline(1, 4)
  1232. Assert getline(5) =~ ' Invalid HEAD (expected: fffffff, actual: [0-9a-f]\{7})'
  1233. AssertEqual [' PlugUpdate required.',
  1234. \'- vim-emoji: OK'], getline(6, '$')
  1235. " PlugDiff should show pending updates for vim-emoji
  1236. PlugDiff
  1237. Log getline(1, '$')
  1238. AssertEqual '0 plugin(s) updated. 1 plugin(s) have pending updates.', getline(1)
  1239. Assert !empty(mapcheck('o'))
  1240. Assert empty(mapcheck('X'))
  1241. Assert !empty(mapcheck("\<cr>"))
  1242. " Nor in PlugSnapshot output
  1243. PlugSnapshot
  1244. Log getline(1, '$')
  1245. AssertEqual 8, line('$')
  1246. q
  1247. Execute (Commit hash support - cleared):
  1248. call plug#begin(g:temp_plugged)
  1249. Plug 'junegunn/goyo.vim'
  1250. Plug 'junegunn/vim-emoji'
  1251. call plug#end()
  1252. PlugInstall
  1253. let hash = system(printf('cd %s && git rev-parse HEAD', g:plugs['vim-emoji'].dir))[:-2]
  1254. AssertEqual '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a', hash
  1255. PlugUpdate
  1256. let hash = system(printf('cd %s && git rev-parse HEAD', g:plugs['vim-emoji'].dir))[:-2]
  1257. AssertNotEqual '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a', hash
  1258. q
  1259. Execute (#371 - 'as' option):
  1260. call plug#begin()
  1261. Plug 'jg/goyo.vim'
  1262. Plug 'junegunn/goyo.vim', {'as': 'yogo'}
  1263. call plug#end()
  1264. AssertEqual ['goyo.vim', 'yogo'], sort(keys(g:plugs))
  1265. Log g:plugs
  1266. Assert g:plugs.yogo.dir =~# '/yogo/$'
  1267. call plug#begin()
  1268. Plug 'junegunn/goyo.vim', {'as': 'yogo', 'dir': '/tmp/vim-plug-test/gogo'}
  1269. call plug#end()
  1270. AssertEqual ['yogo'], sort(keys(g:plugs))
  1271. AssertEqual '/tmp/vim-plug-test/gogo/', g:plugs.yogo.dir
  1272. Execute (#427 - Tag option with wildcard (requires git 1.9.2 or above)):
  1273. if str2nr(split(split(system('git --version'))[-1], '\.')[0]) < 2
  1274. Log 'tag with wildcard requires git 1.9.2 or above'
  1275. else
  1276. call plug#begin()
  1277. Plug 'junegunn/vim-easy-align', { 'tag': '2.9.*' }
  1278. call plug#end()
  1279. PlugInstall!
  1280. Log getline(1, '$')
  1281. AssertExpect! '- Latest tag for 2.9.* -> 2.9.7 (vim-easy-align)', 1
  1282. q
  1283. AssertEqual '2.9.7', GitTag('vim-easy-align')
  1284. endif
  1285. Execute (#530 - Comparison of compatible git URIs):
  1286. " .git suffix
  1287. Assert CompareURI('https://github.com/junegunn/vim-plug.git', 'https://github.com/junegunn/vim-plug')
  1288. " user@
  1289. Assert CompareURI('https://github.com/junegunn/vim-plug.git', 'https://user@github.com/junegunn/vim-plug.git')
  1290. " git::@
  1291. Assert CompareURI('https://github.com/junegunn/vim-plug.git', 'https://git::@github.com/junegunn/vim-plug.git')
  1292. " https and ssh
  1293. Assert CompareURI('https://github.com/junegunn/vim-plug.git', 'git@github.com:junegunn/vim-plug.git')
  1294. " file://
  1295. Assert CompareURI('file:///tmp/vim-plug', '/tmp/vim-plug')
  1296. Assert CompareURI('file:///tmp/vim-plug', '/tmp/vim-plug/')
  1297. Execute (#530 - Comparison of incompatible git URIs):
  1298. " Different hostname
  1299. Assert !CompareURI('https://github.com/junegunn/vim-plug.git', 'https://bitbucket.com/junegunn/vim-plug.git')
  1300. " Different repository
  1301. Assert !CompareURI('https://github.com/junegunn/vim-plug.git', 'https://github.com/junegunn/emacs-plug.git')
  1302. " Different port
  1303. Assert !CompareURI('https://github.com/junegunn/vim-plug.git', 'https://github.com:12345/junegunn/vim-plug.git')
  1304. Execute (#532 - Reuse plug window):
  1305. call plug#begin()
  1306. Plug 'junegunn/goyo.vim'
  1307. call plug#end()
  1308. PlugInstall
  1309. call system(printf('cd "%s" && git commit --allow-empty -m "dummy"', g:plugs['goyo.vim'].dir))
  1310. PlugDiff
  1311. AssertEqual 1, winnr()
  1312. AssertEqual 2, winnr('$')
  1313. " Open preview window
  1314. execute "normal ]]jo"
  1315. AssertEqual 2, winnr()
  1316. AssertEqual 3, winnr('$')
  1317. " Move plug window to the right
  1318. wincmd L
  1319. AssertEqual 3, winnr()
  1320. AssertEqual 3, winnr('$')
  1321. " Reuse plug window. Preview window is closed.
  1322. PlugStatus
  1323. AssertEqual 2, winnr()
  1324. AssertEqual 2, winnr('$')
  1325. q