diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2017-03-12 10:52:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-12 10:52:13 +0100 |
commit | c8f0f8fea6e3170db0d68d61dd84f3c3ef9ee77c (patch) | |
tree | d993945c472a610a265baa79d714c6d32f149f14 /test/unit/tempfile_spec.lua | |
parent | b2b15e6e137d7be2b01bf2174791f36bd12981bd (diff) | |
parent | 48e7a83447c0a1a59a110b5ca9e712f560fd9e03 (diff) | |
download | rneovim-c8f0f8fea6e3170db0d68d61dd84f3c3ef9ee77c.tar.gz rneovim-c8f0f8fea6e3170db0d68d61dd84f3c3ef9ee77c.tar.bz2 rneovim-c8f0f8fea6e3170db0d68d61dd84f3c3ef9ee77c.zip |
Merge #6214 from ZyX-I/split-eval'/isolated-unittests
Run all unit tests in separate processes
Diffstat (limited to 'test/unit/tempfile_spec.lua')
-rw-r--r-- | test/unit/tempfile_spec.lua | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/test/unit/tempfile_spec.lua b/test/unit/tempfile_spec.lua index cf0d78b7a7..210518fe1f 100644 --- a/test/unit/tempfile_spec.lua +++ b/test/unit/tempfile_spec.lua @@ -1,58 +1,65 @@ -local lfs = require 'lfs' -local helpers = require 'test.unit.helpers' +local lfs = require('lfs') +local helpers = require('test.unit.helpers')(after_each) +local itp = helpers.gen_itp(it) -local os = helpers.cimport './src/nvim/os/os.h' -local tempfile = helpers.cimport './src/nvim/fileio.h' +local eq = helpers.eq +local neq = helpers.neq +local cimport = helpers.cimport +local child_call_once = helpers.child_call_once +local child_cleanup_once = helpers.child_cleanup_once + +local lib = cimport('./src/nvim/os/os.h', './src/nvim/fileio.h') describe('tempfile related functions', function() before_each(function() - tempfile.vim_deltempdir() - end) - after_each(function() - tempfile.vim_deltempdir() + local function vim_deltempdir() + lib.vim_deltempdir() + end + child_call_once(vim_deltempdir) + child_cleanup_once(vim_deltempdir) end) local vim_gettempdir = function() - return helpers.ffi.string(tempfile.vim_gettempdir()) + return helpers.ffi.string(lib.vim_gettempdir()) end describe('vim_gettempdir', function() - it('returns path to Neovim own temp directory', function() + itp('returns path to Neovim own temp directory', function() local dir = vim_gettempdir() assert.True(dir ~= nil and dir:len() > 0) -- os_file_is_writable returns 2 for a directory which we have rights -- to write into. - assert.equals(os.os_file_is_writable(helpers.to_cstr(dir)), 2) + eq(lib.os_file_is_writable(helpers.to_cstr(dir)), 2) for entry in lfs.dir(dir) do assert.True(entry == '.' or entry == '..') end end) - it('returns the same directory on each call', function() + itp('returns the same directory on each call', function() local dir1 = vim_gettempdir() local dir2 = vim_gettempdir() - assert.equals(dir1, dir2) + eq(dir1, dir2) end) end) describe('vim_tempname', function() local vim_tempname = function() - return helpers.ffi.string(tempfile.vim_tempname()) + return helpers.ffi.string(lib.vim_tempname()) end - it('generate name of non-existing file', function() + itp('generate name of non-existing file', function() local file = vim_tempname() assert.truthy(file) - assert.False(os.os_path_exists(file)) + assert.False(lib.os_path_exists(file)) end) - it('generate different names on each call', function() + itp('generate different names on each call', function() local fst = vim_tempname() local snd = vim_tempname() - assert.not_equals(fst, snd) + neq(fst, snd) end) - it('generate file name in Neovim own temp directory', function() + itp('generate file name in Neovim own temp directory', function() local dir = vim_gettempdir() local file = vim_tempname() assert.truthy(file:find('^' .. dir .. '[^/]*$')) |