From 5ccc79e880d5913f092e041f1a67530c1d2d6728 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 8 Dec 2020 20:19:08 -0500 Subject: 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 --- test/functional/eval/executable_spec.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test/functional/eval/executable_spec.lua') 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) -- cgit From da58242fb8e432415778e3eeab96a9d63edfdf06 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 11 Dec 2020 22:59:43 -0500 Subject: test/functional/eval: assert that executable() fixtures are executable --- test/functional/eval/executable_spec.lua | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test/functional/eval/executable_spec.lua') diff --git a/test/functional/eval/executable_spec.lua b/test/functional/eval/executable_spec.lua index f8e579a8ff..28aefb72e5 100644 --- a/test/functional/eval/executable_spec.lua +++ b/test/functional/eval/executable_spec.lua @@ -11,6 +11,10 @@ describe('executable()', function() it('returns 1 for commands in $PATH', function() local exe = iswin() and 'ping' or 'ls' eq(1, call('executable', exe)) + command('let $PATH = fnamemodify("./test/functional/fixtures/bin", ":p")') + eq(1, call('executable', 'null')) + eq(1, call('executable', 'true')) + eq(1, call('executable', 'false')) end) it('fails for invalid values', function() -- cgit