workflow.vader 51 KB

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