test.vader 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. Execute (Initialize test environment):
  2. Save &rtp, g:plugs, g:plug_home, g:plug_window
  3. unlet! g:plugs g:plug_home g:plug_window
  4. let g:plug_url_format = 'file:///tmp/vim-plug-test/%s'
  5. let g:base_rtp = &rtp
  6. let g:first_rtp = split(&rtp, ',')[0]
  7. let g:last_rtp = split(&rtp, ',')[-1]
  8. let g:temp_plugged = tempname()
  9. if !exists('$PLUG_SRC')
  10. let $PLUG_SRC = globpath(&rtp, 'autoload/plug.vim')
  11. endif
  12. let $PLUG_TMP = fnamemodify(tempname(), ':h').'/plug.vim'
  13. " Temporarily patch plug.vim
  14. call system('cp "$PLUG_SRC" "$PLUG_TMP"')
  15. call writefile(extend(readfile($PLUG_TMP),
  16. \ ['function! ResetPlug()', 'let s:loaded = {}', 'endfunction',
  17. \ 'function! CompareURI(a, b)', 'return s:compare_git_uri(a:a, a:b)', 'endfunction']), $PLUG_TMP)
  18. set t_Co=256
  19. colo default
  20. pclose
  21. function! PlugStatusSorted()
  22. PlugStatus
  23. %y
  24. q
  25. normal! P
  26. %sort
  27. g/^$/d
  28. endfunction
  29. function! AssertExpect(bang, pat, cnt)
  30. let op = a:bang ? '==#' : '=~#'
  31. AssertEqual a:cnt, len(filter(getline(1, '$'), "v:val ".op." '".a:pat."'"))
  32. endfunction
  33. command! -nargs=+ -bang AssertExpect call AssertExpect('<bang>' == '!', <args>)
  34. function! EnsureLoaded()
  35. if has('vim_starting')
  36. runtime! plugin/**/*.vim
  37. endif
  38. endfunction
  39. function! RmRf(file)
  40. call system(printf('rm -rf "%s"', a:file))
  41. endfunction
  42. function! ReloadPlug()
  43. call ResetPlug()
  44. source $PLUG_TMP
  45. let &rtp = g:base_rtp
  46. endfunction
  47. function! GitBranch(repo)
  48. return system(printf('cd %s && git rev-parse --abbrev-ref HEAD', g:plugs[a:repo].dir))[:-2]
  49. endfunction
  50. function! GitTag(repo)
  51. return system(printf('cd %s && git describe --tags', g:plugs[a:repo].dir))[:-2]
  52. endfunction
  53. function! GitCommit(repo)
  54. return system(printf('cd %s && git rev-parse HEAD', g:plugs[a:repo].dir))[:-2]
  55. endfunction
  56. source $PLUG_TMP
  57. Execute (Print Interpreter Version):
  58. redir => out
  59. if has('ruby')
  60. silent! ruby puts 'Ruby: ' + RUBY_VERSION
  61. endif
  62. if has('python')
  63. silent! python import sys; svi = sys.version_info; print 'Python: {}.{}.{}'.format(svi[0], svi[1], svi[2])
  64. endif
  65. if has('python3')
  66. silent! python3 import sys; svi = sys.version_info; print('Python: {}.{}.{}'.format(svi[0], svi[1], svi[2]))
  67. endif
  68. redir END
  69. Log split(out, '\n')
  70. Include: workflow.vader
  71. Include: regressions.vader
  72. Execute (Cleanup):
  73. silent! call RmRf(g:temp_plugged)
  74. silent! unlet g:plugs g:plug_home g:plug_url_format
  75. silent! unlet g:temp_plugged g:first_rtp g:last_rtp g:base_rtp out
  76. silent! delf PlugStatusSorted
  77. silent! delf AssertExpect
  78. silent! delf PlugUpdated
  79. silent! delf EnsureLoaded
  80. silent! delf ReloadPlug
  81. silent! delc AssertExpect
  82. silent! unmap /
  83. silent! unmap ?
  84. call delete($PLUG_TMP)
  85. Restore