diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/eval/executable_spec.lua | 25 | ||||
-rw-r--r-- | test/functional/options/defaults_spec.lua | 4 | ||||
-rw-r--r-- | test/unit/os/env_spec.lua | 20 |
3 files changed, 43 insertions, 6 deletions
diff --git a/test/functional/eval/executable_spec.lua b/test/functional/eval/executable_spec.lua index dd8861a07c..bcf5eba4eb 100644 --- a/test/functional/eval/executable_spec.lua +++ b/test/functional/eval/executable_spec.lua @@ -1,7 +1,6 @@ local helpers = require('test.functional.helpers')(after_each) -local eq, clear, execute, call, iswin, write_file = - helpers.eq, helpers.clear, helpers.execute, helpers.call, helpers.iswin, - helpers.write_file +local eq, clear, call, iswin, write_file = + helpers.eq, helpers.clear, helpers.call, helpers.iswin, helpers.write_file describe('executable()', function() before_each(clear) @@ -15,8 +14,28 @@ describe('executable()', function() eq(0, call('executable', 'no_such_file_exists_209ufq23f')) end) + it('sibling to nvim binary', function() + -- Some executable in build/bin/, *not* in $PATH nor CWD. + local sibling_exe = 'printargs-test' + -- Windows: siblings are in Nvim's "pseudo-$PATH". + local expected = iswin() and 1 or 0 + if iswin() then + print('XXXXXXXXXXXXXXXXXXXXXXXXX') + print(helpers.eval('$PATH')) + print('XXXXXXXXXXXXXXXXXXXXXXXXX') + -- $PATH on AppVeyor CI might be oversized, redefine it to a minimal one. + clear({env={PATH=[[C:\Windows\system32;C:\Windows]]}}) + print(helpers.eval('$PATH')) + print('XXXXXXXXXXXXXXXXXXXXXXXXX') + eq('arg1=lemon;arg2=sky;arg3=tree;', + call('system', sibling_exe..' lemon sky tree')) + end + eq(expected, call('executable', sibling_exe)) + end) + describe('exec-bit', function() setup(function() + clear() write_file('Xtest_not_executable', 'non-executable file') write_file('Xtest_executable', 'executable file (exec-bit set)') if not iswin() then -- N/A for Windows. diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua index caeca5e4e2..f3328886b5 100644 --- a/test/functional/options/defaults_spec.lua +++ b/test/functional/options/defaults_spec.lua @@ -96,6 +96,10 @@ describe('startup defaults', function() eq(meths.get_option('runtimepath'), meths.get_option('packpath')) end) end) + + it('v:progpath is set to the absolute path', function() + eq(eval("fnamemodify(v:progpath, ':p')"), eval('v:progpath')) + end) end) describe('XDG-based defaults', function() 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' |