mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
test: enable ex_cmds/cd_spec.lua on Windows
This commit is contained in:
@@ -8,8 +8,7 @@ local call = helpers.call
|
|||||||
local clear = helpers.clear
|
local clear = helpers.clear
|
||||||
local command = helpers.command
|
local command = helpers.command
|
||||||
local exc_exec = helpers.exc_exec
|
local exc_exec = helpers.exc_exec
|
||||||
|
local pathsep = helpers.get_pathsep()
|
||||||
if helpers.pending_win32(pending) then return end
|
|
||||||
|
|
||||||
-- These directories will be created for testing
|
-- These directories will be created for testing
|
||||||
local directories = {
|
local directories = {
|
||||||
@@ -75,8 +74,8 @@ for _, cmd in ipairs {'cd', 'chdir'} do
|
|||||||
eq(0, lwd(globalwin, tabnr))
|
eq(0, lwd(globalwin, tabnr))
|
||||||
|
|
||||||
-- Window with local dir reports as such
|
-- Window with local dir reports as such
|
||||||
eq(globalDir .. '/' .. directories.window, cwd(localwin))
|
eq(globalDir .. pathsep .. directories.window, cwd(localwin))
|
||||||
eq(globalDir .. '/' .. directories.window, cwd(localwin, tabnr))
|
eq(globalDir .. pathsep .. directories.window, cwd(localwin, tabnr))
|
||||||
eq(1, lwd(localwin))
|
eq(1, lwd(localwin))
|
||||||
eq(1, lwd(localwin, tabnr))
|
eq(1, lwd(localwin, tabnr))
|
||||||
|
|
||||||
@@ -86,7 +85,7 @@ for _, cmd in ipairs {'cd', 'chdir'} do
|
|||||||
eq(0, lwd(globalwin, tabnr))
|
eq(0, lwd(globalwin, tabnr))
|
||||||
|
|
||||||
-- From new tab page, local window reports as such
|
-- From new tab page, local window reports as such
|
||||||
eq(globalDir .. '/' .. directories.window, cwd(localwin, tabnr))
|
eq(globalDir .. pathsep .. directories.window, cwd(localwin, tabnr))
|
||||||
eq(1, lwd(localwin, tabnr))
|
eq(1, lwd(localwin, tabnr))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -109,14 +108,14 @@ for _, cmd in ipairs {'cd', 'chdir'} do
|
|||||||
eq(0, lwd(-1, globaltab))
|
eq(0, lwd(-1, globaltab))
|
||||||
|
|
||||||
-- new tab reports local
|
-- new tab reports local
|
||||||
eq(globalDir .. '/' .. directories.tab, cwd(-1, 0))
|
eq(globalDir .. pathsep .. directories.tab, cwd(-1, 0))
|
||||||
eq(globalDir .. '/' .. directories.tab, cwd(-1, localtab))
|
eq(globalDir .. pathsep .. directories.tab, cwd(-1, localtab))
|
||||||
eq(1, lwd(-1, 0))
|
eq(1, lwd(-1, 0))
|
||||||
eq(1, lwd(-1, localtab))
|
eq(1, lwd(-1, localtab))
|
||||||
|
|
||||||
command('tabnext')
|
command('tabnext')
|
||||||
-- From original tab page, local reports as such
|
-- From original tab page, local reports as such
|
||||||
eq(globalDir .. '/' .. directories.tab, cwd(-1, localtab))
|
eq(globalDir .. pathsep .. directories.tab, cwd(-1, localtab))
|
||||||
eq(1, lwd(-1, localtab))
|
eq(1, lwd(-1, localtab))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
@@ -147,17 +146,17 @@ for _, cmd in ipairs {'cd', 'chdir'} do
|
|||||||
-- Create a new tab and change directory
|
-- Create a new tab and change directory
|
||||||
command('tabnew')
|
command('tabnew')
|
||||||
command('silent t' .. cmd .. ' ' .. directories.tab)
|
command('silent t' .. cmd .. ' ' .. directories.tab)
|
||||||
eq(globalDir .. '/' .. directories.tab, tcwd())
|
eq(globalDir .. pathsep .. directories.tab, tcwd())
|
||||||
|
|
||||||
-- Create a new tab and verify it has inherited the directory
|
-- Create a new tab and verify it has inherited the directory
|
||||||
command('tabnew')
|
command('tabnew')
|
||||||
eq(globalDir .. '/' .. directories.tab, tcwd())
|
eq(globalDir .. pathsep .. directories.tab, tcwd())
|
||||||
|
|
||||||
-- Change tab and change back, verify that directories are correct
|
-- Change tab and change back, verify that directories are correct
|
||||||
command('tabnext')
|
command('tabnext')
|
||||||
eq(globalDir, tcwd())
|
eq(globalDir, tcwd())
|
||||||
command('tabprevious')
|
command('tabprevious')
|
||||||
eq(globalDir .. '/' .. directories.tab, tcwd())
|
eq(globalDir .. pathsep .. directories.tab, tcwd())
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -173,7 +172,7 @@ for _, cmd in ipairs {'cd', 'chdir'} do
|
|||||||
|
|
||||||
-- Change tab-local working directory and verify it is different
|
-- Change tab-local working directory and verify it is different
|
||||||
command('silent t' .. cmd .. ' ' .. directories.tab)
|
command('silent t' .. cmd .. ' ' .. directories.tab)
|
||||||
eq(globalDir .. '/' .. directories.tab, cwd())
|
eq(globalDir .. pathsep .. directories.tab, cwd())
|
||||||
eq(cwd(), tcwd()) -- working directory maches tab directory
|
eq(cwd(), tcwd()) -- working directory maches tab directory
|
||||||
eq(1, tlwd())
|
eq(1, tlwd())
|
||||||
eq(cwd(), wcwd()) -- still no window-directory
|
eq(cwd(), wcwd()) -- still no window-directory
|
||||||
@@ -183,16 +182,16 @@ for _, cmd in ipairs {'cd', 'chdir'} do
|
|||||||
command('new')
|
command('new')
|
||||||
eq(1, tlwd()) -- Still tab-local working directory
|
eq(1, tlwd()) -- Still tab-local working directory
|
||||||
eq(0, wlwd()) -- Still no window-local working directory
|
eq(0, wlwd()) -- Still no window-local working directory
|
||||||
eq(globalDir .. '/' .. directories.tab, cwd())
|
eq(globalDir .. pathsep .. directories.tab, cwd())
|
||||||
command('silent l' .. cmd .. ' ../' .. directories.window)
|
command('silent l' .. cmd .. ' ../' .. directories.window)
|
||||||
eq(globalDir .. '/' .. directories.window, cwd())
|
eq(globalDir .. pathsep .. directories.window, cwd())
|
||||||
eq(globalDir .. '/' .. directories.tab, tcwd())
|
eq(globalDir .. pathsep .. directories.tab, tcwd())
|
||||||
eq(1, wlwd())
|
eq(1, wlwd())
|
||||||
|
|
||||||
-- Verify the first window still has the tab local directory
|
-- Verify the first window still has the tab local directory
|
||||||
command('wincmd w')
|
command('wincmd w')
|
||||||
eq(globalDir .. '/' .. directories.tab, cwd())
|
eq(globalDir .. pathsep .. directories.tab, cwd())
|
||||||
eq(globalDir .. '/' .. directories.tab, tcwd())
|
eq(globalDir .. pathsep .. directories.tab, tcwd())
|
||||||
eq(0, wlwd()) -- No window-local directory
|
eq(0, wlwd()) -- No window-local directory
|
||||||
|
|
||||||
-- Change back to initial tab and verify working directory has stayed
|
-- Change back to initial tab and verify working directory has stayed
|
||||||
@@ -203,10 +202,10 @@ for _, cmd in ipairs {'cd', 'chdir'} do
|
|||||||
|
|
||||||
-- Verify global changes don't affect local ones
|
-- Verify global changes don't affect local ones
|
||||||
command('silent ' .. cmd .. ' ' .. directories.global)
|
command('silent ' .. cmd .. ' ' .. directories.global)
|
||||||
eq(globalDir .. '/' .. directories.global, cwd())
|
eq(globalDir .. pathsep .. directories.global, cwd())
|
||||||
command('tabnext')
|
command('tabnext')
|
||||||
eq(globalDir .. '/' .. directories.tab, cwd())
|
eq(globalDir .. pathsep .. directories.tab, cwd())
|
||||||
eq(globalDir .. '/' .. directories.tab, tcwd())
|
eq(globalDir .. pathsep .. directories.tab, tcwd())
|
||||||
eq(0, wlwd()) -- Still no window-local directory in this window
|
eq(0, wlwd()) -- Still no window-local directory in this window
|
||||||
|
|
||||||
-- Unless the global change happened in a tab with local directory
|
-- Unless the global change happened in a tab with local directory
|
||||||
@@ -220,9 +219,9 @@ for _, cmd in ipairs {'cd', 'chdir'} do
|
|||||||
|
|
||||||
-- But not in a window with its own local directory
|
-- But not in a window with its own local directory
|
||||||
command('tabnext | wincmd w')
|
command('tabnext | wincmd w')
|
||||||
eq(globalDir .. '/' .. directories.window, cwd() )
|
eq(globalDir .. pathsep .. directories.window, cwd() )
|
||||||
eq(0 , tlwd())
|
eq(0 , tlwd())
|
||||||
eq(globalDir .. '/' .. directories.window, wcwd())
|
eq(globalDir .. pathsep .. directories.window, wcwd())
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@@ -280,6 +279,10 @@ describe("getcwd()", function ()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it("returns empty string if working directory does not exist", function()
|
it("returns empty string if working directory does not exist", function()
|
||||||
|
if helpers.iswin() then
|
||||||
|
pending('[Cannot delete working directory in Windows]')
|
||||||
|
return
|
||||||
|
end
|
||||||
command("cd "..directories.global)
|
command("cd "..directories.global)
|
||||||
command("call delete('../"..directories.global.."', 'd')")
|
command("call delete('../"..directories.global.."', 'd')")
|
||||||
eq("", helpers.eval("getcwd()"))
|
eq("", helpers.eval("getcwd()"))
|
||||||
|
@@ -641,7 +641,7 @@ local function redir_exec(cmd)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function get_pathsep()
|
local function get_pathsep()
|
||||||
return funcs.fnamemodify('.', ':p'):sub(-1)
|
return iswin() and '\\' or '/'
|
||||||
end
|
end
|
||||||
|
|
||||||
local function pathroot()
|
local function pathroot()
|
||||||
|
Reference in New Issue
Block a user