workflow.vader 41 KB

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