aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ex_cmds/oldfiles_spec.lua
diff options
context:
space:
mode:
authorJohn Szakmeister <john@szakmeister.net>2015-11-16 05:31:20 -0500
committerJohn Szakmeister <john@szakmeister.net>2015-11-16 08:29:45 -0500
commitd4f3d819d8e7cb0381ab804868db14ede568fb3b (patch)
treee2312dde720033d528ba6b6d5406aaad904ed08c /test/functional/ex_cmds/oldfiles_spec.lua
parent86ce65ebe9946096438879190cce724af7fdba21 (diff)
downloadrneovim-d4f3d819d8e7cb0381ab804868db14ede568fb3b.tar.gz
rneovim-d4f3d819d8e7cb0381ab804868db14ede568fb3b.tar.bz2
rneovim-d4f3d819d8e7cb0381ab804868db14ede568fb3b.zip
Workaround the unstable ordering of v:oldfiles in some more tests.
Fixes #3676. Reviewed-by: Marco Hinz <mh.codebro@gmail.com>
Diffstat (limited to 'test/functional/ex_cmds/oldfiles_spec.lua')
-rw-r--r--test/functional/ex_cmds/oldfiles_spec.lua25
1 files changed, 18 insertions, 7 deletions
diff --git a/test/functional/ex_cmds/oldfiles_spec.lua b/test/functional/ex_cmds/oldfiles_spec.lua
index d54e43f6cb..e02f42cd12 100644
--- a/test/functional/ex_cmds/oldfiles_spec.lua
+++ b/test/functional/ex_cmds/oldfiles_spec.lua
@@ -3,7 +3,7 @@ local helpers = require('test.functional.helpers')
local buf, eq, execute = helpers.curbufmeths, helpers.eq, helpers.execute
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'
@@ -35,16 +35,15 @@ describe(':oldfiles', function()
screen = Screen.new(100, 5)
screen:attach()
execute('edit testfile1')
- local filename1 = buf.get_name()
execute('edit testfile2')
- local filename2 = buf.get_name()
execute('wshada ' .. shada_file)
execute('rshada! ' .. shada_file)
+ local oldfiles = helpers.meths.get_vvar('oldfiles')
execute('oldfiles')
screen:expect([[
testfile2 |
- 1: ]].. add_padding(filename1) ..[[ |
- 2: ]].. add_padding(filename2) ..[[ |
+ 1: ]].. add_padding(oldfiles[1]) ..[[ |
+ 2: ]].. add_padding(oldfiles[2]) ..[[ |
|
Press ENTER or type command to continue^ |
]])
@@ -53,15 +52,27 @@ end)
describe(':oldfiles!', function()
local filename
+ local filename2
+ local oldfiles
before_each(function()
_clear()
execute('edit testfile1')
- execute('edit testfile2')
filename = buf.get_name()
+ execute('edit testfile2')
+ filename2 = buf.get_name()
execute('wshada ' .. shada_file)
_clear()
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!')
end)
@@ -71,7 +82,7 @@ describe(':oldfiles!', function()
it('provides a prompt and edits the chosen file', function()
feed('2<cr>')
- eq(filename, buf.get_name())
+ eq(oldfiles[2], buf.get_name())
end)
it('provides a prompt and does nothing on <cr>', function()