diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-12-08 20:19:08 -0500 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-12-11 21:20:20 -0500 |
commit | 5ccc79e880d5913f092e041f1a67530c1d2d6728 (patch) | |
tree | 1220939397a812156a92bbdddd8d2b03ebd98fd5 /test/functional | |
parent | 062576f679a1bd5cb546bb8081dc97caefe7b51f (diff) | |
download | rneovim-5ccc79e880d5913f092e041f1a67530c1d2d6728.tar.gz rneovim-5ccc79e880d5913f092e041f1a67530c1d2d6728.tar.bz2 rneovim-5ccc79e880d5913f092e041f1a67530c1d2d6728.zip |
eval: executable(), exepath() accept strings only
Cherry-pick f_executable(), f_exepath(), check_for_string() from patch 8.2.2117.
Rename check_for_string() to tv_check_for_string().
https://github.com/vim/vim/commit/7bb4e74c38642682cfdd0cb4052adfa5efdd7dd1
Close https://github.com/neovim/neovim/issues/13485
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/eval/executable_spec.lua | 11 | ||||
-rw-r--r-- | test/functional/eval/exepath_spec.lua | 28 | ||||
-rwxr-xr-x | test/functional/fixtures/bin/false | 0 | ||||
-rwxr-xr-x | test/functional/fixtures/bin/false.cmd | 0 | ||||
-rwxr-xr-x | test/functional/fixtures/bin/null | 0 | ||||
-rwxr-xr-x | test/functional/fixtures/bin/null.cmd | 0 | ||||
-rwxr-xr-x | test/functional/fixtures/bin/true | 0 | ||||
-rwxr-xr-x | test/functional/fixtures/bin/true.cmd | 0 |
8 files changed, 32 insertions, 7 deletions
diff --git a/test/functional/eval/executable_spec.lua b/test/functional/eval/executable_spec.lua index a1cf056907..f8e579a8ff 100644 --- a/test/functional/eval/executable_spec.lua +++ b/test/functional/eval/executable_spec.lua @@ -2,6 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local eq, clear, call, iswin, write_file, command = helpers.eq, helpers.clear, helpers.call, helpers.iswin, helpers.write_file, helpers.command +local exc_exec = helpers.exc_exec local eval = helpers.eval describe('executable()', function() @@ -12,6 +13,16 @@ describe('executable()', function() eq(1, call('executable', exe)) end) + it('fails for invalid values', function() + for _, input in ipairs({'""', 'v:null', 'v:true', 'v:false', '{}', '[]'}) do + eq('Vim(call):E928: String required', exc_exec('call executable('..input..')')) + end + command('let $PATH = fnamemodify("./test/functional/fixtures/bin", ":p")') + for _, input in ipairs({'v:null', 'v:true', 'v:false'}) do + eq('Vim(call):E928: String required', exc_exec('call executable('..input..')')) + end + end) + it('returns 0 for non-existent files', function() eq(0, call('executable', 'no_such_file_exists_209ufq23f')) end) diff --git a/test/functional/eval/exepath_spec.lua b/test/functional/eval/exepath_spec.lua index 10a11aeacc..b86fea5535 100644 --- a/test/functional/eval/exepath_spec.lua +++ b/test/functional/eval/exepath_spec.lua @@ -1,14 +1,28 @@ local helpers = require('test.functional.helpers')(after_each) local eq, clear, call, iswin = helpers.eq, helpers.clear, helpers.call, helpers.iswin +local command = helpers.command +local exc_exec = helpers.exc_exec -describe('exepath() (Windows)', function() - if not iswin() then return end -- N/A for Unix. +describe('exepath()', function() + before_each(clear) - it('append extension if omitted', function() - local filename = 'cmd' - local pathext = '.exe' - clear({env={PATHEXT=pathext}}) - eq(call('exepath', filename..pathext), call('exepath', filename)) + it('fails for invalid values', function() + for _, input in ipairs({'""', 'v:null', 'v:true', 'v:false', '{}', '[]'}) do + eq('Vim(call):E928: String required', exc_exec('call exepath('..input..')')) + end + command('let $PATH = fnamemodify("./test/functional/fixtures/bin", ":p")') + for _, input in ipairs({'v:null', 'v:true', 'v:false'}) do + eq('Vim(call):E928: String required', exc_exec('call exepath('..input..')')) + end end) + + if iswin() then + 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 end) diff --git a/test/functional/fixtures/bin/false b/test/functional/fixtures/bin/false new file mode 100755 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/functional/fixtures/bin/false diff --git a/test/functional/fixtures/bin/false.cmd b/test/functional/fixtures/bin/false.cmd new file mode 100755 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/functional/fixtures/bin/false.cmd diff --git a/test/functional/fixtures/bin/null b/test/functional/fixtures/bin/null new file mode 100755 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/functional/fixtures/bin/null diff --git a/test/functional/fixtures/bin/null.cmd b/test/functional/fixtures/bin/null.cmd new file mode 100755 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/functional/fixtures/bin/null.cmd diff --git a/test/functional/fixtures/bin/true b/test/functional/fixtures/bin/true new file mode 100755 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/functional/fixtures/bin/true diff --git a/test/functional/fixtures/bin/true.cmd b/test/functional/fixtures/bin/true.cmd new file mode 100755 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/functional/fixtures/bin/true.cmd |