1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
From: zeertzjq <zeertzjq@outlook.com>
Date: Tue, 19 Jul 2022 19:36:29 +0800
X-Dgit-Generated: 0.7.2-4 b5625218233decc64350294a2753318932046e97
Subject: test: deal with RPC call causing Nvim to exit later
---
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index d44f34dd8..bfa934b20 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -273,10 +273,22 @@ function module.command(cmd)
end
--- use for commands which expect nvim to quit
-function module.expect_exit(...)
- eq("EOF was received from Nvim. Likely the Nvim process crashed.",
- module.pcall_err(...))
+-- Use for commands which expect nvim to quit.
+-- The first argument can also be a timeout.
+function module.expect_exit(fn_or_timeout, ...)
+ 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
-- Evaluates a VimL expression.
diff --git a/test/functional/vimscript/let_spec.lua b/test/functional/vimscript/let_spec.lua
index 509846450..4e95cd636 100644
--- a/test/functional/vimscript/let_spec.lua
+++ b/test/functional/vimscript/let_spec.lua
@@ -6,6 +6,7 @@ local command = helpers.command
local eval = helpers.eval
local meths = helpers.meths
local exec_capture = helpers.exec_capture
+local expect_exit = helpers.expect_exit
local source = helpers.source
local testprg = helpers.testprg
@@ -27,7 +28,7 @@ describe(':let', function()
it(":unlet self-referencing node in a List graph #6070", function()
-- :unlet-ing a self-referencing List must not allow GC on indirectly
-- referenced in-scope Lists. Before #6070 this caused use-after-free.
- source([=[
+ expect_exit(100, source, [=[
let [l1, l2] = [[], []]
echo 'l1:' . id(l1)
echo 'l2:' . id(l2)
|