neovim/test/functional/ex_cmds/file_spec.lua

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
1.1 KiB
Lua
Raw Normal View History

2017-04-09 16:38:20 -07:00
local helpers = require('test.functional.helpers')(after_each)
local luv = require('luv')
2017-04-09 16:38:20 -07:00
local clear = helpers.clear
local command = helpers.command
local eq = helpers.eq
local funcs = helpers.funcs
local rmdir = helpers.rmdir
local mkdir = helpers.mkdir
2017-04-09 16:38:20 -07:00
describe(':file', function()
2024-01-02 18:09:18 -07:00
local swapdir = luv.cwd() .. '/Xtest-file_spec'
2017-04-09 16:38:20 -07:00
before_each(function()
clear()
rmdir(swapdir)
mkdir(swapdir)
2017-04-09 16:38:20 -07:00
end)
after_each(function()
command('%bwipeout!')
rmdir(swapdir)
end)
2024-01-02 18:09:18 -07:00
it('rename does not lose swapfile #6487', function()
2017-04-09 16:38:20 -07:00
local testfile = 'test-file_spec'
2024-01-02 18:09:18 -07:00
local testfile_renamed = testfile .. '-renamed'
2017-04-09 16:38:20 -07:00
-- Note: `set swapfile` *must* go after `set directory`: otherwise it may
-- attempt to create a swapfile in different directory.
2024-01-02 18:09:18 -07:00
command('set directory^=' .. swapdir .. '//')
2017-04-09 16:38:20 -07:00
command('set swapfile fileformat=unix undolevels=-1')
2024-01-02 18:09:18 -07:00
command('edit! ' .. testfile)
2017-04-09 16:38:20 -07:00
-- Before #6487 this gave "E301: Oops, lost the swap file !!!" on Windows.
2024-01-02 18:09:18 -07:00
command('file ' .. testfile_renamed)
eq(testfile_renamed .. '.swp', string.match(funcs.execute('swapname'), '[^%%]+$'))
2017-04-09 16:38:20 -07:00
end)
end)