mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
test: fix dependencies between test cases
Discovered using --shuffle argument of busted.
(cherry picked from commit f273a5a529
)
This commit is contained in:
parent
5c26f463bb
commit
1d9ef90115
@ -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()
|
||||
|
@ -59,11 +59,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!')
|
||||
@ -84,7 +84,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!')
|
||||
@ -280,7 +280,7 @@ a]], '13m7')
|
||||
a
|
||||
a
|
||||
]])
|
||||
command('set foldmethod=indent')
|
||||
command('setlocal foldmethod=indent')
|
||||
command('2')
|
||||
command('%foldopen')
|
||||
command('read ' .. tempfname)
|
||||
@ -318,7 +318,7 @@ a]], '13m7')
|
||||
a
|
||||
a
|
||||
]])
|
||||
command('set foldmethod=indent')
|
||||
command('setlocal foldmethod=indent')
|
||||
command('3,5d')
|
||||
eq(5, funcs.foldclosedend(1))
|
||||
end)
|
||||
@ -334,7 +334,7 @@ a]], '13m7')
|
||||
|
||||
}}}
|
||||
]])
|
||||
command('set foldmethod=marker')
|
||||
command('setlocal foldmethod=marker')
|
||||
command('3,5d')
|
||||
command('%foldclose')
|
||||
eq(2, funcs.foldclosedend(1))
|
||||
@ -373,7 +373,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)
|
||||
@ -387,7 +387,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')
|
||||
@ -395,7 +395,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
|
||||
@ -413,7 +413,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))
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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))
|
||||
|
@ -771,10 +771,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)
|
||||
|
||||
@ -1439,10 +1440,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)
|
||||
|
||||
@ -1670,11 +1672,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
|
||||
|
||||
@ -2153,9 +2156,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()
|
||||
@ -2361,8 +2365,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")
|
||||
@ -2898,8 +2901,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')))
|
||||
@ -2919,8 +2922,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})')
|
||||
@ -2946,8 +2949,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)
|
||||
@ -2976,8 +2979,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([[
|
||||
@ -3002,8 +3005,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([[
|
||||
@ -3055,8 +3058,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')
|
||||
@ -3075,8 +3078,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>')
|
||||
@ -3142,8 +3145,8 @@ it(':substitute with inccommand does not unexpectedly change viewport #25697', f
|
||||
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',
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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')")
|
||||
|
Loading…
Reference in New Issue
Block a user