test: enable ex_cmds/cd_spec.lua on Windows

This commit is contained in:
Jan Edmund Lazo 2017-11-11 03:14:44 -05:00
parent df99ab461e
commit d80bf3c656
2 changed files with 26 additions and 23 deletions

View File

@ -8,8 +8,7 @@ local call = helpers.call
local clear = helpers.clear
local command = helpers.command
local exc_exec = helpers.exc_exec
if helpers.pending_win32(pending) then return end
local pathsep = helpers.get_pathsep()
-- These directories will be created for testing
local directories = {
@ -75,8 +74,8 @@ for _, cmd in ipairs {'cd', 'chdir'} do
eq(0, lwd(globalwin, tabnr))
-- Window with local dir reports as such
eq(globalDir .. '/' .. directories.window, cwd(localwin))
eq(globalDir .. '/' .. directories.window, cwd(localwin, tabnr))
eq(globalDir .. pathsep .. directories.window, cwd(localwin))
eq(globalDir .. pathsep .. directories.window, cwd(localwin, tabnr))
eq(1, lwd(localwin))
eq(1, lwd(localwin, tabnr))
@ -86,7 +85,7 @@ for _, cmd in ipairs {'cd', 'chdir'} do
eq(0, lwd(globalwin, tabnr))
-- 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))
end)
@ -109,14 +108,14 @@ for _, cmd in ipairs {'cd', 'chdir'} do
eq(0, lwd(-1, globaltab))
-- new tab reports local
eq(globalDir .. '/' .. directories.tab, cwd(-1, 0))
eq(globalDir .. '/' .. directories.tab, cwd(-1, localtab))
eq(globalDir .. pathsep .. directories.tab, cwd(-1, 0))
eq(globalDir .. pathsep .. directories.tab, cwd(-1, localtab))
eq(1, lwd(-1, 0))
eq(1, lwd(-1, localtab))
command('tabnext')
-- 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))
end)
end)
@ -147,17 +146,17 @@ for _, cmd in ipairs {'cd', 'chdir'} do
-- Create a new tab and change directory
command('tabnew')
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
command('tabnew')
eq(globalDir .. '/' .. directories.tab, tcwd())
eq(globalDir .. pathsep .. directories.tab, tcwd())
-- Change tab and change back, verify that directories are correct
command('tabnext')
eq(globalDir, tcwd())
command('tabprevious')
eq(globalDir .. '/' .. directories.tab, tcwd())
eq(globalDir .. pathsep .. directories.tab, tcwd())
end)
end)
@ -173,7 +172,7 @@ for _, cmd in ipairs {'cd', 'chdir'} do
-- Change tab-local working directory and verify it is different
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(1, tlwd())
eq(cwd(), wcwd()) -- still no window-directory
@ -183,16 +182,16 @@ for _, cmd in ipairs {'cd', 'chdir'} do
command('new')
eq(1, tlwd()) -- Still tab-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)
eq(globalDir .. '/' .. directories.window, cwd())
eq(globalDir .. '/' .. directories.tab, tcwd())
eq(globalDir .. pathsep .. directories.window, cwd())
eq(globalDir .. pathsep .. directories.tab, tcwd())
eq(1, wlwd())
-- Verify the first window still has the tab local directory
command('wincmd w')
eq(globalDir .. '/' .. directories.tab, cwd())
eq(globalDir .. '/' .. directories.tab, tcwd())
eq(globalDir .. pathsep .. directories.tab, cwd())
eq(globalDir .. pathsep .. directories.tab, tcwd())
eq(0, wlwd()) -- No window-local directory
-- 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
command('silent ' .. cmd .. ' ' .. directories.global)
eq(globalDir .. '/' .. directories.global, cwd())
eq(globalDir .. pathsep .. directories.global, cwd())
command('tabnext')
eq(globalDir .. '/' .. directories.tab, cwd())
eq(globalDir .. '/' .. directories.tab, tcwd())
eq(globalDir .. pathsep .. directories.tab, cwd())
eq(globalDir .. pathsep .. directories.tab, tcwd())
eq(0, wlwd()) -- Still no window-local directory in this window
-- 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
command('tabnext | wincmd w')
eq(globalDir .. '/' .. directories.window, cwd() )
eq(globalDir .. pathsep .. directories.window, cwd() )
eq(0 , tlwd())
eq(globalDir .. '/' .. directories.window, wcwd())
eq(globalDir .. pathsep .. directories.window, wcwd())
end)
end)
end
@ -280,6 +279,10 @@ describe("getcwd()", function ()
end)
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("call delete('../"..directories.global.."', 'd')")
eq("", helpers.eval("getcwd()"))

View File

@ -641,7 +641,7 @@ local function redir_exec(cmd)
end
local function get_pathsep()
return funcs.fnamemodify('.', ':p'):sub(-1)
return iswin() and '\\' or '/'
end
local function pathroot()