From: bfredl <bjorn.linse@gmail.com>
Date: Wed, 8 Jun 2022 23:22:50 +0200
X-Dgit-Generated: 0.7.2-4 ea5a4488961bd87df4da9699bf9ddb25c385264e
Subject: fix(tests): check for EOF on exit of nvim properly

Signed-off-by: James McCoy <jamessan@debian.org>

---

diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 04b79a715..107cf32c0 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -25,6 +25,7 @@ local tmpname = helpers.tmpname
 local write_file = helpers.write_file
 local exec_lua = helpers.exec_lua
 local exc_exec = helpers.exc_exec
+local expect_exit = helpers.expect_exit
 
 local pcall_err = helpers.pcall_err
 local format_string = helpers.format_string
@@ -2597,7 +2598,7 @@ describe('API', function()
 
     it('does not cause heap-use-after-free on exit while setting options', function()
       command('au OptionSet * q')
-      command('silent! call nvim_create_buf(0, 1)')
+      expect_exit(command, 'silent! call nvim_create_buf(0, 1)')
     end)
   end)
 
diff --git a/test/functional/core/fileio_spec.lua b/test/functional/core/fileio_spec.lua
index c68bc18ee..bc025771d 100644
--- a/test/functional/core/fileio_spec.lua
+++ b/test/functional/core/fileio_spec.lua
@@ -16,12 +16,13 @@ local trim = helpers.trim
 local currentdir = helpers.funcs.getcwd
 local iswin = helpers.iswin
 local assert_alive = helpers.assert_alive
+local expect_exit = helpers.expect_exit
 
 describe('fileio', function()
   before_each(function()
   end)
   after_each(function()
-    command(':qall!')
+    expect_exit(command, ':qall!')
     os.remove('Xtest_startup_shada')
     os.remove('Xtest_startup_file1')
     os.remove('Xtest_startup_file1~')
diff --git a/test/functional/ex_cmds/mksession_spec.lua b/test/functional/ex_cmds/mksession_spec.lua
index 2702fb196..2bec31d41 100644
--- a/test/functional/ex_cmds/mksession_spec.lua
+++ b/test/functional/ex_cmds/mksession_spec.lua
@@ -10,6 +10,7 @@ local funcs = helpers.funcs
 local matches = helpers.matches
 local pesc = helpers.pesc
 local rmdir = helpers.rmdir
+local expect_exit = helpers.expect_exit
 
 local file_prefix = 'Xtest-functional-ex_cmds-mksession_spec'
 
@@ -41,7 +42,7 @@ describe(':mksession', function()
     command('mksession '..session_file)
 
     -- Create a new test instance of Nvim.
-    command('qall!')
+    expect_exit(command, 'qall!')
     clear()
     -- Restore session.
     command('source '..session_file)
@@ -106,7 +107,8 @@ describe(':mksession', function()
     command('terminal echo $PWD')
     command('cd '..cwd_dir)
     command('mksession '..session_path)
-    command('qall!')
+    command('bdelete!')
+    expect_exit(command, 'qall!')
 
     -- Create a new test instance of Nvim.
     clear()
@@ -114,6 +116,6 @@ describe(':mksession', function()
 
     local expected_cwd = cwd_dir..'/'..tab_dir
     matches('^term://'..pesc(expected_cwd)..'//%d+:', funcs.expand('%'))
-    command('qall!')
+    command('bdelete!')
   end)
 end)
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index 6cc0bae51..d44f34dd8 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -272,6 +272,13 @@ function module.command(cmd)
   module.request('nvim_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(...))
+end
+
 -- Evaluates a VimL expression.
 -- Fails on VimL error, but does not update v:errmsg.
 function module.eval(expr)
diff --git a/test/functional/legacy/008_autocommands_spec.lua b/test/functional/legacy/008_autocommands_spec.lua
index 002f037d0..4088cd164 100644
--- a/test/functional/legacy/008_autocommands_spec.lua
+++ b/test/functional/legacy/008_autocommands_spec.lua
@@ -6,6 +6,7 @@ local source = helpers.source
 local clear, command, expect, eq, eval = helpers.clear, helpers.command, helpers.expect, helpers.eq, helpers.eval
 local write_file, dedent = helpers.write_file, helpers.dedent
 local read_file = helpers.read_file
+local expect_exit = helpers.expect_exit
 
 describe('autocommands that delete and unload buffers:', function()
   local test_file = 'Xtest-008_autocommands.out'
@@ -78,7 +79,7 @@ describe('autocommands that delete and unload buffers:', function()
     command('silent! edit Xxx1')
     command('silent! edit Makefile') -- an existing file
     command('silent! split new2')
-    command('silent! quit')
+    expect_exit(command, 'silent! quit')
     eq('VimLeave done',
        string.match(read_file(test_file), "^%s*(.-)%s*$"))
   end)
diff --git a/test/functional/legacy/012_directory_spec.lua b/test/functional/legacy/012_directory_spec.lua
index f666e5146..dd207ca0b 100644
--- a/test/functional/legacy/012_directory_spec.lua
+++ b/test/functional/legacy/012_directory_spec.lua
@@ -16,6 +16,7 @@ local insert = helpers.insert
 local command = helpers.command
 local write_file = helpers.write_file
 local curbufmeths = helpers.curbufmeths
+local expect_exit = helpers.expect_exit
 
 local function ls_dir_sorted(dirname)
   local files = {}
@@ -43,7 +44,7 @@ describe("'directory' option", function()
     clear()
   end)
   teardown(function()
-    command('qall!')
+    expect_exit(command, 'qall!')
     helpers.rmdir('Xtest.je')
     helpers.rmdir('Xtest2')
     os.remove('Xtest1')
diff --git a/test/functional/legacy/031_close_commands_spec.lua b/test/functional/legacy/031_close_commands_spec.lua
index 64c67c988..d02b1a204 100644
--- a/test/functional/legacy/031_close_commands_spec.lua
+++ b/test/functional/legacy/031_close_commands_spec.lua
@@ -17,6 +17,7 @@ local source = helpers.source
 local insert = helpers.insert
 local expect = helpers.expect
 local feed_command = helpers.feed_command
+local expect_exit = helpers.expect_exit
 
 describe('Commands that close windows and/or buffers', function()
   local function cleanup()
@@ -118,7 +119,7 @@ describe('Commands that close windows and/or buffers', function()
     feed_command('q!')
     feed('<CR>')
     expect('testtext 1')
-    source([[
+    expect_exit(source, [[
       q!
       " Now nvim should have exited
       throw "Oh, Not finished yet."]])
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua
index c28fd402e..df88ba762 100644
--- a/test/functional/lua/vim_spec.lua
+++ b/test/functional/lua/vim_spec.lua
@@ -22,7 +22,7 @@ local remove_trace = helpers.remove_trace
 local mkdir_p = helpers.mkdir_p
 local rmdir = helpers.rmdir
 local write_file = helpers.write_file
-
+local expect_exit = helpers.expect_exit
 
 describe('lua stdlib', function()
   before_each(clear)
@@ -2663,9 +2663,7 @@ describe('lua: builtin modules', function()
 
   it('does not work when disabled without runtime', function()
     clear{args={'--luamod-dev'}, env={VIMRUNTIME='fixtures/a'}}
-    -- error checking could be better here. just check that --luamod-dev
-    -- does anything at all by breaking with missing runtime..
-    eq(nil, exec_lua[[return vim.tbl_count {x=1,y=2}]])
+    expect_exit(exec_lua, [[return vim.tbl_count {x=1,y=2}]])
   end)
 end)
 
diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua
index 6620c9ace..439ce30ae 100644
--- a/test/functional/options/defaults_spec.lua
+++ b/test/functional/options/defaults_spec.lua
@@ -17,6 +17,7 @@ local mkdir = helpers.mkdir
 local rmdir = helpers.rmdir
 local alter_slashes = helpers.alter_slashes
 local tbl_contains = helpers.tbl_contains
+local expect_exit = helpers.expect_exit
 
 describe('startup defaults', function()
   describe(':filetype', function()
@@ -174,7 +175,7 @@ describe('startup defaults', function()
     command('write')
     local f = eval('fnamemodify(@%,":p")')
     assert(string.len(f) > 3)
-    command('qall')
+    expect_exit(command, 'qall')
     clear{args={}, args_rm={'-i'}, env=env}
     eq({ f }, eval('v:oldfiles'))
     os.remove('Xtest-foo')
diff --git a/test/functional/shada/buffers_spec.lua b/test/functional/shada/buffers_spec.lua
index 04c9c01d7..26a4569fc 100644
--- a/test/functional/shada/buffers_spec.lua
+++ b/test/functional/shada/buffers_spec.lua
@@ -2,6 +2,7 @@
 local helpers = require('test.functional.helpers')(after_each)
 local nvim_command, funcs, eq, curbufmeths =
   helpers.command, helpers.funcs, helpers.eq, helpers.curbufmeths
+local expect_exit = helpers.expect_exit
 
 local shada_helpers = require('test.functional.shada.helpers')
 local reset, clear = shada_helpers.reset, shada_helpers.clear
@@ -15,7 +16,7 @@ describe('shada support code', function()
     reset('set shada+=%')
     nvim_command('edit ' .. testfilename)
     nvim_command('edit ' .. testfilename_2)
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset('set shada+=%')
     eq(3, funcs.bufnr('$'))
     eq('', funcs.bufname(1))
@@ -27,7 +28,7 @@ describe('shada support code', function()
     reset('set shada+=%')
     nvim_command('edit ' .. testfilename)
     nvim_command('edit ' .. testfilename_2)
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset()
     eq(1, funcs.bufnr('$'))
     eq('', funcs.bufname(1))
@@ -37,7 +38,7 @@ describe('shada support code', function()
     reset()
     nvim_command('edit ' .. testfilename)
     nvim_command('edit ' .. testfilename_2)
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset('set shada+=%')
     eq(1, funcs.bufnr('$'))
     eq('', funcs.bufname(1))
@@ -48,7 +49,7 @@ describe('shada support code', function()
     nvim_command('edit ' .. testfilename)
     nvim_command('edit ' .. testfilename_2)
     curbufmeths.set_option('buflisted', false)
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset('set shada+=%')
     eq(2, funcs.bufnr('$'))
     eq('', funcs.bufname(1))
@@ -60,7 +61,7 @@ describe('shada support code', function()
     nvim_command('edit ' .. testfilename)
     nvim_command('edit ' .. testfilename_2)
     curbufmeths.set_option('buftype', 'quickfix')
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset('set shada+=%')
     eq(2, funcs.bufnr('$'))
     eq('', funcs.bufname(1))
@@ -73,7 +74,7 @@ describe('shada support code', function()
     nvim_command('enew')
     curbufmeths.set_lines(0, 1, true, {'bar'})
     eq(2, funcs.bufnr('$'))
-    nvim_command('qall!')
+    expect_exit(nvim_command, 'qall!')
     reset('set shada+=% hidden')
     eq(1, funcs.bufnr('$'))
     eq('', funcs.bufname(1))
@@ -83,7 +84,7 @@ describe('shada support code', function()
     reset('set shada+=%1')
     nvim_command('edit ' .. testfilename)
     nvim_command('edit ' .. testfilename_2)
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset('set shada+=%1')
     eq(2, funcs.bufnr('$'))
     eq('', funcs.bufname(1))
diff --git a/test/functional/shada/history_spec.lua b/test/functional/shada/history_spec.lua
index 84cc34c7c..d1daf6c7c 100644
--- a/test/functional/shada/history_spec.lua
+++ b/test/functional/shada/history_spec.lua
@@ -3,6 +3,7 @@ local helpers = require('test.functional.helpers')(after_each)
 local nvim_command, funcs, meths, nvim_feed, eq =
   helpers.command, helpers.funcs, helpers.meths, helpers.feed, helpers.eq
 local assert_alive = helpers.assert_alive
+local expect_exit = helpers.expect_exit
 
 local shada_helpers = require('test.functional.shada.helpers')
 local reset, clear = shada_helpers.reset, shada_helpers.clear
@@ -25,13 +26,13 @@ describe('ShaDa support code', function()
     nvim_command('set shada=\'0 history=2')
     nvim_feed(':" Test\n')
     nvim_feed(':" Test 2\n')
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset()
     nvim_command('set shada=\'0 history=2')
     nvim_command('rshada')
     eq('" Test 2', funcs.histget(':', -1))
     eq('" Test', funcs.histget(':', -2))
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
   end)
 
   it('respects &history when dumping',
@@ -138,7 +139,7 @@ describe('ShaDa support code', function()
     nvim_command('set hlsearch shada-=h')
     nvim_feed('/test\n')
     eq(1, meths.get_vvar('hlsearch'))
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset()
     eq(1, meths.get_vvar('hlsearch'))
   end)
@@ -147,7 +148,7 @@ describe('ShaDa support code', function()
     nvim_command('set hlsearch shada-=h')
     nvim_feed('/test\n')
     nvim_command('nohlsearch')
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset()
     eq(0, meths.get_vvar('hlsearch'))
   end)
@@ -156,7 +157,7 @@ describe('ShaDa support code', function()
     nvim_command('set hlsearch')
     nvim_feed('/test\n')
     eq(1, meths.get_vvar('hlsearch'))
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset()
     eq(0, meths.get_vvar('hlsearch'))
   end)
@@ -175,7 +176,7 @@ describe('ShaDa support code', function()
   it('dumps and loads history with UTF-8 characters', function()
     reset()
     nvim_feed(':echo "«"\n')
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset()
     eq('echo "«"', funcs.histget(':', -1))
   end)
@@ -183,7 +184,7 @@ describe('ShaDa support code', function()
   it('dumps and loads replacement with UTF-8 characters',
   function()
     nvim_command('substitute/./«/ge')
-    nvim_command('qall!')
+    expect_exit(nvim_command, 'qall!')
     reset()
     funcs.setline('.', {'.'})
     nvim_command('&')
@@ -193,7 +194,7 @@ describe('ShaDa support code', function()
   it('dumps and loads substitute pattern with UTF-8 characters',
   function()
     nvim_command('substitute/«/./ge')
-    nvim_command('qall!')
+    expect_exit(nvim_command, 'qall!')
     reset()
     funcs.setline('.', {'«\171'})
     nvim_command('&')
@@ -204,7 +205,7 @@ describe('ShaDa support code', function()
   function()
     nvim_command('silent! /«/')
     nvim_command('set shada+=/0')
-    nvim_command('qall!')
+    expect_exit(nvim_command, 'qall!')
     reset()
     funcs.setline('.', {'\171«'})
     nvim_command('~&')
@@ -217,7 +218,7 @@ describe('ShaDa support code', function()
     -- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1
     nvim_command('silent! /\171/')
     nvim_command('set shada+=/0')
-    nvim_command('qall!')
+    expect_exit(nvim_command, 'qall!')
     reset()
     funcs.setline('.', {'\171«'})
     nvim_command('~&')
diff --git a/test/functional/shada/marks_spec.lua b/test/functional/shada/marks_spec.lua
index 153a1c346..a91be1884 100644
--- a/test/functional/shada/marks_spec.lua
+++ b/test/functional/shada/marks_spec.lua
@@ -4,6 +4,7 @@ local meths, curwinmeths, curbufmeths, nvim_command, funcs, eq =
   helpers.meths, helpers.curwinmeths, helpers.curbufmeths, helpers.command,
   helpers.funcs, helpers.eq
 local exc_exec, exec_capture = helpers.exc_exec, helpers.exec_capture
+local expect_exit = helpers.expect_exit
 
 local shada_helpers = require('test.functional.shada.helpers')
 local reset, clear = shada_helpers.reset, shada_helpers.clear
@@ -79,7 +80,7 @@ describe('ShaDa support code', function()
     nvim_command('mark a')
     nvim_command('2')
     nvim_command('kb')
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset()
     nvim_command('edit ' .. testfilename)
     nvim_command('normal! `a')
@@ -92,7 +93,7 @@ describe('ShaDa support code', function()
   it('is able to dump and read back mark "', function()
     nvim_command('edit ' .. testfilename)
     nvim_command('2')
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset()
     nvim_command('edit ' .. testfilename)
     nvim_command('normal! `"')
@@ -104,7 +105,7 @@ describe('ShaDa support code', function()
     nvim_command('tabedit ' .. testfilename_2)
     nvim_command('2')
     nvim_command('q!')
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset()
     nvim_command('edit ' .. testfilename_2)
     nvim_command('normal! `"')
@@ -116,7 +117,7 @@ describe('ShaDa support code', function()
     local tf_full = curbufmeths.get_name()
     nvim_command('edit ' .. testfilename_2)
     local tf_full_2 = curbufmeths.get_name()
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset()
     local oldfiles = meths.get_vvar('oldfiles')
     table.sort(oldfiles)
@@ -145,7 +146,7 @@ describe('ShaDa support code', function()
     nvim_command('enew')
     nvim_command('normal! gg')
     local saved = exec_capture('jumps')
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset()
     eq(saved, exec_capture('jumps'))
   end)
@@ -176,7 +177,7 @@ describe('ShaDa support code', function()
     nvim_command('normal! G')
     nvim_command('sleep 2')
     nvim_command('normal! gg')
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset()
     nvim_command('redraw')
     nvim_command('edit ' .. testfilename)
@@ -200,7 +201,7 @@ describe('ShaDa support code', function()
     nvim_command('edit ' .. testfilename)
     nvim_command('normal! Gra')
     nvim_command('normal! ggrb')
-    nvim_command('qall!')
+    expect_exit(nvim_command, 'qall!')
     reset()
     nvim_command('edit ' .. testfilename)
     nvim_command('normal! Gg;')
diff --git a/test/functional/shada/registers_spec.lua b/test/functional/shada/registers_spec.lua
index 1f06cbe35..6aaa54cce 100644
--- a/test/functional/shada/registers_spec.lua
+++ b/test/functional/shada/registers_spec.lua
@@ -4,6 +4,7 @@ local nvim_command, funcs, eq = helpers.command, helpers.funcs, helpers.eq
 
 local shada_helpers = require('test.functional.shada.helpers')
 local reset, clear = shada_helpers.reset, shada_helpers.clear
+local expect_exit = helpers.expect_exit
 
 local setreg = function(name, contents, typ)
   if type(contents) == 'string' then
@@ -27,7 +28,7 @@ describe('ShaDa support code', function()
     setreg('c', {'d', 'e', ''}, 'c')
     setreg('l', {'a', 'b', 'cde'}, 'l')
     setreg('b', {'bca', 'abc', 'cba'}, 'b3')
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset()
     eq({{'d', 'e', ''}, 'v'}, getreg('c'))
     eq({{'a', 'b', 'cde'}, 'V'}, getreg('l'))
@@ -39,7 +40,7 @@ describe('ShaDa support code', function()
     setreg('c', {'d', 'e', ''}, 'c')
     setreg('l', {'a', 'b', 'cde'}, 'l')
     setreg('b', {'bca', 'abc', 'cba'}, 'b3')
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset()
     eq({{}, ''}, getreg('c'))
     eq({{}, ''}, getreg('l'))
@@ -50,7 +51,7 @@ describe('ShaDa support code', function()
     setreg('c', {'d', 'e', ''}, 'c')
     setreg('l', {'a', 'b', 'cde'}, 'l')
     setreg('b', {'bca', 'abc', 'cba'}, 'b3')
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset('set shada=\'0,<0')
     eq({{'d', 'e', ''}, 'v'}, getreg('c'))
     eq({{'a', 'b', 'cde'}, 'V'}, getreg('l'))
@@ -62,7 +63,7 @@ describe('ShaDa support code', function()
     setreg('c', {'d', 'e', ''}, 'c')
     setreg('l', {'a', 'b', 'cde'}, 'l')
     setreg('b', {'bca', 'abc', 'cba'}, 'b3')
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset()
     eq({{}, ''}, getreg('c'))
     eq({{}, ''}, getreg('l'))
@@ -73,7 +74,7 @@ describe('ShaDa support code', function()
     setreg('c', {'d', 'e', ''}, 'c')
     setreg('l', {'a', 'b', 'cde'}, 'l')
     setreg('b', {'bca', 'abc', 'cba'}, 'b3')
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset('set shada=\'0,\\"0')
     eq({{'d', 'e', ''}, 'v'}, getreg('c'))
     eq({{'a', 'b', 'cde'}, 'V'}, getreg('l'))
@@ -85,7 +86,7 @@ describe('ShaDa support code', function()
     setreg('c', {'d', 'e', ''}, 'c')
     setreg('l', {'a', 'b', 'cde'}, 'l')
     setreg('b', {'bca', 'abc', 'cba'}, 'b3')
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset()
     eq({{'d', 'e', ''}, 'v'}, getreg('c'))
     eq({{'a', 'b', 'cde'}, 'V'}, getreg('l'))
@@ -96,7 +97,7 @@ describe('ShaDa support code', function()
     nvim_command('set shada=\'0,<2')
     setreg('o', {'d'}, 'c')
     setreg('t', {'a', 'b', 'cde'}, 'l')
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset()
     eq({{'d'}, 'v'}, getreg('o'))
     eq({{}, ''}, getreg('t'))
@@ -106,7 +107,7 @@ describe('ShaDa support code', function()
     nvim_command('set shada=\'0,\\"2')
     setreg('o', {'d'}, 'c')
     setreg('t', {'a', 'b', 'cde'}, 'l')
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset()
     eq({{'d'}, 'v'}, getreg('o'))
     eq({{}, ''}, getreg('t'))
@@ -117,7 +118,7 @@ describe('ShaDa support code', function()
     setreg('o', {'d'}, 'c')
     setreg('t', {'a', 'b', 'cde'}, 'l')
     setreg('h', {'abc', 'acb', 'bac', 'bca', 'cab', 'cba'}, 'b3')
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset()
     eq({{'d'}, 'v'}, getreg('o'))
     eq({{'a', 'b', 'cde'}, 'V'}, getreg('t'))
@@ -128,7 +129,7 @@ describe('ShaDa support code', function()
   function()
     reset()
     setreg('e', {'«'}, 'c')
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset()
     eq({{'«'}, 'v'}, getreg('e'))
   end)
@@ -138,7 +139,7 @@ describe('ShaDa support code', function()
     reset()
     -- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1
     setreg('e', {'\171«'}, 'c')
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset()
     eq({{'\171«'}, 'v'}, getreg('e'))
   end)
@@ -148,7 +149,7 @@ describe('ShaDa support code', function()
     setreg('1', {'one'}, 'c')
     setreg('2', {'two'}, 'c')
     setreg('a', {'a'}, 'c')
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset()
     eq({{}, ''}, getreg('0'))
     eq({{'one'}, 'v'}, getreg('1'))
@@ -161,7 +162,7 @@ describe('ShaDa support code', function()
     setreg('0', {'zero'}, 'c')
     setreg('1', {'one'}, 'c')
     setreg('2', {'two'}, 'c')
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset()
     eq({{'zero'}, 'v'}, getreg('0'))
     eq({{'one'}, 'v'}, getreg('1'))
@@ -173,7 +174,7 @@ describe('ShaDa support code', function()
     setreg('0', {'zero'}, 'c')
     setreg('1', {'one'}, 'cu')
     setreg('2', {'two'}, 'c')
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset()
     eq({{'zero'}, 'v'}, getreg('0'))
     eq({{'one'}, 'v'}, getreg('1'))
diff --git a/test/functional/shada/variables_spec.lua b/test/functional/shada/variables_spec.lua
index 854add136..a91b7eb19 100644
--- a/test/functional/shada/variables_spec.lua
+++ b/test/functional/shada/variables_spec.lua
@@ -2,6 +2,7 @@
 local helpers = require('test.functional.helpers')(after_each)
 local meths, funcs, nvim_command, eq, eval =
   helpers.meths, helpers.funcs, helpers.command, helpers.eq, helpers.eval
+local expect_exit = helpers.expect_exit
 
 local shada_helpers = require('test.functional.shada.helpers')
 local reset, clear = shada_helpers.reset, shada_helpers.clear
@@ -33,7 +34,7 @@ describe('ShaDa support code', function()
       local vartype = eval('type(g:' .. varname .. ')')
       -- Exit during `reset` is not a regular exit: it does not write shada
       -- automatically
-      nvim_command('qall')
+      expect_exit(nvim_command, 'qall')
       reset('set shada+=!')
       eq(vartype, eval('type(g:' .. varname .. ')'))
       eq(varval, meths.get_var(varname))
@@ -98,7 +99,7 @@ describe('ShaDa support code', function()
     meths.set_var('LSTVAR', {'«'})
     meths.set_var('DCTVAR', {['«']='«'})
     meths.set_var('NESTEDVAR', {['«']={{'«'}, {['«']='«'}, {a='Test'}}})
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset()
     eq('«', meths.get_var('STRVAR'))
     eq({'«'}, meths.get_var('LSTVAR'))
@@ -116,7 +117,7 @@ describe('ShaDa support code', function()
     meths.set_var('DCTVAR', {['«\171']='«\171'})
     meths.set_var('NESTEDVAR', {['\171']={{'\171«'}, {['\171']='\171'},
                                 {a='Test'}}})
-    nvim_command('qall')
+    expect_exit(nvim_command, 'qall')
     reset()
     eq('\171', meths.get_var('STRVAR'))
     eq({'\171'}, meths.get_var('LSTVAR'))
diff --git a/test/functional/ui/syntax_conceal_spec.lua b/test/functional/ui/syntax_conceal_spec.lua
index 9d10c55cb..f79059714 100644
--- a/test/functional/ui/syntax_conceal_spec.lua
+++ b/test/functional/ui/syntax_conceal_spec.lua
@@ -4,6 +4,7 @@ local clear, feed, command = helpers.clear, helpers.feed, helpers.command
 local eq = helpers.eq
 local insert = helpers.insert
 local poke_eventloop = helpers.poke_eventloop
+local expect_exit = helpers.expect_exit
 
 describe('Screen', function()
   local screen
@@ -1003,7 +1004,7 @@ describe('Screen', function()
   -- test/functional/ui/syntax_conceal_spec.lua.
   describe('concealed line after window scroll', function()
     after_each(function()
-      command(':qall!')
+      expect_exit(command, ':qall!')
       os.remove('Xcolesearch')
     end)
 
diff --git a/third-party/cmake/BuildLuarocks.cmake b/third-party/cmake/BuildLuarocks.cmake
index 065027d86..6933d263f 100644
--- a/third-party/cmake/BuildLuarocks.cmake
+++ b/third-party/cmake/BuildLuarocks.cmake
@@ -219,7 +219,7 @@ if(USE_BUNDLED_BUSTED)
   # nvim-client: https://github.com/neovim/lua-client
   add_custom_command(OUTPUT ${ROCKS_DIR}/nvim-client
     COMMAND ${LUAROCKS_BINARY}
-    ARGS build nvim-client 0.2.2-1 ${LUAROCKS_BUILDARGS}
+    ARGS build nvim-client 0.2.4-1 ${LUAROCKS_BUILDARGS}
     DEPENDS luv)
   add_custom_target(nvim-client DEPENDS ${ROCKS_DIR}/nvim-client)
 
