test: use helpers.pathroot() to avoid a syscall

This commit is contained in:
Jan Edmund Lazo 2018-01-29 00:05:25 -05:00
parent 0578087e5e
commit 41b3c7850f

View File

@ -18,24 +18,18 @@ describe('fnamemodify()', function()
end)
it('works', function()
local root = helpers.pathroot()
eq(root, fnamemodify([[/]], ':p:h'))
eq(root, fnamemodify([[/]], ':p'))
if iswin() then
local drive_f = io.popen('for %P in (%CD%) do @echo %~dP', 'r')
local drive = string.gsub(drive_f:read('*a'), '[\n\r]', '')
drive_f:close()
local root = drive..[[\]]
eq(root, fnamemodify([[\]], ':p:h'))
eq(root, fnamemodify([[\]], ':p'))
eq(root, fnamemodify([[/]], ':p:h'))
eq(root, fnamemodify([[/]], ':p'))
command('set shellslash')
root = drive..[[/]]
root = string.sub(root, 1, -2)..'/'
eq(root, fnamemodify([[\]], ':p:h'))
eq(root, fnamemodify([[\]], ':p'))
eq(root, fnamemodify([[/]], ':p:h'))
eq(root, fnamemodify([[/]], ':p'))
else
eq('/', fnamemodify([[/]], ':p:h'))
eq('/', fnamemodify([[/]], ':p'))
end
end)