diff options
Diffstat (limited to 'test/functional/options/defaults_spec.lua')
-rw-r--r-- | test/functional/options/defaults_spec.lua | 82 |
1 files changed, 45 insertions, 37 deletions
diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua index 4e2f2ab63e..c0d820f40e 100644 --- a/test/functional/options/defaults_spec.lua +++ b/test/functional/options/defaults_spec.lua @@ -12,13 +12,13 @@ local eq = helpers.eq local ok = helpers.ok local funcs = helpers.funcs local insert = helpers.insert -local iswin = helpers.iswin local neq = helpers.neq local mkdir = helpers.mkdir local rmdir = helpers.rmdir local alter_slashes = helpers.alter_slashes local tbl_contains = helpers.tbl_contains local expect_exit = helpers.expect_exit +local is_os = helpers.is_os describe('startup defaults', function() describe(':filetype', function() @@ -220,7 +220,9 @@ describe('startup defaults', function() end) it("'packpath'", function() - clear() + clear{ + args_rm={'runtimepath'}, + } -- Defaults to &runtimepath. eq(meths.get_option('runtimepath'), meths.get_option('packpath')) @@ -238,7 +240,7 @@ describe('startup defaults', function() describe('$NVIM_LOG_FILE', function() local xdgdir = 'Xtest-startup-xdg-logpath' - local xdgstatedir = iswin() and xdgdir..'/nvim-data' or xdgdir..'/nvim' + local xdgstatedir = is_os('win') and xdgdir..'/nvim-data' or xdgdir..'/nvim' after_each(function() os.remove('Xtest-logpath') rmdir(xdgdir) @@ -277,7 +279,7 @@ describe('XDG defaults', function() clear() local rtp = eval('split(&runtimepath, ",")') local rv = {} - local expected = (iswin() + local expected = (is_os('win') and { [[\nvim-data\site]], [[\nvim-data\site\after]], } or { '/nvim/site', '/nvim/site/after', }) @@ -325,24 +327,26 @@ describe('XDG defaults', function() return vimruntime, libdir end - local env_sep = iswin() and ';' or ':' - local data_dir = iswin() and 'nvim-data' or 'nvim' - local state_dir = iswin() and 'nvim-data' or 'nvim' - local root_path = iswin() and 'C:' or '' + local env_sep = is_os('win') and ';' or ':' + local data_dir = is_os('win') and 'nvim-data' or 'nvim' + local state_dir = is_os('win') and 'nvim-data' or 'nvim' + local root_path = is_os('win') and 'C:' or '' describe('with too long XDG variables', function() before_each(function() - clear({env={ - XDG_CONFIG_HOME=(root_path .. ('/x'):rep(4096)), - XDG_CONFIG_DIRS=(root_path .. ('/a'):rep(2048) - .. env_sep.. root_path .. ('/b'):rep(2048) - .. (env_sep .. root_path .. '/c'):rep(512)), - XDG_DATA_HOME=(root_path .. ('/X'):rep(4096)), - XDG_RUNTIME_DIR=(root_path .. ('/X'):rep(4096)), - XDG_STATE_HOME=(root_path .. ('/X'):rep(4096)), - XDG_DATA_DIRS=(root_path .. ('/A'):rep(2048) - .. env_sep .. root_path .. ('/B'):rep(2048) - .. (env_sep .. root_path .. '/C'):rep(512)), + clear({ + args_rm={'runtimepath'}, + env={ + XDG_CONFIG_HOME=(root_path .. ('/x'):rep(4096)), + XDG_CONFIG_DIRS=(root_path .. ('/a'):rep(2048) + .. env_sep.. root_path .. ('/b'):rep(2048) + .. (env_sep .. root_path .. '/c'):rep(512)), + XDG_DATA_HOME=(root_path .. ('/X'):rep(4096)), + XDG_RUNTIME_DIR=(root_path .. ('/X'):rep(4096)), + XDG_STATE_HOME=(root_path .. ('/X'):rep(4096)), + XDG_DATA_DIRS=(root_path .. ('/A'):rep(2048) + .. env_sep .. root_path .. ('/B'):rep(2048) + .. (env_sep .. root_path .. '/C'):rep(512)), }}) end) @@ -405,13 +409,15 @@ describe('XDG defaults', function() describe('with XDG variables that can be expanded', function() before_each(function() - clear({env={ - XDG_CONFIG_HOME='$XDG_DATA_HOME', - XDG_CONFIG_DIRS='$XDG_DATA_DIRS', - XDG_DATA_HOME='$XDG_CONFIG_HOME', - XDG_RUNTIME_DIR='$XDG_RUNTIME_DIR', - XDG_STATE_HOME='$XDG_CONFIG_HOME', - XDG_DATA_DIRS='$XDG_CONFIG_DIRS', + clear({ + args_rm={'runtimepath'}, + env={ + XDG_CONFIG_HOME='$XDG_DATA_HOME', + XDG_CONFIG_DIRS='$XDG_DATA_DIRS', + XDG_DATA_HOME='$XDG_CONFIG_HOME', + XDG_RUNTIME_DIR='$XDG_RUNTIME_DIR', + XDG_STATE_HOME='$XDG_CONFIG_HOME', + XDG_DATA_DIRS='$XDG_CONFIG_DIRS', }}) end) @@ -478,18 +484,20 @@ describe('XDG defaults', function() describe('with commas', function() before_each(function() - clear({env={ - XDG_CONFIG_HOME=', , ,', - XDG_CONFIG_DIRS=',-,-,' .. env_sep .. '-,-,-', - XDG_DATA_HOME=',=,=,', - XDG_STATE_HOME=',=,=,', - XDG_DATA_DIRS=',≡,≡,' .. env_sep .. '≡,≡,≡', + clear({ + args_rm={'runtimepath'}, + env={ + XDG_CONFIG_HOME=', , ,', + XDG_CONFIG_DIRS=',-,-,' .. env_sep .. '-,-,-', + XDG_DATA_HOME=',=,=,', + XDG_STATE_HOME=',=,=,', + XDG_DATA_DIRS=',≡,≡,' .. env_sep .. '≡,≡,≡', }}) end) it('are escaped properly', function() local vimruntime, libdir = vimruntime_and_libdir() - local path_sep = iswin() and '\\' or '/' + local path_sep = is_os('win') and '\\' or '/' eq(('\\, \\, \\,' .. path_sep .. 'nvim' .. ',\\,-\\,-\\,' .. path_sep .. 'nvim' .. ',-\\,-\\,-' .. path_sep .. 'nvim' @@ -541,9 +549,9 @@ end) describe('stdpath()', function() -- Windows appends 'nvim-data' instead of just 'nvim' to prevent collisions -- due to XDG_CONFIG_HOME, XDG_DATA_HOME and XDG_STATE_HOME being the same. - local datadir = iswin() and 'nvim-data' or 'nvim' - local statedir = iswin() and 'nvim-data' or 'nvim' - local env_sep = iswin() and ';' or ':' + local datadir = is_os('win') and 'nvim-data' or 'nvim' + local statedir = is_os('win') and 'nvim-data' or 'nvim' + local env_sep = is_os('win') and ';' or ':' it('acceptance', function() clear() -- Do not explicitly set any env vars. @@ -696,7 +704,7 @@ describe('stdpath()', function() context('returns a List', function() -- Some OS specific variables the system would have set. local function base_env() - if iswin() then + if is_os('win') then return { HOME='C:\\Users\\docwhat', -- technically, is not a usual PATH HOMEDRIVE='C:', |