workflow.vader 42 KB

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