test/helpers: add 'vim_init' helper

- Initializes some global variables.
- Necessary for the buffer tests in PR #904.
This commit is contained in:
Nicolas Hillegeer 2014-07-12 19:37:38 +02:00
parent 32ddfec84f
commit c376cf46bf

View File

@ -97,6 +97,17 @@ cstr = ffi.typeof 'char[?]'
to_cstr = (string) ->
cstr (string.len string) + 1, string
export vim_init_called
-- initialize some global variables, this is still necessary to unit test
-- functions that rely on global state.
vim_init = ->
if vim_init_called ~= nil
return
-- import os_unix.h for mch_early_init(), which initializes some globals
os = cimport './src/nvim/os_unix.h'
os.mch_early_init!
vim_init_called = true
return {
cimport: cimport
cppimport: cppimport
@ -107,4 +118,5 @@ return {
lib: libnvim
cstr: cstr
to_cstr: to_cstr
vim_init: vim_init
}