2018-01-08 17:06:59 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
|
|
|
local clear = helpers.clear
|
|
|
|
local eq = helpers.eq
|
|
|
|
local iswin = helpers.iswin
|
|
|
|
local fnamemodify = helpers.funcs.fnamemodify
|
2018-01-11 09:05:15 -07:00
|
|
|
local command = helpers.command
|
2018-01-08 17:06:59 -07:00
|
|
|
|
|
|
|
describe('fnamemodify()', function()
|
|
|
|
before_each(clear)
|
|
|
|
|
|
|
|
it('works', function()
|
|
|
|
if iswin() then
|
2018-01-11 17:16:39 -07:00
|
|
|
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()
|
2018-01-11 15:31:29 -07:00
|
|
|
local root = drive..[[\]]
|
|
|
|
eq(root, fnamemodify([[\]], ':p:h'))
|
|
|
|
eq(root, fnamemodify([[\]], ':p'))
|
|
|
|
eq(root, fnamemodify([[/]], ':p:h'))
|
|
|
|
eq(root, fnamemodify([[/]], ':p'))
|
2018-01-11 09:05:15 -07:00
|
|
|
command('set shellslash')
|
2018-01-11 15:31:29 -07:00
|
|
|
root = drive..[[/]]
|
|
|
|
eq(root, fnamemodify([[\]], ':p:h'))
|
|
|
|
eq(root, fnamemodify([[\]], ':p'))
|
|
|
|
eq(root, fnamemodify([[/]], ':p:h'))
|
|
|
|
eq(root, fnamemodify([[/]], ':p'))
|
2018-01-08 17:06:59 -07:00
|
|
|
else
|
|
|
|
eq('/', fnamemodify([[/]], ':p:h'))
|
|
|
|
eq('/', fnamemodify([[/]], ':p'))
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
end)
|