aboutsummaryrefslogtreecommitdiff
path: root/test/unit
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-02-05 01:11:06 +0100
committerGitHub <noreply@github.com>2017-02-05 01:11:06 +0100
commitbb2f36d038ccb375249a078997f68840ddcc66ef (patch)
treea080d374a6b38607806ca553d00b2d3e8b590c36 /test/unit
parent3d3b1641d0cae3244c09d4602ab96d290dd0928a (diff)
parent18127f64c421a2c4da100a9e40d49c31a9a5170a (diff)
downloadrneovim-bb2f36d038ccb375249a078997f68840ddcc66ef.tar.gz
rneovim-bb2f36d038ccb375249a078997f68840ddcc66ef.tar.bz2
rneovim-bb2f36d038ccb375249a078997f68840ddcc66ef.zip
Merge #6038 from justinmk/win32-executable
win: executable()
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/os/env_spec.lua20
-rw-r--r--test/unit/os/fs_spec.lua15
2 files changed, 22 insertions, 13 deletions
diff --git a/test/unit/os/env_spec.lua b/test/unit/os/env_spec.lua
index 64bbaaa8c2..3c2cc164c9 100644
--- a/test/unit/os/env_spec.lua
+++ b/test/unit/os/env_spec.lua
@@ -14,15 +14,15 @@ local cimp = cimport('./src/nvim/os/os.h')
describe('env function', function()
local function os_setenv(name, value, override)
- return cimp.os_setenv((to_cstr(name)), (to_cstr(value)), override)
+ return cimp.os_setenv(to_cstr(name), to_cstr(value), override)
end
local function os_unsetenv(name, _, _)
- return cimp.os_unsetenv((to_cstr(name)))
+ return cimp.os_unsetenv(to_cstr(name))
end
local function os_getenv(name)
- local rval = cimp.os_getenv((to_cstr(name)))
+ local rval = cimp.os_getenv(to_cstr(name))
if rval ~= NULL then
return ffi.string(rval)
else
@@ -52,6 +52,20 @@ describe('env function', function()
end)
end)
+ describe('os_setenv_append_path', function()
+ it('appends /foo/bar to $PATH', function()
+ local original_path = os.getenv('PATH')
+ eq(true, cimp.os_setenv_append_path(to_cstr('/foo/bar/baz')))
+ eq(original_path..':/foo/bar', os.getenv('PATH'))
+ end)
+
+ it('returns false if `fname` is not absolute', function()
+ local original_path = os.getenv('PATH')
+ eq(false, cimp.os_setenv_append_path(to_cstr('foo/bar/baz')))
+ eq(original_path, os.getenv('PATH'))
+ end)
+ end)
+
describe('os_getenv', function()
it('reads an env variable', function()
local name = 'NEOVIM_UNIT_TEST_GETENV_1N'
diff --git a/test/unit/os/fs_spec.lua b/test/unit/os/fs_spec.lua
index 5d889d6e33..516fb5a7d1 100644
--- a/test/unit/os/fs_spec.lua
+++ b/test/unit/os/fs_spec.lua
@@ -23,7 +23,7 @@ cimport('./src/nvim/os/shell.h')
cimport('./src/nvim/option_defs.h')
cimport('./src/nvim/main.h')
cimport('./src/nvim/fileio.h')
-local fs = cimport('./src/nvim/os/os.h')
+local fs = cimport('./src/nvim/os/os.h', './src/nvim/path.h')
cppimport('sys/stat.h')
cppimport('fcntl.h')
cppimport('uv-errno.h')
@@ -77,11 +77,9 @@ describe('fs function', function()
lfs.link('test.file', 'unit-test-directory/test_link.file', true)
lfs.link('non_existing_file.file', 'unit-test-directory/test_broken_link.file', true)
- -- Since the tests are executed, they are called by an executable. We use
- -- that executable for several asserts.
+ -- The tests are invoked with an absolute path to `busted` executable.
absolute_executable = arg[0]
- -- Split absolute_executable into a directory and the actual file name for
- -- later usage.
+ -- Split the absolute_executable path into a directory and filename.
directory, executable_name = string.match(absolute_executable, '^(.*)/(.*)$')
end)
@@ -194,11 +192,8 @@ describe('fs function', function()
end)
it('returns the absolute path when given an executable inside $PATH', function()
- -- Since executable_name does not start with "./", the path will be
- -- selected from $PATH. Make sure the ends match, ignore the directories.
- local _, busted = string.match(absolute_executable, '^(.*)/(.*)$')
- local _, name = string.match(exe(executable_name), '^(.*)/(.*)$')
- eq(busted, name)
+ local fullpath = exe('ls')
+ eq(1, fs.path_is_absolute_path(to_cstr(fullpath)))
end)
it('returns the absolute path when given an executable relative to the current dir', function()