workflow.vader 40 KB

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