aboutsummaryrefslogtreecommitdiff
path: root/test/functional/eval
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/eval')
-rw-r--r--test/functional/eval/api_functions_spec.lua2
-rw-r--r--test/functional/eval/executable_spec.lua65
-rw-r--r--test/functional/eval/exepath_spec.lua14
-rw-r--r--test/functional/eval/let_spec.lua2
4 files changed, 71 insertions, 12 deletions
diff --git a/test/functional/eval/api_functions_spec.lua b/test/functional/eval/api_functions_spec.lua
index 6f440c7d82..40d06b599f 100644
--- a/test/functional/eval/api_functions_spec.lua
+++ b/test/functional/eval/api_functions_spec.lua
@@ -6,7 +6,7 @@ local clear, curbufmeths = helpers.clear, helpers.curbufmeths
local exc_exec, expect, eval = helpers.exc_exec, helpers.expect, helpers.eval
local insert = helpers.insert
-describe('api functions', function()
+describe('eval-API', function()
before_each(clear)
it("work", function()
diff --git a/test/functional/eval/executable_spec.lua b/test/functional/eval/executable_spec.lua
index c931b47221..6a95128a4d 100644
--- a/test/functional/eval/executable_spec.lua
+++ b/test/functional/eval/executable_spec.lua
@@ -1,6 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
-local eq, clear, call, iswin, write_file =
- helpers.eq, helpers.clear, helpers.call, helpers.iswin, helpers.write_file
+local eq, clear, call, iswin, write_file, command =
+ helpers.eq, helpers.clear, helpers.call, helpers.iswin, helpers.write_file,
+ helpers.command
describe('executable()', function()
before_each(clear)
@@ -48,18 +49,17 @@ describe('executable()', function()
end)
it('not set', function()
- local expected = iswin() and 1 or 0
- eq(expected, call('executable', 'Xtest_not_executable'))
- eq(expected, call('executable', './Xtest_not_executable'))
+ eq(0, call('executable', 'Xtest_not_executable'))
+ eq(0, call('executable', './Xtest_not_executable'))
end)
it('set, unqualified and not in $PATH', function()
- local expected = iswin() and 1 or 0
- eq(expected, call('executable', 'Xtest_executable'))
+ eq(0, call('executable', 'Xtest_executable'))
end)
it('set, qualified as a path', function()
- eq(1, call('executable', './Xtest_executable'))
+ local expected = iswin() and 0 or 1
+ eq(expected, call('executable', './Xtest_executable'))
end)
end)
end)
@@ -136,16 +136,48 @@ describe('executable() (Windows)', function()
eq(1, call('executable', '.\\test_executable_zzz'))
end)
- it('returns 1 for any existing filename', function()
+ it("with weird $PATHEXT", function()
+ clear({env={PATHEXT=';'}})
+ eq(0, call('executable', '.\\test_executable_zzz'))
+ clear({env={PATHEXT=';;;.zzz;;'}})
+ eq(1, call('executable', '.\\test_executable_zzz'))
+ end)
+
+ it("unqualified filename, Unix-style 'shell'", function()
clear({env={PATHEXT=''}})
+ command('set shell=sh')
for _,ext in ipairs(exts) do
eq(1, call('executable', 'test_executable_'..ext..'.'..ext))
end
eq(1, call('executable', 'test_executable_zzz.zzz'))
end)
- it('returns 1 for any existing path (backslashes)', function()
+ it("relative path, Unix-style 'shell' (backslashes)", function()
clear({env={PATHEXT=''}})
+ command('set shell=bash.exe')
+ for _,ext in ipairs(exts) do
+ eq(1, call('executable', '.\\test_executable_'..ext..'.'..ext))
+ eq(1, call('executable', './test_executable_'..ext..'.'..ext))
+ end
+ eq(1, call('executable', '.\\test_executable_zzz.zzz'))
+ eq(1, call('executable', './test_executable_zzz.zzz'))
+ end)
+
+ it('unqualified filename, $PATHEXT contains dot', function()
+ clear({env={PATHEXT='.;.zzz'}})
+ for _,ext in ipairs(exts) do
+ eq(1, call('executable', 'test_executable_'..ext..'.'..ext))
+ end
+ eq(1, call('executable', 'test_executable_zzz.zzz'))
+ clear({env={PATHEXT='.zzz;.'}})
+ for _,ext in ipairs(exts) do
+ eq(1, call('executable', 'test_executable_'..ext..'.'..ext))
+ end
+ eq(1, call('executable', 'test_executable_zzz.zzz'))
+ end)
+
+ it('relative path, $PATHEXT contains dot (backslashes)', function()
+ clear({env={PATHEXT='.;.zzz'}})
for _,ext in ipairs(exts) do
eq(1, call('executable', '.\\test_executable_'..ext..'.'..ext))
eq(1, call('executable', './test_executable_'..ext..'.'..ext))
@@ -153,4 +185,17 @@ describe('executable() (Windows)', function()
eq(1, call('executable', '.\\test_executable_zzz.zzz'))
eq(1, call('executable', './test_executable_zzz.zzz'))
end)
+
+ it('ignores case of extension', function()
+ clear({env={PATHEXT='.ZZZ'}})
+ eq(1, call('executable', 'test_executable_zzz.zzz'))
+ end)
+
+ it('relative path does not search $PATH', function()
+ clear({env={PATHEXT=''}})
+ eq(0, call('executable', './System32/notepad.exe'))
+ eq(0, call('executable', '.\\System32\\notepad.exe'))
+ eq(0, call('executable', '../notepad.exe'))
+ eq(0, call('executable', '..\\notepad.exe'))
+ end)
end)
diff --git a/test/functional/eval/exepath_spec.lua b/test/functional/eval/exepath_spec.lua
new file mode 100644
index 0000000000..10a11aeacc
--- /dev/null
+++ b/test/functional/eval/exepath_spec.lua
@@ -0,0 +1,14 @@
+local helpers = require('test.functional.helpers')(after_each)
+local eq, clear, call, iswin =
+ helpers.eq, helpers.clear, helpers.call, helpers.iswin
+
+describe('exepath() (Windows)', function()
+ if not iswin() then return end -- N/A for Unix.
+
+ it('append extension if omitted', function()
+ local filename = 'cmd'
+ local pathext = '.exe'
+ clear({env={PATHEXT=pathext}})
+ eq(call('exepath', filename..pathext), call('exepath', filename))
+ end)
+end)
diff --git a/test/functional/eval/let_spec.lua b/test/functional/eval/let_spec.lua
index 0cbf40137e..63e18f943f 100644
--- a/test/functional/eval/let_spec.lua
+++ b/test/functional/eval/let_spec.lua
@@ -59,7 +59,7 @@ describe(':let', function()
end)
it("multibyte env var to child process #8398 #9267", function()
- if (not helpers.iswin()) and require('test.helpers').isCI() then
+ if (not helpers.iswin()) and helpers.isCI() then
-- Fails on non-Windows CI. Buffering/timing issue?
pending('fails on unix CI', function() end)
end