mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
functests: Test invalid behaviour
Test correctly fail for oneline ruby, python and python3.
This commit is contained in:
parent
d9023b84e6
commit
8b171b8c50
75
test/functional/ex_cmds/script_spec.lua
Normal file
75
test/functional/ex_cmds/script_spec.lua
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
|
|
||||||
|
local eq = helpers.eq
|
||||||
|
local neq = helpers.neq
|
||||||
|
local meths = helpers.meths
|
||||||
|
local clear = helpers.clear
|
||||||
|
local dedent = helpers.dedent
|
||||||
|
local source = helpers.source
|
||||||
|
local exc_exec = helpers.exc_exec
|
||||||
|
local check_provider = helpers.check_provider
|
||||||
|
|
||||||
|
before_each(clear)
|
||||||
|
|
||||||
|
describe('script_get-based command', function()
|
||||||
|
local garbage = ')}{+*({}]*[;(+}{&[]}{*])('
|
||||||
|
|
||||||
|
local function test_garbage_exec(cmd, check_neq)
|
||||||
|
describe(cmd, function()
|
||||||
|
it('works correctly when skipping oneline variant', function()
|
||||||
|
eq(true, pcall(source, (dedent([[
|
||||||
|
if 0
|
||||||
|
%s %s
|
||||||
|
endif
|
||||||
|
]])):format(cmd, garbage)))
|
||||||
|
eq('', meths.command_output('messages'))
|
||||||
|
if check_neq then
|
||||||
|
neq(0, exc_exec(dedent([[
|
||||||
|
%s %s
|
||||||
|
]])):format(cmd, garbage))
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
it('works correctly when skipping HEREdoc variant', function()
|
||||||
|
eq(true, pcall(source, (dedent([[
|
||||||
|
if 0
|
||||||
|
%s << EOF
|
||||||
|
%s
|
||||||
|
EOF
|
||||||
|
endif
|
||||||
|
]])):format(cmd, garbage)))
|
||||||
|
eq('', meths.command_output('messages'))
|
||||||
|
if check_neq then
|
||||||
|
eq(true, pcall(source, (dedent([[
|
||||||
|
let g:exc = 0
|
||||||
|
try
|
||||||
|
%s << EOF
|
||||||
|
%s
|
||||||
|
EOF
|
||||||
|
catch
|
||||||
|
let g:exc = v:exception
|
||||||
|
endtry
|
||||||
|
]])):format(cmd, garbage)))
|
||||||
|
neq(0, meths.get_var('exc'))
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
clear()
|
||||||
|
|
||||||
|
-- Built-in scripts
|
||||||
|
test_garbage_exec('lua', true)
|
||||||
|
|
||||||
|
-- Provider-based scripts
|
||||||
|
test_garbage_exec('ruby', check_provider('ruby'))
|
||||||
|
test_garbage_exec('python', check_provider('python'))
|
||||||
|
test_garbage_exec('python3', check_provider('python3'))
|
||||||
|
|
||||||
|
-- Missing scripts
|
||||||
|
test_garbage_exec('tcl', false)
|
||||||
|
test_garbage_exec('mzscheme', false)
|
||||||
|
test_garbage_exec('perl', false)
|
||||||
|
|
||||||
|
-- Not really a script
|
||||||
|
test_garbage_exec('xxxinvalidlanguagexxx', true)
|
||||||
|
end)
|
@ -566,6 +566,19 @@ local function get_pathsep()
|
|||||||
return funcs.fnamemodify('.', ':p'):sub(-1)
|
return funcs.fnamemodify('.', ':p'):sub(-1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function check_provider(provider)
|
||||||
|
if provider == 'ruby' then
|
||||||
|
local prog = funcs['provider#' .. provider .. '#Detect']()
|
||||||
|
return prog ~= ''
|
||||||
|
elseif provider == 'python' or provider == 'python3' then
|
||||||
|
local py_major_version = (provider == 'python3' and 3 or 2)
|
||||||
|
local errors = funcs['provider#pythonx#Detect'](py_major_version)[2]
|
||||||
|
return errors == ''
|
||||||
|
else
|
||||||
|
assert(false, 'Unknown provider: ' .. provider)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local module = {
|
local module = {
|
||||||
prepend_argv = prepend_argv,
|
prepend_argv = prepend_argv,
|
||||||
clear = clear,
|
clear = clear,
|
||||||
@ -632,6 +645,7 @@ local module = {
|
|||||||
meth_pcall = meth_pcall,
|
meth_pcall = meth_pcall,
|
||||||
NIL = mpack.NIL,
|
NIL = mpack.NIL,
|
||||||
get_pathsep = get_pathsep,
|
get_pathsep = get_pathsep,
|
||||||
|
check_provider = check_provider,
|
||||||
}
|
}
|
||||||
|
|
||||||
return function(after_each)
|
return function(after_each)
|
||||||
|
@ -3,12 +3,11 @@ local eval, command, feed = helpers.eval, helpers.command, helpers.feed
|
|||||||
local eq, clear, insert = helpers.eq, helpers.clear, helpers.insert
|
local eq, clear, insert = helpers.eq, helpers.clear, helpers.insert
|
||||||
local expect, write_file = helpers.expect, helpers.write_file
|
local expect, write_file = helpers.expect, helpers.write_file
|
||||||
local feed_command = helpers.feed_command
|
local feed_command = helpers.feed_command
|
||||||
|
local check_provider = helpers.check_provider
|
||||||
|
|
||||||
do
|
do
|
||||||
clear()
|
clear()
|
||||||
command('let [g:interp, g:errors] = provider#pythonx#Detect(3)')
|
if not check_provider('python3') then
|
||||||
local errors = eval('g:errors')
|
|
||||||
if errors ~= '' then
|
|
||||||
pending(
|
pending(
|
||||||
'Python 3 (or the Python 3 neovim module) is broken or missing:\n' .. errors,
|
'Python 3 (or the Python 3 neovim module) is broken or missing:\n' .. errors,
|
||||||
function() end)
|
function() end)
|
||||||
|
@ -12,12 +12,11 @@ local command = helpers.command
|
|||||||
local exc_exec = helpers.exc_exec
|
local exc_exec = helpers.exc_exec
|
||||||
local write_file = helpers.write_file
|
local write_file = helpers.write_file
|
||||||
local curbufmeths = helpers.curbufmeths
|
local curbufmeths = helpers.curbufmeths
|
||||||
|
local check_provider = helpers.check_provider
|
||||||
|
|
||||||
do
|
do
|
||||||
clear()
|
clear()
|
||||||
command('let [g:interp, g:errors] = provider#pythonx#Detect(2)')
|
if not check_provider('python') then
|
||||||
local errors = meths.get_var('errors')
|
|
||||||
if errors ~= '' then
|
|
||||||
pending(
|
pending(
|
||||||
'Python 2 (or the Python 2 neovim module) is broken or missing:\n' .. errors,
|
'Python 2 (or the Python 2 neovim module) is broken or missing:\n' .. errors,
|
||||||
function() end)
|
function() end)
|
||||||
|
@ -10,13 +10,11 @@ local expect = helpers.expect
|
|||||||
local command = helpers.command
|
local command = helpers.command
|
||||||
local write_file = helpers.write_file
|
local write_file = helpers.write_file
|
||||||
local curbufmeths = helpers.curbufmeths
|
local curbufmeths = helpers.curbufmeths
|
||||||
|
local check_provider = helpers.check_provider
|
||||||
|
|
||||||
do
|
do
|
||||||
clear()
|
clear()
|
||||||
command('let g:prog = provider#ruby#Detect()')
|
if not check_provider('ruby') then
|
||||||
local prog = meths.get_var('prog')
|
|
||||||
|
|
||||||
if prog == '' then
|
|
||||||
pending(
|
pending(
|
||||||
"Cannot find the neovim RubyGem. Try :CheckHealth",
|
"Cannot find the neovim RubyGem. Try :CheckHealth",
|
||||||
function() end)
|
function() end)
|
||||||
|
Loading…
Reference in New Issue
Block a user