mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
test/shada_spec: avoid exit_event race #10951
Doing clear() multiple times in quick succession provokes the
`exit_event` race described in #8813.
- Avoid it by removing unnecessary reset() call.
- Replace unnecessary nested describe() blocks with it() blocks.
ref d4a0b6c4e1
This commit is contained in:
parent
79ea47d478
commit
607d610d06
@ -12,9 +12,7 @@ local shada_helpers = require('test.functional.shada.helpers')
|
||||
local get_shada_rw = shada_helpers.get_shada_rw
|
||||
|
||||
local function reset(shada_file)
|
||||
clear{ args={'-u', 'NORC',
|
||||
'-i', shada_file or 'NONE',
|
||||
}}
|
||||
clear{ args={'-u', 'NORC', '-i', shada_file or 'NONE', }}
|
||||
end
|
||||
|
||||
local mpack_eq = function(expected, mpack_result)
|
||||
@ -2143,7 +2141,7 @@ describe('plugin/shada.vim', function()
|
||||
local epoch = os.date('%Y-%m-%dT%H:%M:%S', 0)
|
||||
local eol = helpers.iswin() and '\r\n' or '\n'
|
||||
before_each(function()
|
||||
reset()
|
||||
-- Note: reset() is called explicitly in each test.
|
||||
os.remove(fname)
|
||||
os.remove(fname .. '.tst')
|
||||
os.remove(fname_tmp)
|
||||
@ -2159,8 +2157,8 @@ describe('plugin/shada.vim', function()
|
||||
mpack_eq(expected, mpack_result)
|
||||
end
|
||||
|
||||
describe('event BufReadCmd', function()
|
||||
it('works', function()
|
||||
it('event BufReadCmd', function()
|
||||
reset()
|
||||
wshada('\004\000\009\147\000\196\002ab\196\001a')
|
||||
wshada_tmp('\004\000\009\147\000\196\002ab\196\001b')
|
||||
nvim_command('edit ' .. fname)
|
||||
@ -2193,10 +2191,9 @@ describe('plugin/shada.vim', function()
|
||||
}, nvim_eval('getline(1, "$")'))
|
||||
neq(true, curbuf('get_option', 'modified'))
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('event FileReadCmd', function()
|
||||
it('works', function()
|
||||
it('event FileReadCmd', function()
|
||||
reset()
|
||||
wshada('\004\000\009\147\000\196\002ab\196\001a')
|
||||
wshada_tmp('\004\000\009\147\000\196\002ab\196\001b')
|
||||
nvim_command('$read ' .. fname)
|
||||
@ -2243,10 +2240,9 @@ describe('plugin/shada.vim', function()
|
||||
}, nvim_eval('getline(1, "$")'))
|
||||
neq(true, curbuf('get_option', 'modified'))
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('event BufWriteCmd', function()
|
||||
it('works', function()
|
||||
it('event BufWriteCmd', function()
|
||||
reset()
|
||||
nvim('set_var', 'shada#add_own_header', 0)
|
||||
curbuf('set_lines', 0, 1, true, {
|
||||
'Jump with timestamp ' .. epoch .. ':',
|
||||
@ -2299,10 +2295,9 @@ describe('plugin/shada.vim', function()
|
||||
value={c=-200, f={'foo'}, l=2, n=('A'):byte()},
|
||||
}}, fname_tmp)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('event FileWriteCmd', function()
|
||||
it('works', function()
|
||||
it('event FileWriteCmd', function()
|
||||
reset()
|
||||
nvim('set_var', 'shada#add_own_header', 0)
|
||||
curbuf('set_lines', 0, 1, true, {
|
||||
'Jump with timestamp ' .. epoch .. ':',
|
||||
@ -2338,10 +2333,9 @@ describe('plugin/shada.vim', function()
|
||||
value={n=('A'):byte()},
|
||||
}}, fname_tmp)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('event FileAppendCmd', function()
|
||||
it('works', function()
|
||||
it('event FileAppendCmd', function()
|
||||
reset()
|
||||
nvim('set_var', 'shada#add_own_header', 0)
|
||||
curbuf('set_lines', 0, 1, true, {
|
||||
'Jump with timestamp ' .. epoch .. ':',
|
||||
@ -2411,13 +2405,9 @@ describe('plugin/shada.vim', function()
|
||||
value={c=-200, f={'foo'}, l=2, n=('A'):byte()},
|
||||
}}, fname_tmp)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('event SourceCmd', function()
|
||||
before_each(function()
|
||||
it('event SourceCmd', function()
|
||||
reset(fname)
|
||||
end)
|
||||
it('works', function()
|
||||
wshada('\004\000\006\146\000\196\002ab')
|
||||
wshada_tmp('\004\001\006\146\000\196\002bc')
|
||||
eq(0, exc_exec('source ' .. fname))
|
||||
@ -2425,7 +2415,6 @@ describe('plugin/shada.vim', function()
|
||||
eq('bc', funcs.histget(':', -1))
|
||||
eq('ab', funcs.histget(':', -2))
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('ftplugin/shada.vim', function()
|
||||
|
Loading…
Reference in New Issue
Block a user