diff options
author | ZyX <kp-pav@yandex.ru> | 2017-01-03 08:46:44 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2017-01-03 22:54:54 +0300 |
commit | 410d18ef5c24a325f4d63c9b01991015199194c2 (patch) | |
tree | a6e2acad16f222e35c2c0be979d0396cc1a17813 /test/functional/helpers.lua | |
parent | efe1476d4293170496f0e933a4d3c955f0559b03 (diff) | |
download | rneovim-410d18ef5c24a325f4d63c9b01991015199194c2.tar.gz rneovim-410d18ef5c24a325f4d63c9b01991015199194c2.tar.bz2 rneovim-410d18ef5c24a325f4d63c9b01991015199194c2.zip |
unittest: Allow multiple indirect includes
Works by saving all preprocessor defines and reusing them on each run. This also
saves NVIM_HEADER_H defines. Saving other defines is needed for defines like
`Map(foo, bar)` which are sometimes used to declare types or functions. Saving
types or function declarations is not needed because they are recorded as luajit
state.
Fixes #5857
Diffstat (limited to 'test/functional/helpers.lua')
-rw-r--r-- | test/functional/helpers.lua | 41 |
1 files changed, 3 insertions, 38 deletions
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index f3332cff4f..d67f225ed1 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -21,6 +21,9 @@ local nvim_argv = {nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N', local mpack = require('mpack') +local tmpname = global_helpers.tmpname +local uname = global_helpers.uname + -- Formulate a path to the directory containing nvim. We use this to -- help run test executables. It helps to keep the tests working, even -- when the build is not in the default location. @@ -334,44 +337,6 @@ local function write_file(name, text, dont_dedent) file:close() end --- Tries to get platform name from $SYSTEM_NAME, uname; fallback is "Windows". -local uname = (function() - local platform = nil - return (function() - if platform then - return platform - end - - platform = os.getenv("SYSTEM_NAME") - if platform then - return platform - end - - local status, f = pcall(io.popen, "uname -s") - if status then - platform = f:read("*l") - else - platform = 'Windows' - end - return platform - end) -end)() - -local function tmpname() - local fname = os.tmpname() - if uname() == 'Windows' and fname:sub(1, 2) == '\\s' then - -- In Windows tmpname() returns a filename starting with - -- special sequence \s, prepend $TEMP path - local tmpdir = os.getenv('TEMP') - return tmpdir..fname - elseif fname:match('^/tmp') and uname() == 'Darwin' then - -- In OS X /tmp links to /private/tmp - return '/private'..fname - else - return fname - end -end - local function source(code) local fname = tmpname() write_file(fname, code) |