workflow.vader 38 KB

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