diff --git a/test/functional/api/autocmd_spec.lua b/test/functional/api/autocmd_spec.lua index 64b28e7bf7..10e4a45254 100644 --- a/test/functional/api/autocmd_spec.lua +++ b/test/functional/api/autocmd_spec.lua @@ -1171,8 +1171,6 @@ describe('autocmd api', function() describe('nvim_create_augroup', function() before_each(function() - clear() - api.nvim_set_var('executed', 0) end) diff --git a/test/functional/api/buffer_updates_spec.lua b/test/functional/api/buffer_updates_spec.lua index 1821be66c4..5062fbaee3 100644 --- a/test/functional/api/buffer_updates_spec.lua +++ b/test/functional/api/buffer_updates_spec.lua @@ -57,7 +57,6 @@ local function editoriginal(activate, lines) lines = origlines end -- load up the file with the correct contents - clear() return open(activate, lines) end @@ -507,8 +506,6 @@ describe('API: buffer events:', function() end) it('can notify several channels at once', function() - clear() - -- create several new sessions, in addition to our main API local sessions = {} local pipe = n.new_pipename() @@ -781,8 +778,6 @@ describe('API: buffer events:', function() end) it('detaches if the buffer is unloaded/deleted/wiped', function() - -- start with a blank nvim - clear() -- need to make a new window with a buffer because :bunload doesn't let you -- unload the last buffer for _, cmd in ipairs({ 'bunload', 'bdelete', 'bwipeout' }) do @@ -798,20 +793,17 @@ describe('API: buffer events:', function() end) it('does not send the buffer content if not requested', function() - clear() local b, tick = editoriginal(false) ok(api.nvim_buf_attach(b, false, {})) expectn('nvim_buf_changedtick_event', { b, tick }) end) it('returns a proper error on nonempty options dict', function() - clear() local b = editoriginal(false) eq("Invalid key: 'builtin'", pcall_err(api.nvim_buf_attach, b, false, { builtin = 'asfd' })) end) it('nvim_buf_attach returns response after delay #8634', function() - clear() sleep(250) -- response eq(true, n.request('nvim_buf_attach', 0, false, {})) diff --git a/test/functional/api/version_spec.lua b/test/functional/api/version_spec.lua index c997819cab..e9770575ce 100644 --- a/test/functional/api/version_spec.lua +++ b/test/functional/api/version_spec.lua @@ -48,8 +48,6 @@ describe("api_info()['version']", function() end) describe('api metadata', function() - before_each(clear) - local function name_table(entries) local by_name = {} for _, e in ipairs(entries) do @@ -149,6 +147,8 @@ describe('api metadata', function() clean_level_0(old_api[level]) end end + -- No Nvim session will be used in the following tests. + n.check_close() end) it('functions are compatible with old metadata or have new level', function() diff --git a/test/functional/autocmd/completedone_spec.lua b/test/functional/autocmd/completedone_spec.lua index 46c52cca8a..cfc1963f8a 100644 --- a/test/functional/autocmd/completedone_spec.lua +++ b/test/functional/autocmd/completedone_spec.lua @@ -13,7 +13,6 @@ describe('CompleteDone', function() describe('sets v:event.reason', function() before_each(function() - clear() command('autocmd CompleteDone * let g:donereason = v:event.reason') feed('i') call('complete', call('col', '.'), { 'foo', 'bar' }) diff --git a/test/functional/core/exit_spec.lua b/test/functional/core/exit_spec.lua index aafad4c8a5..1314916168 100644 --- a/test/functional/core/exit_spec.lua +++ b/test/functional/core/exit_spec.lua @@ -58,6 +58,7 @@ end) describe(':cquit', function() local function test_cq(cmdline, exit_code, redir_msg) if redir_msg then + n.clear() eq( redir_msg, pcall_err(function() @@ -66,16 +67,13 @@ describe(':cquit', function() ) poke_eventloop() assert_alive() + n.check_close() else local p = n.spawn_wait('--cmd', cmdline) eq(exit_code, p.status) end end - before_each(function() - n.clear() - end) - it('exits with non-zero after :cquit', function() test_cq('cquit', 1, nil) end) diff --git a/test/functional/lua/fs_spec.lua b/test/functional/lua/fs_spec.lua index b7baed526b..e735f60a69 100644 --- a/test/functional/lua/fs_spec.lua +++ b/test/functional/lua/fs_spec.lua @@ -53,7 +53,7 @@ local tests_windows_paths = { 'c:\\users\\foo\\bar\\..\\', } -before_each(clear) +setup(clear) describe('vim.fs', function() describe('parents()', function() @@ -354,6 +354,10 @@ describe('vim.fs', function() command('edit test/functional/fixtures/tty-test.c') end) + after_each(function() + command('bwipe!') + end) + it('works with a single marker', function() eq(test_source_path, exec_lua([[return vim.fs.root(0, 'CMakePresets.json')]])) end) @@ -466,8 +470,9 @@ describe('vim.fs', function() eq( xdg_config_home .. '/nvim', exec_lua(function() - vim.env.XDG_CONFIG_HOME = xdg_config_home - return vim.fs.normalize('$XDG_CONFIG_HOME/nvim') + return vim._with({ env = { XDG_CONFIG_HOME = xdg_config_home } }, function() + return vim.fs.normalize('$XDG_CONFIG_HOME/nvim') + end) end) ) end) diff --git a/test/functional/lua/glob_spec.lua b/test/functional/lua/glob_spec.lua index c3d285c310..5ca38be62a 100644 --- a/test/functional/lua/glob_spec.lua +++ b/test/functional/lua/glob_spec.lua @@ -1,15 +1,10 @@ local t = require('test.testutil') -local n = require('test.functional.testnvim')() local eq = t.eq describe('glob', function() - before_each(n.clear) - local match = function(pattern, str) - return n.exec_lua(function() - return require('vim.glob').to_lpeg(pattern):match(str) ~= nil - end) + return require('vim.glob').to_lpeg(pattern):match(str) ~= nil end describe('glob matching', function() diff --git a/test/functional/lua/text_spec.lua b/test/functional/lua/text_spec.lua index 7cdec39338..05eb5cab0c 100644 --- a/test/functional/lua/text_spec.lua +++ b/test/functional/lua/text_spec.lua @@ -1,12 +1,8 @@ local t = require('test.testutil') -local n = require('test.functional.testnvim')() -local clear = n.clear local eq = t.eq describe('vim.text', function() - before_each(clear) - describe('indent()', function() it('validation', function() t.matches('size%: expected number, got string', t.pcall_err(vim.text.indent, 'x', 'x')) diff --git a/test/functional/options/keymap_spec.lua b/test/functional/options/keymap_spec.lua index f76525699f..21e6ab97ff 100644 --- a/test/functional/options/keymap_spec.lua +++ b/test/functional/options/keymap_spec.lua @@ -9,7 +9,6 @@ local exec_capture, dedent = n.exec_capture, t.dedent -- First test it's implemented using the :lmap and :lnoremap commands, then -- check those mappings behave as expected. describe("'keymap' / :lmap", function() - clear() before_each(function() clear() insert('lllaaa') diff --git a/test/functional/plugin/lsp/utils_spec.lua b/test/functional/plugin/lsp/utils_spec.lua index f0fa659372..6161529f5e 100644 --- a/test/functional/plugin/lsp/utils_spec.lua +++ b/test/functional/plugin/lsp/utils_spec.lua @@ -184,7 +184,6 @@ describe('vim.lsp.util', function() end before_each(function() - n.clear() local _ = Screen.new(80, 80) feed('79i') -- fill screen with empty lines end) @@ -280,7 +279,6 @@ describe('vim.lsp.util', function() describe('open_floating_preview', function() before_each(function() - n.clear() Screen.new(10, 10) feed('9iG4k') end) diff --git a/test/functional/treesitter/fold_spec.lua b/test/functional/treesitter/fold_spec.lua index d4a96bc28e..5c3aa19903 100644 --- a/test/functional/treesitter/fold_spec.lua +++ b/test/functional/treesitter/fold_spec.lua @@ -14,8 +14,6 @@ local poke_eventloop = n.poke_eventloop before_each(clear) describe('treesitter foldexpr', function() - clear() - before_each(function() -- open folds to avoid deleting entire folded region exec_lua([[vim.opt.foldlevel = 9]]) diff --git a/test/functional/treesitter/node_spec.lua b/test/functional/treesitter/node_spec.lua index 1354481036..ac930b434d 100644 --- a/test/functional/treesitter/node_spec.lua +++ b/test/functional/treesitter/node_spec.lua @@ -14,8 +14,6 @@ local function lua_eval(lua_expr) end describe('treesitter node API', function() - clear() - it('double free tree', function() insert('F') exec_lua(function() diff --git a/test/functional/treesitter/utils_spec.lua b/test/functional/treesitter/utils_spec.lua index 34bea349f6..6b25bbbf33 100644 --- a/test/functional/treesitter/utils_spec.lua +++ b/test/functional/treesitter/utils_spec.lua @@ -9,8 +9,6 @@ local exec_lua = n.exec_lua before_each(clear) describe('treesitter utils', function() - before_each(clear) - it('can find an ancestor', function() insert([[ int main() { diff --git a/test/functional/vimscript/functions_spec.lua b/test/functional/vimscript/functions_spec.lua index c9e412ae93..82a1497341 100644 --- a/test/functional/vimscript/functions_spec.lua +++ b/test/functional/vimscript/functions_spec.lua @@ -16,6 +16,5 @@ local is_os = t.is_os before_each(clear) it('windowsversion()', function() - clear() matches(is_os('win') and '^%d+%.%d+$' or '^$', eval('windowsversion()')) end)