mirror of
https://github.com/neovim/neovim.git
synced 2025-11-15 14:59:20 +00:00
test(autochdir_spec): use better patterns
This commit is contained in:
@@ -14,19 +14,20 @@ describe('autochdir behavior', function()
|
|||||||
before_each(function()
|
before_each(function()
|
||||||
lfs.mkdir(dir)
|
lfs.mkdir(dir)
|
||||||
clear()
|
clear()
|
||||||
|
command('set shellslash')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
after_each(function()
|
after_each(function()
|
||||||
helpers.rmdir(dir)
|
helpers.rmdir(dir)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Tests vim/vim/777 without test_autochdir().
|
-- Tests vim/vim#777 without test_autochdir().
|
||||||
it('sets filename', function()
|
it('sets filename', function()
|
||||||
command('set acd')
|
command('set acd')
|
||||||
command('new')
|
command('new')
|
||||||
command('w '..dir..'/Xtest')
|
command('w '..dir..'/Xtest')
|
||||||
eq('Xtest', eval("expand('%')"))
|
eq('Xtest', eval("expand('%')"))
|
||||||
eq(dir, eval([[substitute(getcwd(), '.*[/\\]\(\k*\)', '\1', '')]]))
|
eq(dir, eval([[substitute(getcwd(), '.*/\(\k*\)', '\1', '')]]))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it(':file in win_execute() does not cause wrong directory', function()
|
it(':file in win_execute() does not cause wrong directory', function()
|
||||||
@@ -68,11 +69,11 @@ describe('autochdir behavior', function()
|
|||||||
call('mkdir', subdir)
|
call('mkdir', subdir)
|
||||||
local winid = eval('win_getid()')
|
local winid = eval('win_getid()')
|
||||||
command('new '..subdir..'/file')
|
command('new '..subdir..'/file')
|
||||||
matches('.*'..dir..'[/\\]'..subdir, eval('getcwd()'))
|
matches(dir..'/'..subdir..'$', eval('getcwd()'))
|
||||||
command('cd ..')
|
command('cd ..')
|
||||||
matches('.*'..dir, eval('getcwd()'))
|
matches(dir..'$', eval('getcwd()'))
|
||||||
call('win_execute', winid, 'echo')
|
call('win_execute', winid, 'echo')
|
||||||
matches('.*'..dir, eval('getcwd()'))
|
matches(dir..'$', eval('getcwd()'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it(':verbose pwd shows whether autochdir is used', function()
|
it(':verbose pwd shows whether autochdir is used', function()
|
||||||
@@ -80,36 +81,36 @@ describe('autochdir behavior', function()
|
|||||||
command('cd '..dir)
|
command('cd '..dir)
|
||||||
local cwd = eval('getcwd()')
|
local cwd = eval('getcwd()')
|
||||||
command('edit global.txt')
|
command('edit global.txt')
|
||||||
matches('%[global%].*'..dir, exec_capture('verbose pwd'))
|
matches('%[global%].*'..dir..'$', exec_capture('verbose pwd'))
|
||||||
call('mkdir', subdir)
|
call('mkdir', subdir)
|
||||||
command('split '..subdir..'/local.txt')
|
command('split '..subdir..'/local.txt')
|
||||||
command('lcd '..subdir)
|
command('lcd '..subdir)
|
||||||
matches('%[window%].*'..dir..'[/\\]'..subdir, exec_capture('verbose pwd'))
|
matches('%[window%].*'..dir..'/'..subdir..'$', exec_capture('verbose pwd'))
|
||||||
command('set acd')
|
command('set acd')
|
||||||
command('wincmd w')
|
command('wincmd w')
|
||||||
matches('%[autochdir%].*'..dir, exec_capture('verbose pwd'))
|
matches('%[autochdir%].*'..dir..'$', exec_capture('verbose pwd'))
|
||||||
command('tcd '..cwd)
|
command('tcd '..cwd)
|
||||||
matches('%[tabpage%].*'..dir, exec_capture('verbose pwd'))
|
matches('%[tabpage%].*'..dir..'$', exec_capture('verbose pwd'))
|
||||||
command('cd '..cwd)
|
command('cd '..cwd)
|
||||||
matches('%[global%].*'..dir, exec_capture('verbose pwd'))
|
matches('%[global%].*'..dir..'$', exec_capture('verbose pwd'))
|
||||||
command('lcd '..cwd)
|
command('lcd '..cwd)
|
||||||
matches('%[window%].*'..dir, exec_capture('verbose pwd'))
|
matches('%[window%].*'..dir..'$', exec_capture('verbose pwd'))
|
||||||
command('edit')
|
command('edit')
|
||||||
matches('%[autochdir%].*'..dir, exec_capture('verbose pwd'))
|
matches('%[autochdir%].*'..dir..'$', exec_capture('verbose pwd'))
|
||||||
command('enew')
|
command('enew')
|
||||||
command('wincmd w')
|
command('wincmd w')
|
||||||
matches('%[autochdir%].*'..dir..'[/\\]'..subdir, exec_capture('verbose pwd'))
|
matches('%[autochdir%].*'..dir..'/'..subdir..'$', exec_capture('verbose pwd'))
|
||||||
command('wincmd w')
|
command('wincmd w')
|
||||||
matches('%[window%].*'..dir, exec_capture('verbose pwd'))
|
matches('%[window%].*'..dir..'$', exec_capture('verbose pwd'))
|
||||||
command('wincmd w')
|
command('wincmd w')
|
||||||
matches('%[autochdir%].*'..dir..'[/\\]'..subdir, exec_capture('verbose pwd'))
|
matches('%[autochdir%].*'..dir..'/'..subdir..'$', exec_capture('verbose pwd'))
|
||||||
command('set noacd')
|
command('set noacd')
|
||||||
matches('%[autochdir%].*'..dir..'[/\\]'..subdir, exec_capture('verbose pwd'))
|
matches('%[autochdir%].*'..dir..'/'..subdir..'$', exec_capture('verbose pwd'))
|
||||||
command('wincmd w')
|
command('wincmd w')
|
||||||
matches('%[window%].*'..dir, exec_capture('verbose pwd'))
|
matches('%[window%].*'..dir..'$', exec_capture('verbose pwd'))
|
||||||
command('cd '..cwd)
|
command('cd '..cwd)
|
||||||
matches('%[global%].*'..dir, exec_capture('verbose pwd'))
|
matches('%[global%].*'..dir..'$', exec_capture('verbose pwd'))
|
||||||
command('wincmd w')
|
command('wincmd w')
|
||||||
matches('%[window%].*'..dir..'[/\\]'..subdir, exec_capture('verbose pwd'))
|
matches('%[window%].*'..dir..'/'..subdir..'$', exec_capture('verbose pwd'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user