workflow.vader 42 KB

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