aboutsummaryrefslogtreecommitdiff
path: root/test/functional/eval/executable_spec.lua
diff options
context:
space:
mode:
authorerw7 <erw7.github@gmail.com>2019-01-18 14:11:40 +0900
committerJustin M. Keyes <justinkz@gmail.com>2019-04-01 03:13:11 +0200
commit3be5aa1a34f63f4e5e2b384098de2020a4c5b3bc (patch)
tree6bf3ccd551b99d5debb0478093465b511574aee6 /test/functional/eval/executable_spec.lua
parent35c2ceba9695b2f246c11d4e457acda82bb9cb36 (diff)
downloadrneovim-3be5aa1a34f63f4e5e2b384098de2020a4c5b3bc.tar.gz
rneovim-3be5aa1a34f63f4e5e2b384098de2020a4c5b3bc.tar.bz2
rneovim-3be5aa1a34f63f4e5e2b384098de2020a4c5b3bc.zip
test/win: executable(), exepath() #9516
Diffstat (limited to 'test/functional/eval/executable_spec.lua')
-rw-r--r--test/functional/eval/executable_spec.lua61
1 files changed, 51 insertions, 10 deletions
diff --git a/test/functional/eval/executable_spec.lua b/test/functional/eval/executable_spec.lua
index c931b47221..1055675c26 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,18 @@ describe('executable() (Windows)', function()
eq(1, call('executable', '.\\test_executable_zzz'))
end)
- it('returns 1 for any existing filename', function()
+ it('returns 1 for any existing filename, when a Unix-shell like \'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('returns 1 for any existing path, when a Unix-shell like \'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))
@@ -153,4 +155,43 @@ describe('executable() (Windows)', function()
eq(1, call('executable', '.\\test_executable_zzz.zzz'))
eq(1, call('executable', './test_executable_zzz.zzz'))
end)
+
+ it('returns 1 for any existing filename, when $PATHEXT contain dot itself', function()
+ clear({env={PATHEXT='.;.zzz'}})
+ 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'))
+ clear({env={PATHEXT='.zzz;.'}})
+ 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, when $PATHEXT contain dot itself (backslashes)', function()
+ clear({env={PATHEXT='.;.zzz'}})
+ 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('ignore case of extension', function()
+ clear({env={PATHEXT='.ZZZ'}})
+ eq(1, call('executable', 'test_executable_zzz.zzz'))
+ end)
+
+ it('file is not found by relative path from $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)