mirror of
https://github.com/neovim/neovim.git
synced 2025-09-13 23:08:16 +00:00
test: fix dependencies between test cases (#23343)
Discovered using --shuffle argument of busted.
This commit is contained in:
@@ -21,9 +21,9 @@ describe('TabNewEntered', function()
|
|||||||
end)
|
end)
|
||||||
describe('with FILE as <afile>', function()
|
describe('with FILE as <afile>', function()
|
||||||
it('matches when opening a new tab for FILE', function()
|
it('matches when opening a new tab for FILE', function()
|
||||||
|
clear()
|
||||||
nvim('command', 'au! TabNewEntered Xtest-tabnewentered echom "tabnewentered:match"')
|
nvim('command', 'au! TabNewEntered Xtest-tabnewentered echom "tabnewentered:match"')
|
||||||
eq('tabnewentered:4:4\ntabnewentered:match',
|
eq('tabnewentered:match', nvim('exec', 'tabnew Xtest-tabnewentered', true))
|
||||||
nvim('exec', 'tabnew Xtest-tabnewentered', true))
|
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
describe('with CTRL-W T', function()
|
describe('with CTRL-W T', function()
|
||||||
|
@@ -58,11 +58,11 @@ describe('Folds', function()
|
|||||||
describe('adjusting folds after :move', function()
|
describe('adjusting folds after :move', function()
|
||||||
local function manually_fold_indent()
|
local function manually_fold_indent()
|
||||||
-- setting foldmethod twice is a trick to get vim to set the folds for me
|
-- setting foldmethod twice is a trick to get vim to set the folds for me
|
||||||
command('set foldmethod=indent')
|
command('setlocal foldmethod=indent')
|
||||||
command('set foldmethod=manual')
|
command('setlocal foldmethod=manual')
|
||||||
-- Ensure that all folds will get closed (makes it easier to test the
|
-- Ensure that all folds will get closed (makes it easier to test the
|
||||||
-- length of folds).
|
-- length of folds).
|
||||||
command('set foldminlines=0')
|
command('setlocal foldminlines=0')
|
||||||
-- Start with all folds open (so :move ranges aren't affected by closed
|
-- Start with all folds open (so :move ranges aren't affected by closed
|
||||||
-- folds).
|
-- folds).
|
||||||
command('%foldopen!')
|
command('%foldopen!')
|
||||||
@@ -83,7 +83,7 @@ describe('Folds', function()
|
|||||||
command(move_command)
|
command(move_command)
|
||||||
local after_move_folds = get_folds()
|
local after_move_folds = get_folds()
|
||||||
-- Doesn't change anything, but does call foldUpdateAll()
|
-- Doesn't change anything, but does call foldUpdateAll()
|
||||||
command('set foldminlines=0')
|
command('setlocal foldminlines=0')
|
||||||
eq(after_move_folds, get_folds())
|
eq(after_move_folds, get_folds())
|
||||||
-- Set up the buffer with insert_string for the manual fold testing.
|
-- Set up the buffer with insert_string for the manual fold testing.
|
||||||
command('enew!')
|
command('enew!')
|
||||||
@@ -279,7 +279,7 @@ a]], '13m7')
|
|||||||
a
|
a
|
||||||
a
|
a
|
||||||
]])
|
]])
|
||||||
command('set foldmethod=indent')
|
command('setlocal foldmethod=indent')
|
||||||
command('2')
|
command('2')
|
||||||
command('%foldopen')
|
command('%foldopen')
|
||||||
command('read ' .. tempfname)
|
command('read ' .. tempfname)
|
||||||
@@ -317,7 +317,7 @@ a]], '13m7')
|
|||||||
a
|
a
|
||||||
a
|
a
|
||||||
]])
|
]])
|
||||||
command('set foldmethod=indent')
|
command('setlocal foldmethod=indent')
|
||||||
command('3,5d')
|
command('3,5d')
|
||||||
eq(5, funcs.foldclosedend(1))
|
eq(5, funcs.foldclosedend(1))
|
||||||
end)
|
end)
|
||||||
@@ -333,7 +333,7 @@ a]], '13m7')
|
|||||||
|
|
||||||
}}}
|
}}}
|
||||||
]])
|
]])
|
||||||
command('set foldmethod=marker')
|
command('setlocal foldmethod=marker')
|
||||||
command('3,5d')
|
command('3,5d')
|
||||||
command('%foldclose')
|
command('%foldclose')
|
||||||
eq(2, funcs.foldclosedend(1))
|
eq(2, funcs.foldclosedend(1))
|
||||||
@@ -372,7 +372,7 @@ a]], '13m7')
|
|||||||
a
|
a
|
||||||
a
|
a
|
||||||
]])
|
]])
|
||||||
command('set foldmethod=expr foldexpr=TestFoldExpr(v:lnum)')
|
command('setlocal foldmethod=expr foldexpr=TestFoldExpr(v:lnum)')
|
||||||
command('2')
|
command('2')
|
||||||
command('foldopen')
|
command('foldopen')
|
||||||
command('read ' .. tempfname)
|
command('read ' .. tempfname)
|
||||||
@@ -386,7 +386,7 @@ a]], '13m7')
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('no folds remain if :delete makes buffer empty #19671', function()
|
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'})
|
funcs.setline(1, {'foo', 'bar', 'baz'})
|
||||||
command('2,3fold')
|
command('2,3fold')
|
||||||
command('%delete')
|
command('%delete')
|
||||||
@@ -394,7 +394,7 @@ a]], '13m7')
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('multibyte fold markers work #20438', function()
|
it('multibyte fold markers work #20438', function()
|
||||||
command('set foldmethod=marker foldmarker=«,» commentstring=/*%s*/')
|
command('setlocal foldmethod=marker foldmarker=«,» commentstring=/*%s*/')
|
||||||
insert([[
|
insert([[
|
||||||
bbbbb
|
bbbbb
|
||||||
bbbbb
|
bbbbb
|
||||||
@@ -412,7 +412,7 @@ a]], '13m7')
|
|||||||
a
|
a
|
||||||
b
|
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
|
feed('gg0<C-v>jI <Esc>') -- indent both lines using visual blockwise mode
|
||||||
eq(1, funcs.foldlevel(1))
|
eq(1, funcs.foldlevel(1))
|
||||||
eq(1, funcs.foldlevel(2))
|
eq(1, funcs.foldlevel(2))
|
||||||
|
@@ -902,6 +902,8 @@ describe('put command', function()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end, unchanged=(not should_ring)}
|
end, unchanged=(not should_ring)}
|
||||||
|
screen.bell = false
|
||||||
|
screen.visualbell = false
|
||||||
end
|
end
|
||||||
|
|
||||||
it('should not ring the bell with gp at end of line', function()
|
it('should not ring the bell with gp at end of line', function()
|
||||||
|
@@ -19,21 +19,14 @@ describe('vim.secure', function()
|
|||||||
local xstate = 'Xstate'
|
local xstate = 'Xstate'
|
||||||
|
|
||||||
setup(function()
|
setup(function()
|
||||||
|
clear{env={XDG_STATE_HOME=xstate}}
|
||||||
helpers.mkdir_p(xstate .. pathsep .. (is_os('win') and 'nvim-data' or 'nvim'))
|
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', [[
|
helpers.write_file('Xfile', [[
|
||||||
let g:foobar = 42
|
let g:foobar = 42
|
||||||
]])
|
]])
|
||||||
clear{env={XDG_STATE_HOME=xstate}}
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
after_each(function()
|
teardown(function()
|
||||||
os.remove('Xfile')
|
os.remove('Xfile')
|
||||||
helpers.rmdir(xstate)
|
helpers.rmdir(xstate)
|
||||||
end)
|
end)
|
||||||
@@ -175,6 +168,7 @@ describe('vim.secure', function()
|
|||||||
local xstate = 'Xstate'
|
local xstate = 'Xstate'
|
||||||
|
|
||||||
setup(function()
|
setup(function()
|
||||||
|
clear{env={XDG_STATE_HOME=xstate}}
|
||||||
helpers.mkdir_p(xstate .. pathsep .. (is_os('win') and 'nvim-data' or 'nvim'))
|
helpers.mkdir_p(xstate .. pathsep .. (is_os('win') and 'nvim-data' or 'nvim'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@@ -2150,6 +2150,7 @@ describe('plugin/shada.vim', function()
|
|||||||
|
|
||||||
teardown(function()
|
teardown(function()
|
||||||
os.remove(fname)
|
os.remove(fname)
|
||||||
|
os.remove(fname .. '.tst')
|
||||||
os.remove(fname_tmp)
|
os.remove(fname_tmp)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -2419,6 +2420,9 @@ describe('plugin/shada.vim', function()
|
|||||||
|
|
||||||
it('event SourceCmd', function()
|
it('event SourceCmd', function()
|
||||||
reset(fname)
|
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('\004\000\006\146\000\196\002ab')
|
||||||
wshada_tmp('\004\001\006\146\000\196\002bc')
|
wshada_tmp('\004\001\006\146\000\196\002bc')
|
||||||
eq(0, exc_exec('source ' .. fname))
|
eq(0, exc_exec('source ' .. fname))
|
||||||
|
@@ -745,10 +745,11 @@ describe(":substitute, 'inccommand' preserves undo", function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
describe(":substitute, inccommand=split", function()
|
describe(":substitute, inccommand=split", function()
|
||||||
local screen = Screen.new(30,15)
|
local screen
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
|
screen = Screen.new(30,15)
|
||||||
common_setup(screen, "split", default_text .. default_text)
|
common_setup(screen, "split", default_text .. default_text)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -1413,10 +1414,11 @@ describe(":substitute, inccommand=split", function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
describe("inccommand=nosplit", function()
|
describe("inccommand=nosplit", function()
|
||||||
local screen = Screen.new(20,10)
|
local screen
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
|
screen = Screen.new(20,10)
|
||||||
common_setup(screen, "nosplit", default_text .. default_text)
|
common_setup(screen, "nosplit", default_text .. default_text)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -1644,11 +1646,12 @@ describe("inccommand=nosplit", function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
describe(":substitute, 'inccommand' with a failing expression", function()
|
describe(":substitute, 'inccommand' with a failing expression", function()
|
||||||
local screen = Screen.new(20,10)
|
local screen
|
||||||
local cases = { "", "split", "nosplit" }
|
local cases = { "", "split", "nosplit" }
|
||||||
|
|
||||||
local function refresh(case)
|
local function refresh(case)
|
||||||
clear()
|
clear()
|
||||||
|
screen = Screen.new(20,10)
|
||||||
common_setup(screen, case, default_text)
|
common_setup(screen, case, default_text)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -2127,9 +2130,10 @@ describe("'inccommand' with 'gdefault'", function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
describe(":substitute", function()
|
describe(":substitute", function()
|
||||||
local screen = Screen.new(30,15)
|
local screen
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
|
screen = Screen.new(30,15)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("inccommand=split, highlights multiline substitutions", function()
|
it("inccommand=split, highlights multiline substitutions", function()
|
||||||
@@ -2335,8 +2339,7 @@ describe(":substitute", function()
|
|||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("inccommand=split, substitutions of different length",
|
it("inccommand=split, substitutions of different length", function()
|
||||||
function()
|
|
||||||
common_setup(screen, "split", "T T123 T2T TTT T090804\nx")
|
common_setup(screen, "split", "T T123 T2T TTT T090804\nx")
|
||||||
|
|
||||||
feed(":%s/T\\([0-9]\\+\\)/\\1\\1/g")
|
feed(":%s/T\\([0-9]\\+\\)/\\1\\1/g")
|
||||||
@@ -2872,8 +2875,8 @@ it(':substitute with inccommand during :terminal activity', function()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
retry(2, 40000, function()
|
retry(2, 40000, function()
|
||||||
local screen = Screen.new(30,15)
|
|
||||||
clear()
|
clear()
|
||||||
|
local screen = Screen.new(30,15)
|
||||||
|
|
||||||
command("set cmdwinheight=3")
|
command("set cmdwinheight=3")
|
||||||
feed(([[:terminal "%s" REP 5000 xxx<cr>]]):format(testprg('shell-test')))
|
feed(([[:terminal "%s" REP 5000 xxx<cr>]]):format(testprg('shell-test')))
|
||||||
@@ -2893,8 +2896,8 @@ it(':substitute with inccommand during :terminal activity', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it(':substitute with inccommand, timer-induced :redraw #9777', function()
|
it(':substitute with inccommand, timer-induced :redraw #9777', function()
|
||||||
local screen = Screen.new(30,12)
|
|
||||||
clear()
|
clear()
|
||||||
|
local screen = Screen.new(30,12)
|
||||||
command('set cmdwinheight=3')
|
command('set cmdwinheight=3')
|
||||||
command('call timer_start(10, {-> execute("redraw")}, {"repeat":-1})')
|
command('call timer_start(10, {-> execute("redraw")}, {"repeat":-1})')
|
||||||
command('call timer_start(10, {-> execute("redrawstatus")}, {"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)
|
end)
|
||||||
|
|
||||||
it(':substitute with inccommand, allows :redraw before first separator is typed #18857', function()
|
it(':substitute with inccommand, allows :redraw before first separator is typed #18857', function()
|
||||||
local screen = Screen.new(30,6)
|
|
||||||
clear()
|
clear()
|
||||||
|
local screen = Screen.new(30,6)
|
||||||
common_setup(screen, 'split', 'foo bar baz\nbar baz fox\nbar foo baz')
|
common_setup(screen, 'split', 'foo bar baz\nbar baz fox\nbar foo baz')
|
||||||
command('hi! link NormalFloat CursorLine')
|
command('hi! link NormalFloat CursorLine')
|
||||||
local float_buf = meths.create_buf(false, true)
|
local float_buf = meths.create_buf(false, true)
|
||||||
@@ -2950,8 +2953,8 @@ it(':substitute with inccommand, allows :redraw before first separator is typed
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it(':substitute with inccommand, does not crash if range contains invalid marks', function()
|
it(':substitute with inccommand, does not crash if range contains invalid marks', function()
|
||||||
local screen = Screen.new(30, 6)
|
|
||||||
clear()
|
clear()
|
||||||
|
local screen = Screen.new(30, 6)
|
||||||
common_setup(screen, 'split', 'test')
|
common_setup(screen, 'split', 'test')
|
||||||
feed([[:'a,'bs]])
|
feed([[:'a,'bs]])
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
@@ -2976,8 +2979,8 @@ it(':substitute with inccommand, does not crash if range contains invalid marks'
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it(':substitute with inccommand, no unnecessary redraw if preview is not shown', function()
|
it(':substitute with inccommand, no unnecessary redraw if preview is not shown', function()
|
||||||
local screen = Screen.new(60, 6)
|
|
||||||
clear()
|
clear()
|
||||||
|
local screen = Screen.new(60, 6)
|
||||||
common_setup(screen, 'split', 'test')
|
common_setup(screen, 'split', 'test')
|
||||||
feed(':ls<CR>')
|
feed(':ls<CR>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
@@ -3029,8 +3032,8 @@ it(':substitute with inccommand, no unnecessary redraw if preview is not shown',
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it(":substitute doesn't crash with inccommand, if undo is empty #12932", function()
|
it(":substitute doesn't crash with inccommand, if undo is empty #12932", function()
|
||||||
local screen = Screen.new(10,5)
|
|
||||||
clear()
|
clear()
|
||||||
|
local screen = Screen.new(10,5)
|
||||||
command('set undolevels=-1')
|
command('set undolevels=-1')
|
||||||
common_setup(screen, 'split', 'test')
|
common_setup(screen, 'split', 'test')
|
||||||
feed(':%s/test')
|
feed(':%s/test')
|
||||||
@@ -3049,8 +3052,8 @@ it(":substitute doesn't crash with inccommand, if undo is empty #12932", functio
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it(':substitute with inccommand works properly if undo is not synced #20029', function()
|
it(':substitute with inccommand works properly if undo is not synced #20029', function()
|
||||||
local screen = Screen.new(30, 6)
|
|
||||||
clear()
|
clear()
|
||||||
|
local screen = Screen.new(30, 6)
|
||||||
common_setup(screen, 'nosplit', 'foo\nbar\nbaz')
|
common_setup(screen, 'nosplit', 'foo\nbar\nbaz')
|
||||||
meths.set_keymap('x', '<F2>', '<Esc>`<Oaaaaa asdf<Esc>`>obbbbb asdf<Esc>V`<k:s/asdf/', {})
|
meths.set_keymap('x', '<F2>', '<Esc>`<Oaaaaa asdf<Esc>`>obbbbb asdf<Esc>V`<k:s/asdf/', {})
|
||||||
feed('gg0<C-V>lljj<F2>')
|
feed('gg0<C-V>lljj<F2>')
|
||||||
@@ -3086,8 +3089,8 @@ it(':substitute with inccommand works properly if undo is not synced #20029', fu
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('long :%s/ with inccommand does not collapse cmdline', function()
|
it('long :%s/ with inccommand does not collapse cmdline', function()
|
||||||
local screen = Screen.new(10,5)
|
|
||||||
clear()
|
clear()
|
||||||
|
local screen = Screen.new(10,5)
|
||||||
common_setup(screen)
|
common_setup(screen)
|
||||||
command('set inccommand=nosplit')
|
command('set inccommand=nosplit')
|
||||||
feed(':%s/AAAAAAA', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
|
feed(':%s/AAAAAAA', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
|
||||||
|
@@ -15,6 +15,8 @@ local set_shell_powershell = helpers.set_shell_powershell
|
|||||||
local skip = helpers.skip
|
local skip = helpers.skip
|
||||||
local is_os = helpers.is_os
|
local is_os = helpers.is_os
|
||||||
|
|
||||||
|
clear() -- for has_powershell()
|
||||||
|
|
||||||
describe("shell command :!", function()
|
describe("shell command :!", function()
|
||||||
local screen
|
local screen
|
||||||
before_each(function()
|
before_each(function()
|
||||||
|
@@ -26,6 +26,8 @@ end)
|
|||||||
describe('empty $HOME', function()
|
describe('empty $HOME', function()
|
||||||
local original_home = os.getenv('HOME')
|
local original_home = os.getenv('HOME')
|
||||||
|
|
||||||
|
before_each(clear)
|
||||||
|
|
||||||
-- recover $HOME after each test
|
-- recover $HOME after each test
|
||||||
after_each(function()
|
after_each(function()
|
||||||
if original_home ~= nil then
|
if original_home ~= nil then
|
||||||
|
@@ -137,12 +137,16 @@ describe('executable() (Windows)', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('system([…]), jobstart([…]) use $PATHEXT #9569', function()
|
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`.
|
-- Invoking `cmdscript` should find/execute `cmdscript.cmd`.
|
||||||
eq('much success\n', call('system', {'test/functional/fixtures/cmdscript'}))
|
eq('much success\n', call('system', {'test/functional/fixtures/cmdscript'}))
|
||||||
assert(0 < call('jobstart', {'test/functional/fixtures/cmdscript'}))
|
assert(0 < call('jobstart', {'test/functional/fixtures/cmdscript'}))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('full path with extension', function()
|
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.
|
-- Some executable we can expect in the test env.
|
||||||
local exe = 'printargs-test'
|
local exe = 'printargs-test'
|
||||||
local exedir = eval("fnamemodify(v:progpath, ':h')")
|
local exedir = eval("fnamemodify(v:progpath, ':h')")
|
||||||
@@ -153,6 +157,8 @@ describe('executable() (Windows)', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('full path without extension', function()
|
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.
|
-- Some executable we can expect in the test env.
|
||||||
local exe = 'printargs-test'
|
local exe = 'printargs-test'
|
||||||
local exedir = eval("fnamemodify(v:progpath, ':h')")
|
local exedir = eval("fnamemodify(v:progpath, ':h')")
|
||||||
|
Reference in New Issue
Block a user