mirror of
https://github.com/neovim/neovim.git
synced 2025-12-17 11:55:34 +00:00
Workaround the unstable ordering of v:oldfiles in some more tests.
Fixes #3676. Reviewed-by: Marco Hinz <mh.codebro@gmail.com>
This commit is contained in:
@@ -3,7 +3,7 @@ local helpers = require('test.functional.helpers')
|
|||||||
|
|
||||||
local buf, eq, execute = helpers.curbufmeths, helpers.eq, helpers.execute
|
local buf, eq, execute = helpers.curbufmeths, helpers.eq, helpers.execute
|
||||||
local feed, nvim, nvim_prog = helpers.feed, helpers.nvim, helpers.nvim_prog
|
local feed, nvim, nvim_prog = helpers.feed, helpers.nvim, helpers.nvim_prog
|
||||||
local set_session, spawn = helpers.set_session, helpers.spawn
|
local ok, set_session, spawn = helpers.ok, helpers.set_session, helpers.spawn
|
||||||
|
|
||||||
local shada_file = 'test.shada'
|
local shada_file = 'test.shada'
|
||||||
|
|
||||||
@@ -35,16 +35,15 @@ describe(':oldfiles', function()
|
|||||||
screen = Screen.new(100, 5)
|
screen = Screen.new(100, 5)
|
||||||
screen:attach()
|
screen:attach()
|
||||||
execute('edit testfile1')
|
execute('edit testfile1')
|
||||||
local filename1 = buf.get_name()
|
|
||||||
execute('edit testfile2')
|
execute('edit testfile2')
|
||||||
local filename2 = buf.get_name()
|
|
||||||
execute('wshada ' .. shada_file)
|
execute('wshada ' .. shada_file)
|
||||||
execute('rshada! ' .. shada_file)
|
execute('rshada! ' .. shada_file)
|
||||||
|
local oldfiles = helpers.meths.get_vvar('oldfiles')
|
||||||
execute('oldfiles')
|
execute('oldfiles')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
testfile2 |
|
testfile2 |
|
||||||
1: ]].. add_padding(filename1) ..[[ |
|
1: ]].. add_padding(oldfiles[1]) ..[[ |
|
||||||
2: ]].. add_padding(filename2) ..[[ |
|
2: ]].. add_padding(oldfiles[2]) ..[[ |
|
||||||
|
|
|
|
||||||
Press ENTER or type command to continue^ |
|
Press ENTER or type command to continue^ |
|
||||||
]])
|
]])
|
||||||
@@ -53,15 +52,27 @@ end)
|
|||||||
|
|
||||||
describe(':oldfiles!', function()
|
describe(':oldfiles!', function()
|
||||||
local filename
|
local filename
|
||||||
|
local filename2
|
||||||
|
local oldfiles
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
_clear()
|
_clear()
|
||||||
execute('edit testfile1')
|
execute('edit testfile1')
|
||||||
execute('edit testfile2')
|
|
||||||
filename = buf.get_name()
|
filename = buf.get_name()
|
||||||
|
execute('edit testfile2')
|
||||||
|
filename2 = buf.get_name()
|
||||||
execute('wshada ' .. shada_file)
|
execute('wshada ' .. shada_file)
|
||||||
_clear()
|
_clear()
|
||||||
execute('rshada! ' .. shada_file)
|
execute('rshada! ' .. shada_file)
|
||||||
|
|
||||||
|
-- Ensure v:oldfiles isn't busted. Since things happen so fast,
|
||||||
|
-- the ordering of v:oldfiles is unstable (it uses qsort() under-the-hood).
|
||||||
|
-- Let's verify the contents and the length of v:oldfiles before moving on.
|
||||||
|
oldfiles = helpers.meths.get_vvar('oldfiles')
|
||||||
|
eq(2, #oldfiles)
|
||||||
|
ok(filename == oldfiles[1] or filename == oldfiles[2])
|
||||||
|
ok(filename2 == oldfiles[1] or filename2 == oldfiles[2])
|
||||||
|
|
||||||
execute('oldfiles!')
|
execute('oldfiles!')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -71,7 +82,7 @@ describe(':oldfiles!', function()
|
|||||||
|
|
||||||
it('provides a prompt and edits the chosen file', function()
|
it('provides a prompt and edits the chosen file', function()
|
||||||
feed('2<cr>')
|
feed('2<cr>')
|
||||||
eq(filename, buf.get_name())
|
eq(oldfiles[2], buf.get_name())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('provides a prompt and does nothing on <cr>', function()
|
it('provides a prompt and does nothing on <cr>', function()
|
||||||
|
|||||||
Reference in New Issue
Block a user