diff options
author | Marco Hinz <mh.codebro@gmail.com> | 2015-11-17 15:49:12 +0100 |
---|---|---|
committer | Marco Hinz <mh.codebro@gmail.com> | 2015-11-23 13:57:21 +0100 |
commit | 32ecd75a16371fcfbe0cfc25eacaf041a755ac03 (patch) | |
tree | 80e848ba25993d30caa8556bbde6d7638e1d5ad9 /test/unit/os | |
parent | 4afd386276bb3c8cebb138b96e16c2b45de003ba (diff) | |
download | rneovim-32ecd75a16371fcfbe0cfc25eacaf041a755ac03.tar.gz rneovim-32ecd75a16371fcfbe0cfc25eacaf041a755ac03.tar.bz2 rneovim-32ecd75a16371fcfbe0cfc25eacaf041a755ac03.zip |
test/unit: clean up according to luacheck
Diffstat (limited to 'test/unit/os')
-rw-r--r-- | test/unit/os/env_spec.lua | 8 | ||||
-rw-r--r-- | test/unit/os/fs_spec.lua | 35 | ||||
-rw-r--r-- | test/unit/os/shell_spec.lua | 4 | ||||
-rw-r--r-- | test/unit/os/users_spec.lua | 8 |
4 files changed, 21 insertions, 34 deletions
diff --git a/test/unit/os/env_spec.lua b/test/unit/os/env_spec.lua index 8e18c599d9..e0e12a24f2 100644 --- a/test/unit/os/env_spec.lua +++ b/test/unit/os/env_spec.lua @@ -1,11 +1,9 @@ local helpers = require('test.unit.helpers') local cimport = helpers.cimport -local internalize = helpers.internalize local eq = helpers.eq local neq = helpers.neq local ffi = helpers.ffi -local lib = helpers.lib local cstr = helpers.cstr local to_cstr = helpers.to_cstr local NULL = helpers.NULL @@ -15,15 +13,15 @@ require('lfs') local env = cimport('./src/nvim/os/os.h') describe('env function', function() - function os_setenv(name, value, override) + local function os_setenv(name, value, override) return env.os_setenv((to_cstr(name)), (to_cstr(value)), override) end - function os_unsetenv(name, value, override) + local function os_unsetenv(name, _, _) return env.os_unsetenv((to_cstr(name))) end - function os_getenv(name) + local function os_getenv(name) local rval = env.os_getenv((to_cstr(name))) if rval ~= NULL then return ffi.string(rval) diff --git a/test/unit/os/fs_spec.lua b/test/unit/os/fs_spec.lua index c7a1f55b5d..5a1b9e3aa8 100644 --- a/test/unit/os/fs_spec.lua +++ b/test/unit/os/fs_spec.lua @@ -1,3 +1,6 @@ +local lfs = require('lfs') +local bit = require('bit') + local helpers = require('test.unit.helpers') local cimport = helpers.cimport @@ -6,16 +9,12 @@ local internalize = helpers.internalize local eq = helpers.eq local neq = helpers.neq local ffi = helpers.ffi -local lib = helpers.lib local cstr = helpers.cstr local to_cstr = helpers.to_cstr local OK = helpers.OK local FAIL = helpers.FAIL local NULL = helpers.NULL -require('lfs') -require('bit') - cimport('unistd.h') cimport('./src/nvim/os/shell.h') cimport('./src/nvim/option_defs.h') @@ -26,8 +25,7 @@ cppimport('sys/stat.h') cppimport('sys/fcntl.h') cppimport('sys/errno.h') -local len = 0 -local buf = "" +local buffer = "" local directory = nil local absolute_executable = nil local executable_name = nil @@ -85,24 +83,26 @@ describe('fs function', function() end) describe('os_dirname', function() + local length + local function os_dirname(buf, len) return fs.os_dirname(buf, len) end before_each(function() - len = (string.len(lfs.currentdir())) + 1 - buf = cstr(len, '') + length = (string.len(lfs.currentdir())) + 1 + buffer = cstr(length, '') end) it('returns OK and writes current directory into the buffer if it is large\n enough', function() - eq(OK, (os_dirname(buf, len))) - eq(lfs.currentdir(), (ffi.string(buf))) + eq(OK, (os_dirname(buffer, length))) + eq(lfs.currentdir(), (ffi.string(buffer))) end) -- What kind of other failing cases are possible? it('returns FAIL if the buffer is too small', function() - local buf = cstr((len - 1), '') - eq(FAIL, (os_dirname(buf, (len - 1)))) + local buf = cstr((length - 1), '') + eq(FAIL, (os_dirname(buf, (length - 1)))) end) end) @@ -213,15 +213,6 @@ describe('fs function', function() os_setperm('unit-test-directory/test.file', orig_test_file_perm) end) - local function os_getperm(filename) - local perm = fs.os_getperm((to_cstr(filename))) - return tonumber(perm) - end - - local function os_setperm(filename, perm) - return fs.os_setperm((to_cstr(filename)), perm) - end - local function os_fchown(filename, user_id, group_id) local fd = ffi.C.open(filename, 0) local res = fs.os_fchown(fd, user_id, group_id) @@ -611,7 +602,7 @@ describe('fs function', function() it('removes the given directory and returns 0', function() lfs.mkdir('unit-test-directory/new-dir') - eq(0, (os_rmdir('unit-test-directory/new-dir', mode))) + eq(0, os_rmdir('unit-test-directory/new-dir')) eq(false, (os_isdir('unit-test-directory/new-dir'))) end) end) diff --git a/test/unit/os/shell_spec.lua b/test/unit/os/shell_spec.lua index 20cfc17950..01deefab0c 100644 --- a/test/unit/os/shell_spec.lua +++ b/test/unit/os/shell_spec.lua @@ -17,7 +17,7 @@ local shell = helpers.cimport( './src/nvim/main.h', './src/nvim/misc1.h' ) -local ffi, eq, neq = helpers.ffi, helpers.eq, helpers.neq +local ffi, eq = helpers.ffi, helpers.eq local intern = helpers.internalize local to_cstr = helpers.to_cstr local NULL = ffi.cast('void *', 0) @@ -70,7 +70,7 @@ describe('shell functions', function() end) it ('returns non-zero exit code', function() - local status, output = os_system('exit 2') + local status = os_system('exit 2') eq(2, status) end) end) diff --git a/test/unit/os/users_spec.lua b/test/unit/os/users_spec.lua index df5d2365c6..236481e9e7 100644 --- a/test/unit/os/users_spec.lua +++ b/test/unit/os/users_spec.lua @@ -1,26 +1,24 @@ local helpers = require('test.unit.helpers') local cimport = helpers.cimport -local internalize = helpers.internalize local eq = helpers.eq local ffi = helpers.ffi local lib = helpers.lib -local cstr = helpers.cstr local NULL = helpers.NULL local OK = helpers.OK local FAIL = helpers.FAIL local users = cimport('./src/nvim/os/os.h', 'unistd.h') -function garray_new() +local function garray_new() return ffi.new('garray_T[1]') end -function garray_get_len(array) +local function garray_get_len(array) return array[0].ga_len end -function garray_get_item(array, index) +local function garray_get_item(array, index) return (ffi.cast('void **', array[0].ga_data))[index] end |