diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-04-02 12:40:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-02 12:40:36 +0200 |
commit | 8eaa452073a1be59234642dba347316226f1dcb1 (patch) | |
tree | 38ed586e8801ff20929fb03c3995ddf2c936904a /test/functional/eval/executable_spec.lua | |
parent | 35362495c965554f45634bcde3c4ce6d5eca52aa (diff) | |
parent | c7039fd0d3f6f5d7c8699fd88095e100f0754e59 (diff) | |
download | rneovim-8eaa452073a1be59234642dba347316226f1dcb1.tar.gz rneovim-8eaa452073a1be59234642dba347316226f1dcb1.tar.bz2 rneovim-8eaa452073a1be59234642dba347316226f1dcb1.zip |
Merge #9516 from erw7/improve-executable-on-windows
Improve executable() and exepath() on windows
Diffstat (limited to 'test/functional/eval/executable_spec.lua')
-rw-r--r-- | test/functional/eval/executable_spec.lua | 65 |
1 files changed, 55 insertions, 10 deletions
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) |