diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2014-09-30 18:00:20 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-09-30 18:00:20 -0300 |
commit | afe7ba1e71f0fe43817ae9abac56c721c99f95c6 (patch) | |
tree | 187b69d95e4efc3d87c07c2ce9a4016bc0495114 /test/functional/helpers.lua | |
parent | 4b0f524915ee0e94bf9ca24fb1c1014921e610d5 (diff) | |
parent | 911acd22d8e8d6c3ef2341c604ecf820f8e322dd (diff) | |
download | rneovim-afe7ba1e71f0fe43817ae9abac56c721c99f95c6.tar.gz rneovim-afe7ba1e71f0fe43817ae9abac56c721c99f95c6.tar.bz2 rneovim-afe7ba1e71f0fe43817ae9abac56c721c99f95c6.zip |
Merge PR #1258 'Replace vroom by lua/busted for functional tests'
Diffstat (limited to 'test/functional/helpers.lua')
-rw-r--r-- | test/functional/helpers.lua | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua new file mode 100644 index 0000000000..2b9ddfbe3c --- /dev/null +++ b/test/functional/helpers.lua @@ -0,0 +1,84 @@ +local function clear() + nvim_command('call BeforeEachTest()') +end + +local function feed(...) + for _, v in ipairs({...}) do + nvim_feed(nvim_replace_termcodes(dedent(v))) + end +end + +local function rawfeed(...) + for _, v in ipairs({...}) do + nvim_feed(dedent(v), 'nt') + end +end + +local function insert(...) + nvim_feed('i', 'nt') + rawfeed(...) + nvim_feed(nvim_replace_termcodes('<ESC>'), 'nt') +end + +local function execute(...) + for _, v in ipairs({...}) do + if v:sub(1, 1) ~= '/' then + -- not a search command, prefix with colon + nvim_feed(':', 'nt') + end + nvim_feed(v, 'nt') + nvim_feed(nvim_replace_termcodes('<CR>'), 'nt') + end +end + +local function expect(contents, first, last, buffer_index) + return assert.are.same(dedent(contents), + buffer_slice(first, last, buffer_idx)) +end + +rawfeed([[:function BeforeEachTest() + set all& + redir => groups + silent augroup + redir END + for group in split(groups) + exe 'augroup '.group + autocmd! + augroup END + endfor + autocmd! + tabnew + let curbufnum = eval(bufnr('%')) + redir => buflist + silent ls! + redir END + let bufnums = [] + for buf in split(buflist, '\n') + let bufnum = eval(split(buf, '[ u]')[0]) + if bufnum != curbufnum + call add(bufnums, bufnum) + endif + endfor + if len(bufnums) > 0 + exe 'silent bwipeout! '.join(bufnums, ' ') + endif + silent tabonly + for k in keys(g:) + exe 'unlet g:'.k + endfor + filetype plugin indent off + mapclear + mapclear! + abclear + comclear +endfunction +]]) + +return { + clear = clear, + rawfeed = rawfeed, + insert = insert, + feed = feed, + execute = execute, + expect = expect +} |