mirror of
https://github.com/neovim/neovim.git
synced 2026-08-29 18:41:48 +00:00
Merge #5872 justinmk/test_autochdir
This commit is contained in:
@@ -14,6 +14,7 @@ local neq = global_helpers.neq
|
||||
local eq = global_helpers.eq
|
||||
local ok = global_helpers.ok
|
||||
|
||||
local start_dir = lfs.currentdir()
|
||||
local nvim_prog = os.getenv('NVIM_PROG') or 'build/bin/nvim'
|
||||
local nvim_argv = {nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N',
|
||||
'--cmd', 'set shortmess+=I background=light noswapfile noautoindent laststatus=1 undodir=. directory=. viewdir=. backupdir=.',
|
||||
@@ -440,6 +441,12 @@ end
|
||||
|
||||
local function rmdir(path)
|
||||
local ret, _ = pcall(do_rmdir, path)
|
||||
if not ret and os_name() == "windows" then
|
||||
-- Maybe "Permission denied"; try again after changing the nvim
|
||||
-- process to the top-level directory.
|
||||
nvim_command([[exe 'cd '.fnameescape(']]..start_dir.."')")
|
||||
ret, _ = pcall(do_rmdir, path)
|
||||
end
|
||||
-- During teardown, the nvim process may not exit quickly enough, then rmdir()
|
||||
-- will fail (on Windows).
|
||||
if not ret then -- Try again.
|
||||
|
||||
26
test/functional/legacy/autochdir_spec.lua
Normal file
26
test/functional/legacy/autochdir_spec.lua
Normal file
@@ -0,0 +1,26 @@
|
||||
local lfs = require('lfs')
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local clear, eq = helpers.clear, helpers.eq
|
||||
local eval, execute = helpers.eval, helpers.execute
|
||||
|
||||
describe('autochdir behavior', function()
|
||||
local dir = 'Xtest-functional-legacy-autochdir'
|
||||
|
||||
before_each(function()
|
||||
lfs.mkdir(dir)
|
||||
clear()
|
||||
end)
|
||||
|
||||
after_each(function()
|
||||
helpers.rmdir(dir)
|
||||
end)
|
||||
|
||||
-- Tests vim/vim/777 without test_autochdir().
|
||||
it('sets filename', function()
|
||||
execute('set acd')
|
||||
execute('new')
|
||||
execute('w '..dir..'/Xtest')
|
||||
eq('Xtest', eval("expand('%')"))
|
||||
eq(dir, eval([[substitute(getcwd(), '.*[/\\]\(\k*\)', '\1', '')]]))
|
||||
end)
|
||||
end)
|
||||
Reference in New Issue
Block a user