mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
test: deal with RPC call causing Nvim to exit later
This commit is contained in:
@@ -271,10 +271,22 @@ function module.command(cmd)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- use for commands which expect nvim to quit
|
-- Use for commands which expect nvim to quit.
|
||||||
function module.expect_exit(...)
|
-- The first argument can also be a timeout.
|
||||||
eq("EOF was received from Nvim. Likely the Nvim process crashed.",
|
function module.expect_exit(fn_or_timeout, ...)
|
||||||
module.pcall_err(...))
|
local eof_err_msg = 'EOF was received from Nvim. Likely the Nvim process crashed.'
|
||||||
|
if type(fn_or_timeout) == 'function' then
|
||||||
|
eq(eof_err_msg, module.pcall_err(fn_or_timeout, ...))
|
||||||
|
else
|
||||||
|
eq(eof_err_msg, module.pcall_err(function(timeout, fn, ...)
|
||||||
|
fn(...)
|
||||||
|
while session:next_message(timeout) do
|
||||||
|
end
|
||||||
|
if session.eof_err then
|
||||||
|
error(session.eof_err[2])
|
||||||
|
end
|
||||||
|
end, fn_or_timeout, ...))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Evaluates a VimL expression.
|
-- Evaluates a VimL expression.
|
||||||
|
@@ -4,6 +4,7 @@ local helpers = require('test.functional.helpers')(after_each)
|
|||||||
local Screen = require('test.functional.ui.screen')
|
local Screen = require('test.functional.ui.screen')
|
||||||
local clear, command, eq = helpers.clear, helpers.command, helpers.eq
|
local clear, command, eq = helpers.clear, helpers.command, helpers.eq
|
||||||
local eval, exc_exec, neq = helpers.eval, helpers.exc_exec, helpers.neq
|
local eval, exc_exec, neq = helpers.eval, helpers.exc_exec, helpers.neq
|
||||||
|
local expect_exit = helpers.expect_exit
|
||||||
local feed = helpers.feed
|
local feed = helpers.feed
|
||||||
local pcall_err = helpers.pcall_err
|
local pcall_err = helpers.pcall_err
|
||||||
|
|
||||||
@@ -275,6 +276,6 @@ describe('argument list commands', function()
|
|||||||
2 more files to edit. Quit anyway? |
|
2 more files to edit. Quit anyway? |
|
||||||
[Y]es, (N)o: ^ |
|
[Y]es, (N)o: ^ |
|
||||||
]])
|
]])
|
||||||
feed('Y')
|
expect_exit(100, feed, 'Y')
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@@ -4,11 +4,11 @@ local clear = helpers.clear
|
|||||||
local command = helpers.command
|
local command = helpers.command
|
||||||
local exec = helpers.exec
|
local exec = helpers.exec
|
||||||
local exec_lua = helpers.exec_lua
|
local exec_lua = helpers.exec_lua
|
||||||
|
local expect_exit = helpers.expect_exit
|
||||||
local feed = helpers.feed
|
local feed = helpers.feed
|
||||||
local funcs = helpers.funcs
|
local funcs = helpers.funcs
|
||||||
local iswin = helpers.iswin
|
local iswin = helpers.iswin
|
||||||
local meths = helpers.meths
|
local meths = helpers.meths
|
||||||
local poke_eventloop = helpers.poke_eventloop
|
|
||||||
local read_file = helpers.read_file
|
local read_file = helpers.read_file
|
||||||
local source = helpers.source
|
local source = helpers.source
|
||||||
local eq = helpers.eq
|
local eq = helpers.eq
|
||||||
@@ -94,8 +94,7 @@ describe(':confirm command dialog', function()
|
|||||||
{3:Save changes to "Xbar"?} |
|
{3:Save changes to "Xbar"?} |
|
||||||
{3:[Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: }^ |
|
{3:[Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: }^ |
|
||||||
]])
|
]])
|
||||||
feed('A')
|
expect_exit(100, feed, 'A')
|
||||||
poke_eventloop()
|
|
||||||
|
|
||||||
eq('foo2\n', read_file('Xfoo'))
|
eq('foo2\n', read_file('Xfoo'))
|
||||||
eq('bar2\n', read_file('Xbar'))
|
eq('bar2\n', read_file('Xbar'))
|
||||||
@@ -133,8 +132,7 @@ describe(':confirm command dialog', function()
|
|||||||
{3:Save changes to "Xbar"?} |
|
{3:Save changes to "Xbar"?} |
|
||||||
{3:[Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: }^ |
|
{3:[Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: }^ |
|
||||||
]])
|
]])
|
||||||
feed('D')
|
expect_exit(100, feed, 'D')
|
||||||
poke_eventloop()
|
|
||||||
|
|
||||||
eq('foo2\n', read_file('Xfoo'))
|
eq('foo2\n', read_file('Xfoo'))
|
||||||
eq('bar2\n', read_file('Xbar'))
|
eq('bar2\n', read_file('Xbar'))
|
||||||
@@ -195,8 +193,7 @@ describe(':confirm command dialog', function()
|
|||||||
{3:Save changes to "Xfoo"?} |
|
{3:Save changes to "Xfoo"?} |
|
||||||
{3:[Y]es, (N)o, (C)ancel: }^ |
|
{3:[Y]es, (N)o, (C)ancel: }^ |
|
||||||
]])
|
]])
|
||||||
feed('Y')
|
expect_exit(100, feed, 'Y')
|
||||||
poke_eventloop()
|
|
||||||
|
|
||||||
eq('foo4\n', read_file('Xfoo'))
|
eq('foo4\n', read_file('Xfoo'))
|
||||||
eq('bar2\n', read_file('Xbar'))
|
eq('bar2\n', read_file('Xbar'))
|
||||||
|
@@ -7,6 +7,7 @@ local eval = helpers.eval
|
|||||||
local meths = helpers.meths
|
local meths = helpers.meths
|
||||||
local exec = helpers.exec
|
local exec = helpers.exec
|
||||||
local exec_capture = helpers.exec_capture
|
local exec_capture = helpers.exec_capture
|
||||||
|
local expect_exit = helpers.expect_exit
|
||||||
local source = helpers.source
|
local source = helpers.source
|
||||||
local testprg = helpers.testprg
|
local testprg = helpers.testprg
|
||||||
|
|
||||||
@@ -28,7 +29,7 @@ describe(':let', function()
|
|||||||
it(":unlet self-referencing node in a List graph #6070", function()
|
it(":unlet self-referencing node in a List graph #6070", function()
|
||||||
-- :unlet-ing a self-referencing List must not allow GC on indirectly
|
-- :unlet-ing a self-referencing List must not allow GC on indirectly
|
||||||
-- referenced in-scope Lists. Before #6070 this caused use-after-free.
|
-- referenced in-scope Lists. Before #6070 this caused use-after-free.
|
||||||
source([=[
|
expect_exit(100, source, [=[
|
||||||
let [l1, l2] = [[], []]
|
let [l1, l2] = [[], []]
|
||||||
echo 'l1:' . id(l1)
|
echo 'l1:' . id(l1)
|
||||||
echo 'l2:' . id(l2)
|
echo 'l2:' . id(l2)
|
||||||
|
Reference in New Issue
Block a user