aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-04-27 15:51:44 +0800
committerGitHub <noreply@github.com>2023-04-27 15:51:44 +0800
commitd321deb4a9b05e9d81b79ac166274f4a6e7981bf (patch)
tree195446b3e2668a53edb44e93223905b9939073d6
parentd1bb9bffd5e86d30696969e001af3c3db8ed4bcf (diff)
downloadrneovim-d321deb4a9b05e9d81b79ac166274f4a6e7981bf.tar.gz
rneovim-d321deb4a9b05e9d81b79ac166274f4a6e7981bf.tar.bz2
rneovim-d321deb4a9b05e9d81b79ac166274f4a6e7981bf.zip
test: fix dependencies between test cases (#23343)
Discovered using --shuffle argument of busted.
-rw-r--r--test/functional/autocmd/tabnewentered_spec.lua4
-rw-r--r--test/functional/editor/fold_spec.lua22
-rw-r--r--test/functional/editor/put_spec.lua2
-rw-r--r--test/functional/lua/secure_spec.lua12
-rw-r--r--test/functional/plugin/shada_spec.lua4
-rw-r--r--test/functional/ui/inccommand_spec.lua31
-rw-r--r--test/functional/ui/output_spec.lua2
-rw-r--r--test/functional/vimscript/environ_spec.lua2
-rw-r--r--test/functional/vimscript/executable_spec.lua6
9 files changed, 49 insertions, 36 deletions
diff --git a/test/functional/autocmd/tabnewentered_spec.lua b/test/functional/autocmd/tabnewentered_spec.lua
index b186aa1f50..f3443f317d 100644
--- a/test/functional/autocmd/tabnewentered_spec.lua
+++ b/test/functional/autocmd/tabnewentered_spec.lua
@@ -21,9 +21,9 @@ describe('TabNewEntered', function()
end)
describe('with FILE as <afile>', function()
it('matches when opening a new tab for FILE', function()
+ clear()
nvim('command', 'au! TabNewEntered Xtest-tabnewentered echom "tabnewentered:match"')
- eq('tabnewentered:4:4\ntabnewentered:match',
- nvim('exec', 'tabnew Xtest-tabnewentered', true))
+ eq('tabnewentered:match', nvim('exec', 'tabnew Xtest-tabnewentered', true))
end)
end)
describe('with CTRL-W T', function()
diff --git a/test/functional/editor/fold_spec.lua b/test/functional/editor/fold_spec.lua
index 3115c20410..0ed9d1ba80 100644
--- a/test/functional/editor/fold_spec.lua
+++ b/test/functional/editor/fold_spec.lua
@@ -58,11 +58,11 @@ describe('Folds', function()
describe('adjusting folds after :move', function()
local function manually_fold_indent()
-- setting foldmethod twice is a trick to get vim to set the folds for me
- command('set foldmethod=indent')
- command('set foldmethod=manual')
+ command('setlocal foldmethod=indent')
+ command('setlocal foldmethod=manual')
-- Ensure that all folds will get closed (makes it easier to test the
-- length of folds).
- command('set foldminlines=0')
+ command('setlocal foldminlines=0')
-- Start with all folds open (so :move ranges aren't affected by closed
-- folds).
command('%foldopen!')
@@ -83,7 +83,7 @@ describe('Folds', function()
command(move_command)
local after_move_folds = get_folds()
-- Doesn't change anything, but does call foldUpdateAll()
- command('set foldminlines=0')
+ command('setlocal foldminlines=0')
eq(after_move_folds, get_folds())
-- Set up the buffer with insert_string for the manual fold testing.
command('enew!')
@@ -279,7 +279,7 @@ a]], '13m7')
a
a
]])
- command('set foldmethod=indent')
+ command('setlocal foldmethod=indent')
command('2')
command('%foldopen')
command('read ' .. tempfname)
@@ -317,7 +317,7 @@ a]], '13m7')
a
a
]])
- command('set foldmethod=indent')
+ command('setlocal foldmethod=indent')
command('3,5d')
eq(5, funcs.foldclosedend(1))
end)
@@ -333,7 +333,7 @@ a]], '13m7')
}}}
]])
- command('set foldmethod=marker')
+ command('setlocal foldmethod=marker')
command('3,5d')
command('%foldclose')
eq(2, funcs.foldclosedend(1))
@@ -372,7 +372,7 @@ a]], '13m7')
a
a
]])
- command('set foldmethod=expr foldexpr=TestFoldExpr(v:lnum)')
+ command('setlocal foldmethod=expr foldexpr=TestFoldExpr(v:lnum)')
command('2')
command('foldopen')
command('read ' .. tempfname)
@@ -386,7 +386,7 @@ a]], '13m7')
end)
it('no folds remain if :delete makes buffer empty #19671', function()
- command('set foldmethod=manual')
+ command('setlocal foldmethod=manual')
funcs.setline(1, {'foo', 'bar', 'baz'})
command('2,3fold')
command('%delete')
@@ -394,7 +394,7 @@ a]], '13m7')
end)
it('multibyte fold markers work #20438', function()
- command('set foldmethod=marker foldmarker=«,» commentstring=/*%s*/')
+ command('setlocal foldmethod=marker foldmarker=«,» commentstring=/*%s*/')
insert([[
bbbbb
bbbbb
@@ -412,7 +412,7 @@ a]], '13m7')
a
b
]])
- command('set foldmethod=indent shiftwidth=2')
+ command('setlocal foldmethod=indent shiftwidth=2')
feed('gg0<C-v>jI <Esc>') -- indent both lines using visual blockwise mode
eq(1, funcs.foldlevel(1))
eq(1, funcs.foldlevel(2))
diff --git a/test/functional/editor/put_spec.lua b/test/functional/editor/put_spec.lua
index fb55b71e43..47068470bb 100644
--- a/test/functional/editor/put_spec.lua
+++ b/test/functional/editor/put_spec.lua
@@ -902,6 +902,8 @@ describe('put command', function()
end
end
end, unchanged=(not should_ring)}
+ screen.bell = false
+ screen.visualbell = false
end
it('should not ring the bell with gp at end of line', function()
diff --git a/test/functional/lua/secure_spec.lua b/test/functional/lua/secure_spec.lua
index c4abf70f64..2348a193de 100644
--- a/test/functional/lua/secure_spec.lua
+++ b/test/functional/lua/secure_spec.lua
@@ -19,21 +19,14 @@ describe('vim.secure', function()
local xstate = 'Xstate'
setup(function()
+ clear{env={XDG_STATE_HOME=xstate}}
helpers.mkdir_p(xstate .. pathsep .. (is_os('win') and 'nvim-data' or 'nvim'))
- end)
-
- teardown(function()
- helpers.rmdir(xstate)
- end)
-
- before_each(function()
helpers.write_file('Xfile', [[
let g:foobar = 42
]])
- clear{env={XDG_STATE_HOME=xstate}}
end)
- after_each(function()
+ teardown(function()
os.remove('Xfile')
helpers.rmdir(xstate)
end)
@@ -175,6 +168,7 @@ describe('vim.secure', function()
local xstate = 'Xstate'
setup(function()
+ clear{env={XDG_STATE_HOME=xstate}}
helpers.mkdir_p(xstate .. pathsep .. (is_os('win') and 'nvim-data' or 'nvim'))
end)
diff --git a/test/functional/plugin/shada_spec.lua b/test/functional/plugin/shada_spec.lua
index 93cf6d2b77..f6145a5809 100644
--- a/test/functional/plugin/shada_spec.lua
+++ b/test/functional/plugin/shada_spec.lua
@@ -2150,6 +2150,7 @@ describe('plugin/shada.vim', function()
teardown(function()
os.remove(fname)
+ os.remove(fname .. '.tst')
os.remove(fname_tmp)
end)
@@ -2419,6 +2420,9 @@ describe('plugin/shada.vim', function()
it('event SourceCmd', function()
reset(fname)
+ finally(function()
+ nvim_command('set shadafile=NONE') -- Avoid writing shada file on exit
+ end)
wshada('\004\000\006\146\000\196\002ab')
wshada_tmp('\004\001\006\146\000\196\002bc')
eq(0, exc_exec('source ' .. fname))
diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua
index 96634be327..a67db78cbe 100644
--- a/test/functional/ui/inccommand_spec.lua
+++ b/test/functional/ui/inccommand_spec.lua
@@ -745,10 +745,11 @@ describe(":substitute, 'inccommand' preserves undo", function()
end)
describe(":substitute, inccommand=split", function()
- local screen = Screen.new(30,15)
+ local screen
before_each(function()
clear()
+ screen = Screen.new(30,15)
common_setup(screen, "split", default_text .. default_text)
end)
@@ -1413,10 +1414,11 @@ describe(":substitute, inccommand=split", function()
end)
describe("inccommand=nosplit", function()
- local screen = Screen.new(20,10)
+ local screen
before_each(function()
clear()
+ screen = Screen.new(20,10)
common_setup(screen, "nosplit", default_text .. default_text)
end)
@@ -1644,11 +1646,12 @@ describe("inccommand=nosplit", function()
end)
describe(":substitute, 'inccommand' with a failing expression", function()
- local screen = Screen.new(20,10)
+ local screen
local cases = { "", "split", "nosplit" }
local function refresh(case)
clear()
+ screen = Screen.new(20,10)
common_setup(screen, case, default_text)
end
@@ -2127,9 +2130,10 @@ describe("'inccommand' with 'gdefault'", function()
end)
describe(":substitute", function()
- local screen = Screen.new(30,15)
+ local screen
before_each(function()
clear()
+ screen = Screen.new(30,15)
end)
it("inccommand=split, highlights multiline substitutions", function()
@@ -2335,8 +2339,7 @@ describe(":substitute", function()
]])
end)
- it("inccommand=split, substitutions of different length",
- function()
+ it("inccommand=split, substitutions of different length", function()
common_setup(screen, "split", "T T123 T2T TTT T090804\nx")
feed(":%s/T\\([0-9]\\+\\)/\\1\\1/g")
@@ -2872,8 +2875,8 @@ it(':substitute with inccommand during :terminal activity', function()
return
end
retry(2, 40000, function()
- local screen = Screen.new(30,15)
clear()
+ local screen = Screen.new(30,15)
command("set cmdwinheight=3")
feed(([[:terminal "%s" REP 5000 xxx<cr>]]):format(testprg('shell-test')))
@@ -2893,8 +2896,8 @@ it(':substitute with inccommand during :terminal activity', function()
end)
it(':substitute with inccommand, timer-induced :redraw #9777', function()
- local screen = Screen.new(30,12)
clear()
+ local screen = Screen.new(30,12)
command('set cmdwinheight=3')
command('call timer_start(10, {-> execute("redraw")}, {"repeat":-1})')
command('call timer_start(10, {-> execute("redrawstatus")}, {"repeat":-1})')
@@ -2920,8 +2923,8 @@ it(':substitute with inccommand, timer-induced :redraw #9777', function()
end)
it(':substitute with inccommand, allows :redraw before first separator is typed #18857', function()
- local screen = Screen.new(30,6)
clear()
+ local screen = Screen.new(30,6)
common_setup(screen, 'split', 'foo bar baz\nbar baz fox\nbar foo baz')
command('hi! link NormalFloat CursorLine')
local float_buf = meths.create_buf(false, true)
@@ -2950,8 +2953,8 @@ it(':substitute with inccommand, allows :redraw before first separator is typed
end)
it(':substitute with inccommand, does not crash if range contains invalid marks', function()
- local screen = Screen.new(30, 6)
clear()
+ local screen = Screen.new(30, 6)
common_setup(screen, 'split', 'test')
feed([[:'a,'bs]])
screen:expect([[
@@ -2976,8 +2979,8 @@ it(':substitute with inccommand, does not crash if range contains invalid marks'
end)
it(':substitute with inccommand, no unnecessary redraw if preview is not shown', function()
- local screen = Screen.new(60, 6)
clear()
+ local screen = Screen.new(60, 6)
common_setup(screen, 'split', 'test')
feed(':ls<CR>')
screen:expect([[
@@ -3029,8 +3032,8 @@ it(':substitute with inccommand, no unnecessary redraw if preview is not shown',
end)
it(":substitute doesn't crash with inccommand, if undo is empty #12932", function()
- local screen = Screen.new(10,5)
clear()
+ local screen = Screen.new(10,5)
command('set undolevels=-1')
common_setup(screen, 'split', 'test')
feed(':%s/test')
@@ -3049,8 +3052,8 @@ it(":substitute doesn't crash with inccommand, if undo is empty #12932", functio
end)
it(':substitute with inccommand works properly if undo is not synced #20029', function()
- local screen = Screen.new(30, 6)
clear()
+ local screen = Screen.new(30, 6)
common_setup(screen, 'nosplit', 'foo\nbar\nbaz')
meths.set_keymap('x', '<F2>', '<Esc>`<Oaaaaa asdf<Esc>`>obbbbb asdf<Esc>V`<k:s/asdf/', {})
feed('gg0<C-V>lljj<F2>')
@@ -3086,8 +3089,8 @@ it(':substitute with inccommand works properly if undo is not synced #20029', fu
end)
it('long :%s/ with inccommand does not collapse cmdline', function()
- local screen = Screen.new(10,5)
clear()
+ local screen = Screen.new(10,5)
common_setup(screen)
command('set inccommand=nosplit')
feed(':%s/AAAAAAA', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
diff --git a/test/functional/ui/output_spec.lua b/test/functional/ui/output_spec.lua
index 954431d689..0dd1f0325c 100644
--- a/test/functional/ui/output_spec.lua
+++ b/test/functional/ui/output_spec.lua
@@ -15,6 +15,8 @@ local set_shell_powershell = helpers.set_shell_powershell
local skip = helpers.skip
local is_os = helpers.is_os
+clear() -- for has_powershell()
+
describe("shell command :!", function()
local screen
before_each(function()
diff --git a/test/functional/vimscript/environ_spec.lua b/test/functional/vimscript/environ_spec.lua
index 9e19568249..52218d3cc9 100644
--- a/test/functional/vimscript/environ_spec.lua
+++ b/test/functional/vimscript/environ_spec.lua
@@ -26,6 +26,8 @@ end)
describe('empty $HOME', function()
local original_home = os.getenv('HOME')
+ before_each(clear)
+
-- recover $HOME after each test
after_each(function()
if original_home ~= nil then
diff --git a/test/functional/vimscript/executable_spec.lua b/test/functional/vimscript/executable_spec.lua
index 43e4a29e1a..2b8e3f6218 100644
--- a/test/functional/vimscript/executable_spec.lua
+++ b/test/functional/vimscript/executable_spec.lua
@@ -137,12 +137,16 @@ describe('executable() (Windows)', function()
end)
it('system([…]), jobstart([…]) use $PATHEXT #9569', function()
+ -- Empty $PATHEXT defaults to ".com;.exe;.bat;.cmd".
+ clear({env={PATHEXT=''}})
-- Invoking `cmdscript` should find/execute `cmdscript.cmd`.
eq('much success\n', call('system', {'test/functional/fixtures/cmdscript'}))
assert(0 < call('jobstart', {'test/functional/fixtures/cmdscript'}))
end)
it('full path with extension', function()
+ -- Empty $PATHEXT defaults to ".com;.exe;.bat;.cmd".
+ clear({env={PATHEXT=''}})
-- Some executable we can expect in the test env.
local exe = 'printargs-test'
local exedir = eval("fnamemodify(v:progpath, ':h')")
@@ -153,6 +157,8 @@ describe('executable() (Windows)', function()
end)
it('full path without extension', function()
+ -- Empty $PATHEXT defaults to ".com;.exe;.bat;.cmd".
+ clear({env={PATHEXT=''}})
-- Some executable we can expect in the test env.
local exe = 'printargs-test'
local exedir = eval("fnamemodify(v:progpath, ':h')")