win/env: fix stdpath()/XDG_* initialization, parsing #12829

- Windows environment variables are semicolon-separated, but some logic
  was assuming colon (:). This broke initialization and parsing of
  XDG_CONFIG_DIRS, XDG_DATA_DIRS, 'runtimepath', stdpath(), etc.
- test/defaults_spec: enable tests on Windows

ref #12793
This commit is contained in:
erw7 2020-09-08 14:40:12 +09:00 committed by GitHub
parent 6abbc157af
commit aa45579206
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 149 additions and 129 deletions

View File

@ -7075,7 +7075,7 @@ void get_xdg_var_list(const XDGVarType xdg, typval_T *rettv)
do {
size_t dir_len;
const char *dir;
iter = vim_env_iter(':', dirs, iter, &dir, &dir_len);
iter = vim_env_iter(ENV_SEPCHAR, dirs, iter, &dir, &dir_len);
if (dir != NULL && dir_len > 0) {
char *dir_with_nvim = xmemdupz(dir, dir_len);
dir_with_nvim = concat_fnames_realloc(dir_with_nvim, "nvim", true);

View File

@ -347,20 +347,21 @@ static char *strcpy_comma_escaped(char *dest, const char *src, const size_t len)
return &dest[len + shift];
}
/// Compute length of a colon-separated value, doubled and with some suffixes
/// Compute length of a ENV_SEPCHAR-separated value, doubled and with some
/// suffixes
///
/// @param[in] val Colon-separated array value.
/// @param[in] val ENV_SEPCHAR-separated array value.
/// @param[in] common_suf_len Length of the common suffix which is appended to
/// each item in the array, twice.
/// @param[in] single_suf_len Length of the suffix which is appended to each
/// item in the array once.
///
/// @return Length of the comma-separated string array that contains each item
/// in the original array twice with suffixes with given length
/// @return Length of the ENV_SEPCHAR-separated string array that contains each
/// item in the original array twice with suffixes with given length
/// (common_suf is present after each new item, single_suf is present
/// after half of the new items) and with commas after each item, commas
/// inside the values are escaped.
static inline size_t compute_double_colon_len(const char *const val,
static inline size_t compute_double_env_sep_len(const char *const val,
const size_t common_suf_len,
const size_t single_suf_len)
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_PURE
@ -373,7 +374,7 @@ static inline size_t compute_double_colon_len(const char *const val,
do {
size_t dir_len;
const char *dir;
iter = vim_env_iter(':', val, iter, &dir, &dir_len);
iter = vim_env_iter(ENV_SEPCHAR, val, iter, &dir, &dir_len);
if (dir != NULL && dir_len > 0) {
ret += ((dir_len + memcnt(dir, ',', dir_len) + common_suf_len
+ !after_pathsep(dir, dir + dir_len)) * 2
@ -385,13 +386,13 @@ static inline size_t compute_double_colon_len(const char *const val,
#define NVIM_SIZE (sizeof("nvim") - 1)
/// Add directories to a comma-separated array from a colon-separated one
/// Add directories to a ENV_SEPCHAR-separated array from a colon-separated one
///
/// Commas are escaped in process. To each item PATHSEP "nvim" is appended in
/// addition to suf1 and suf2.
///
/// @param[in,out] dest Destination comma-separated array.
/// @param[in] val Source colon-separated array.
/// @param[in] val Source ENV_SEPCHAR-separated array.
/// @param[in] suf1 If not NULL, suffix appended to destination. Prior to it
/// directory separator is appended. Suffix must not contain
/// commas.
@ -404,7 +405,7 @@ static inline size_t compute_double_colon_len(const char *const val,
/// Otherwise in reverse.
///
/// @return (dest + appended_characters_length)
static inline char *add_colon_dirs(char *dest, const char *const val,
static inline char *add_env_sep_dirs(char *dest, const char *const val,
const char *const suf1, const size_t len1,
const char *const suf2, const size_t len2,
const bool forward)
@ -417,8 +418,8 @@ static inline char *add_colon_dirs(char *dest, const char *const val,
do {
size_t dir_len;
const char *dir;
iter = (forward ? vim_env_iter : vim_env_iter_rev)(':', val, iter, &dir,
&dir_len);
iter = (forward ? vim_env_iter : vim_env_iter_rev)(ENV_SEPCHAR, val, iter,
&dir, &dir_len);
if (dir != NULL && dir_len > 0) {
dest = strcpy_comma_escaped(dest, dir, dir_len);
if (!after_pathsep(dest - 1, dest)) {
@ -581,9 +582,10 @@ static void set_runtimepath_default(bool clean_arg)
rtp_size += libdir_len + memcnt(libdir, ',', libdir_len) + 1;
}
}
rtp_size += compute_double_colon_len(data_dirs, NVIM_SIZE + 1 + SITE_SIZE + 1,
rtp_size += compute_double_env_sep_len(data_dirs,
NVIM_SIZE + 1 + SITE_SIZE + 1,
AFTER_SIZE + 1);
rtp_size += compute_double_colon_len(config_dirs, NVIM_SIZE + 1,
rtp_size += compute_double_env_sep_len(config_dirs, NVIM_SIZE + 1,
AFTER_SIZE + 1);
if (rtp_size == 0) {
return;
@ -592,19 +594,19 @@ static void set_runtimepath_default(bool clean_arg)
char *rtp_cur = rtp;
rtp_cur = add_dir(rtp_cur, config_home, config_len, kXDGConfigHome,
NULL, 0, NULL, 0);
rtp_cur = add_colon_dirs(rtp_cur, config_dirs, NULL, 0, NULL, 0, true);
rtp_cur = add_env_sep_dirs(rtp_cur, config_dirs, NULL, 0, NULL, 0, true);
rtp_cur = add_dir(rtp_cur, data_home, data_len, kXDGDataHome,
"site", SITE_SIZE, NULL, 0);
rtp_cur = add_colon_dirs(rtp_cur, data_dirs, "site", SITE_SIZE, NULL, 0,
rtp_cur = add_env_sep_dirs(rtp_cur, data_dirs, "site", SITE_SIZE, NULL, 0,
true);
rtp_cur = add_dir(rtp_cur, vimruntime, vimruntime_len, kXDGNone,
NULL, 0, NULL, 0);
rtp_cur = add_dir(rtp_cur, libdir, libdir_len, kXDGNone, NULL, 0, NULL, 0);
rtp_cur = add_colon_dirs(rtp_cur, data_dirs, "site", SITE_SIZE,
rtp_cur = add_env_sep_dirs(rtp_cur, data_dirs, "site", SITE_SIZE,
"after", AFTER_SIZE, false);
rtp_cur = add_dir(rtp_cur, data_home, data_len, kXDGDataHome,
"site", SITE_SIZE, "after", AFTER_SIZE);
rtp_cur = add_colon_dirs(rtp_cur, config_dirs, "after", AFTER_SIZE, NULL, 0,
rtp_cur = add_env_sep_dirs(rtp_cur, config_dirs, "after", AFTER_SIZE, NULL, 0,
false);
rtp_cur = add_dir(rtp_cur, config_home, config_len, kXDGConfigHome,
"after", AFTER_SIZE, NULL, 0);

View File

@ -290,9 +290,6 @@ describe('XDG-based defaults', function()
end)
end)
-- TODO(jkeyes): tests below fail on win32 because of path separator.
if helpers.pending_win32(pending) then return end
local function vimruntime_and_libdir()
local vimruntime = eval('$VIMRUNTIME')
-- libdir is hard to calculate reliably across various ci platforms
@ -301,71 +298,78 @@ describe('XDG-based defaults', function()
return vimruntime, libdir
end
local env_sep = iswin() and ';' or ':'
local data_dir = iswin() and 'nvim-data' or 'nvim'
local root_path = iswin() and 'C:' or ''
describe('with too long XDG variables', function()
before_each(function()
clear({env={
XDG_CONFIG_HOME=('/x'):rep(4096),
XDG_CONFIG_DIRS=(('/a'):rep(2048)
.. ':' .. ('/b'):rep(2048)
.. (':/c'):rep(512)),
XDG_DATA_HOME=('/X'):rep(4096),
XDG_DATA_DIRS=(('/A'):rep(2048)
.. ':' .. ('/B'):rep(2048)
.. (':/C'):rep(512)),
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_DATA_DIRS=(root_path .. ('/A'):rep(2048)
.. env_sep .. root_path .. ('/B'):rep(2048)
.. (env_sep .. root_path .. '/C'):rep(512)),
}})
end)
it('are correctly set', function()
local vimruntime, libdir = vimruntime_and_libdir()
eq((('/x'):rep(4096) .. '/nvim'
.. ',' .. ('/a'):rep(2048) .. '/nvim'
.. ',' .. ('/b'):rep(2048) .. '/nvim'
.. (',' .. '/c/nvim'):rep(512)
.. ',' .. ('/X'):rep(4096) .. '/nvim/site'
.. ',' .. ('/A'):rep(2048) .. '/nvim/site'
.. ',' .. ('/B'):rep(2048) .. '/nvim/site'
.. (',' .. '/C/nvim/site'):rep(512)
eq(((root_path .. ('/x'):rep(4096) .. '/nvim'
.. ',' .. root_path .. ('/a'):rep(2048) .. '/nvim'
.. ',' .. root_path .. ('/b'):rep(2048) .. '/nvim'
.. (',' .. root_path .. '/c/nvim'):rep(512)
.. ',' .. root_path .. ('/X'):rep(4096) .. '/' .. data_dir .. '/site'
.. ',' .. root_path .. ('/A'):rep(2048) .. '/nvim/site'
.. ',' .. root_path .. ('/B'):rep(2048) .. '/nvim/site'
.. (',' .. root_path .. '/C/nvim/site'):rep(512)
.. ',' .. vimruntime
.. ',' .. libdir
.. (',' .. '/C/nvim/site/after'):rep(512)
.. ',' .. ('/B'):rep(2048) .. '/nvim/site/after'
.. ',' .. ('/A'):rep(2048) .. '/nvim/site/after'
.. ',' .. ('/X'):rep(4096) .. '/nvim/site/after'
.. (',' .. '/c/nvim/after'):rep(512)
.. ',' .. ('/b'):rep(2048) .. '/nvim/after'
.. ',' .. ('/a'):rep(2048) .. '/nvim/after'
.. ',' .. ('/x'):rep(4096) .. '/nvim/after'
), meths.get_option('runtimepath'))
.. (',' .. root_path .. '/C/nvim/site/after'):rep(512)
.. ',' .. root_path .. ('/B'):rep(2048) .. '/nvim/site/after'
.. ',' .. root_path .. ('/A'):rep(2048) .. '/nvim/site/after'
.. ',' .. root_path .. ('/X'):rep(4096) .. '/' .. data_dir .. '/site/after'
.. (',' .. root_path .. '/c/nvim/after'):rep(512)
.. ',' .. root_path .. ('/b'):rep(2048) .. '/nvim/after'
.. ',' .. root_path .. ('/a'):rep(2048) .. '/nvim/after'
.. ',' .. root_path .. ('/x'):rep(4096) .. '/nvim/after'
):gsub('\\', '/')), (meths.get_option('runtimepath')):gsub('\\', '/'))
meths.command('set runtimepath&')
meths.command('set backupdir&')
meths.command('set directory&')
meths.command('set undodir&')
meths.command('set viewdir&')
eq((('/x'):rep(4096) .. '/nvim'
.. ',' .. ('/a'):rep(2048) .. '/nvim'
.. ',' .. ('/b'):rep(2048) .. '/nvim'
.. (',' .. '/c/nvim'):rep(512)
.. ',' .. ('/X'):rep(4096) .. '/nvim/site'
.. ',' .. ('/A'):rep(2048) .. '/nvim/site'
.. ',' .. ('/B'):rep(2048) .. '/nvim/site'
.. (',' .. '/C/nvim/site'):rep(512)
eq(((root_path .. ('/x'):rep(4096) .. '/nvim'
.. ',' .. root_path .. ('/a'):rep(2048) .. '/nvim'
.. ',' .. root_path .. ('/b'):rep(2048) .. '/nvim'
.. (',' .. root_path .. '/c/nvim'):rep(512)
.. ',' .. root_path .. ('/X'):rep(4096) .. '/' .. data_dir .. '/site'
.. ',' .. root_path .. ('/A'):rep(2048) .. '/nvim/site'
.. ',' .. root_path .. ('/B'):rep(2048) .. '/nvim/site'
.. (',' .. root_path .. '/C/nvim/site'):rep(512)
.. ',' .. vimruntime
.. ',' .. libdir
.. (',' .. '/C/nvim/site/after'):rep(512)
.. ',' .. ('/B'):rep(2048) .. '/nvim/site/after'
.. ',' .. ('/A'):rep(2048) .. '/nvim/site/after'
.. ',' .. ('/X'):rep(4096) .. '/nvim/site/after'
.. (',' .. '/c/nvim/after'):rep(512)
.. ',' .. ('/b'):rep(2048) .. '/nvim/after'
.. ',' .. ('/a'):rep(2048) .. '/nvim/after'
.. ',' .. ('/x'):rep(4096) .. '/nvim/after'
), meths.get_option('runtimepath'))
eq('.,' .. ('/X'):rep(4096) .. '/nvim/backup',
meths.get_option('backupdir'))
eq(('/X'):rep(4096) .. '/nvim/swap//', meths.get_option('directory'))
eq(('/X'):rep(4096) .. '/nvim/undo', meths.get_option('undodir'))
eq(('/X'):rep(4096) .. '/nvim/view', meths.get_option('viewdir'))
.. (',' .. root_path .. '/C/nvim/site/after'):rep(512)
.. ',' .. root_path .. ('/B'):rep(2048) .. '/nvim/site/after'
.. ',' .. root_path .. ('/A'):rep(2048) .. '/nvim/site/after'
.. ',' .. root_path .. ('/X'):rep(4096) .. '/' .. data_dir .. '/site/after'
.. (',' .. root_path .. '/c/nvim/after'):rep(512)
.. ',' .. root_path .. ('/b'):rep(2048) .. '/nvim/after'
.. ',' .. root_path .. ('/a'):rep(2048) .. '/nvim/after'
.. ',' .. root_path .. ('/x'):rep(4096) .. '/nvim/after'
):gsub('\\', '/')), (meths.get_option('runtimepath')):gsub('\\', '/'))
eq('.,' .. root_path .. ('/X'):rep(4096).. '/' .. data_dir .. '/backup',
(meths.get_option('backupdir'):gsub('\\', '/')))
eq(root_path .. ('/X'):rep(4096) .. '/' .. data_dir .. '/swap//',
(meths.get_option('directory')):gsub('\\', '/'))
eq(root_path .. ('/X'):rep(4096) .. '/' .. data_dir .. '/undo',
(meths.get_option('undodir')):gsub('\\', '/'))
eq(root_path .. ('/X'):rep(4096) .. '/' .. data_dir .. '/view',
(meths.get_option('viewdir')):gsub('\\', '/'))
end)
end)
@ -381,53 +385,61 @@ describe('XDG-based defaults', function()
it('are not expanded', function()
local vimruntime, libdir = vimruntime_and_libdir()
eq(('$XDG_DATA_HOME/nvim'
eq((('$XDG_DATA_HOME/nvim'
.. ',$XDG_DATA_DIRS/nvim'
.. ',$XDG_CONFIG_HOME/nvim/site'
.. ',$XDG_CONFIG_HOME/' .. data_dir .. '/site'
.. ',$XDG_CONFIG_DIRS/nvim/site'
.. ',' .. vimruntime
.. ',' .. libdir
.. ',$XDG_CONFIG_DIRS/nvim/site/after'
.. ',$XDG_CONFIG_HOME/nvim/site/after'
.. ',$XDG_CONFIG_HOME/' .. data_dir .. '/site/after'
.. ',$XDG_DATA_DIRS/nvim/after'
.. ',$XDG_DATA_HOME/nvim/after'
), meths.get_option('runtimepath'))
):gsub('\\', '/')), (meths.get_option('runtimepath')):gsub('\\', '/'))
meths.command('set runtimepath&')
meths.command('set backupdir&')
meths.command('set directory&')
meths.command('set undodir&')
meths.command('set viewdir&')
eq(('$XDG_DATA_HOME/nvim'
eq((('$XDG_DATA_HOME/nvim'
.. ',$XDG_DATA_DIRS/nvim'
.. ',$XDG_CONFIG_HOME/nvim/site'
.. ',$XDG_CONFIG_HOME/' .. data_dir .. '/site'
.. ',$XDG_CONFIG_DIRS/nvim/site'
.. ',' .. vimruntime
.. ',' .. libdir
.. ',$XDG_CONFIG_DIRS/nvim/site/after'
.. ',$XDG_CONFIG_HOME/nvim/site/after'
.. ',$XDG_CONFIG_HOME/' .. data_dir .. '/site/after'
.. ',$XDG_DATA_DIRS/nvim/after'
.. ',$XDG_DATA_HOME/nvim/after'
), meths.get_option('runtimepath'))
eq('.,$XDG_CONFIG_HOME/nvim/backup', meths.get_option('backupdir'))
eq('$XDG_CONFIG_HOME/nvim/swap//', meths.get_option('directory'))
eq('$XDG_CONFIG_HOME/nvim/undo', meths.get_option('undodir'))
eq('$XDG_CONFIG_HOME/nvim/view', meths.get_option('viewdir'))
):gsub('\\', '/')), (meths.get_option('runtimepath')):gsub('\\', '/'))
eq(('.,$XDG_CONFIG_HOME/' .. data_dir .. '/backup'),
meths.get_option('backupdir'):gsub('\\', '/'))
eq(('$XDG_CONFIG_HOME/' .. data_dir .. '/swap//'),
meths.get_option('directory'):gsub('\\', '/'))
eq(('$XDG_CONFIG_HOME/' .. data_dir .. '/undo'),
meths.get_option('undodir'):gsub('\\', '/'))
eq(('$XDG_CONFIG_HOME/' .. data_dir .. '/view'),
meths.get_option('viewdir'):gsub('\\', '/'))
meths.command('set all&')
eq(('$XDG_DATA_HOME/nvim'
.. ',$XDG_DATA_DIRS/nvim'
.. ',$XDG_CONFIG_HOME/nvim/site'
.. ',$XDG_CONFIG_HOME/' .. data_dir .. '/site'
.. ',$XDG_CONFIG_DIRS/nvim/site'
.. ',' .. vimruntime
.. ',' .. libdir
.. ',$XDG_CONFIG_DIRS/nvim/site/after'
.. ',$XDG_CONFIG_HOME/nvim/site/after'
.. ',$XDG_CONFIG_HOME/' .. data_dir .. '/site/after'
.. ',$XDG_DATA_DIRS/nvim/after'
.. ',$XDG_DATA_HOME/nvim/after'
), meths.get_option('runtimepath'))
eq('.,$XDG_CONFIG_HOME/nvim/backup', meths.get_option('backupdir'))
eq('$XDG_CONFIG_HOME/nvim/swap//', meths.get_option('directory'))
eq('$XDG_CONFIG_HOME/nvim/undo', meths.get_option('undodir'))
eq('$XDG_CONFIG_HOME/nvim/view', meths.get_option('viewdir'))
):gsub('\\', '/'), (meths.get_option('runtimepath')):gsub('\\', '/'))
eq(('.,$XDG_CONFIG_HOME/' .. data_dir .. '/backup'),
meths.get_option('backupdir'):gsub('\\', '/'))
eq(('$XDG_CONFIG_HOME/' .. data_dir .. '/swap//'),
meths.get_option('directory'):gsub('\\', '/'))
eq(('$XDG_CONFIG_HOME/' .. data_dir .. '/undo'),
meths.get_option('undodir'):gsub('\\', '/'))
eq(('$XDG_CONFIG_HOME/' .. data_dir .. '/view'),
meths.get_option('viewdir'):gsub('\\', '/'))
end)
end)
@ -435,53 +447,58 @@ describe('XDG-based defaults', function()
before_each(function()
clear({env={
XDG_CONFIG_HOME=', , ,',
XDG_CONFIG_DIRS=',-,-,:-,-,-',
XDG_CONFIG_DIRS=',-,-,' .. env_sep .. '-,-,-',
XDG_DATA_HOME=',=,=,',
XDG_DATA_DIRS=',≡,≡,:≡,≡,≡',
XDG_DATA_DIRS=',≡,≡,' .. env_sep .. '≡,≡,≡',
}})
end)
it('are escaped properly', function()
local vimruntime, libdir = vimruntime_and_libdir()
eq(('\\, \\, \\,/nvim'
.. ',\\,-\\,-\\,/nvim'
.. ',-\\,-\\,-/nvim'
.. ',\\,=\\,=\\,/nvim/site'
.. ',\\,≡\\,≡\\,/nvim/site'
.. ',≡\\,≡\\,≡/nvim/site'
local path_sep = iswin() and '\\' or '/'
eq(('\\, \\, \\,' .. path_sep .. 'nvim'
.. ',\\,-\\,-\\,' .. path_sep .. 'nvim'
.. ',-\\,-\\,-' .. path_sep .. 'nvim'
.. ',\\,=\\,=\\,' .. path_sep .. data_dir .. path_sep .. 'site'
.. ',\\,≡\\,≡\\,' .. path_sep .. 'nvim' .. path_sep .. 'site'
.. ',≡\\,≡\\,≡' .. path_sep .. 'nvim' .. path_sep .. 'site'
.. ',' .. vimruntime
.. ',' .. libdir
.. ',≡\\,≡\\,≡/nvim/site/after'
.. ',\\,≡\\,≡\\,/nvim/site/after'
.. ',\\,=\\,=\\,/nvim/site/after'
.. ',-\\,-\\,-/nvim/after'
.. ',\\,-\\,-\\,/nvim/after'
.. ',\\, \\, \\,/nvim/after'
.. ',≡\\,≡\\,≡' .. path_sep .. 'nvim' .. path_sep .. 'site' .. path_sep .. 'after'
.. ',\\,≡\\,≡\\,' .. path_sep .. 'nvim' .. path_sep .. 'site' .. path_sep .. 'after'
.. ',\\,=\\,=\\,' .. path_sep.. data_dir .. path_sep .. 'site' .. path_sep .. 'after'
.. ',-\\,-\\,-' .. path_sep .. 'nvim' .. path_sep .. 'after'
.. ',\\,-\\,-\\,' .. path_sep .. 'nvim' .. path_sep .. 'after'
.. ',\\, \\, \\,' .. path_sep .. 'nvim' .. path_sep .. 'after'
), meths.get_option('runtimepath'))
meths.command('set runtimepath&')
meths.command('set backupdir&')
meths.command('set directory&')
meths.command('set undodir&')
meths.command('set viewdir&')
eq(('\\, \\, \\,/nvim'
.. ',\\,-\\,-\\,/nvim'
.. ',-\\,-\\,-/nvim'
.. ',\\,=\\,=\\,/nvim/site'
.. ',\\,≡\\,≡\\,/nvim/site'
.. ',≡\\,≡\\,≡/nvim/site'
eq(('\\, \\, \\,' .. path_sep .. 'nvim'
.. ',\\,-\\,-\\,' .. path_sep ..'nvim'
.. ',-\\,-\\,-' .. path_sep ..'nvim'
.. ',\\,=\\,=\\,' .. path_sep ..'' .. data_dir .. '' .. path_sep ..'site'
.. ',\\,≡\\,≡\\,' .. path_sep ..'nvim' .. path_sep ..'site'
.. ',≡\\,≡\\,≡' .. path_sep ..'nvim' .. path_sep ..'site'
.. ',' .. vimruntime
.. ',' .. libdir
.. ',≡\\,≡\\,≡/nvim/site/after'
.. ',\\,≡\\,≡\\,/nvim/site/after'
.. ',\\,=\\,=\\,/nvim/site/after'
.. ',-\\,-\\,-/nvim/after'
.. ',\\,-\\,-\\,/nvim/after'
.. ',\\, \\, \\,/nvim/after'
.. ',≡\\,≡\\,≡' .. path_sep ..'nvim' .. path_sep ..'site' .. path_sep ..'after'
.. ',\\,≡\\,≡\\,' .. path_sep ..'nvim' .. path_sep ..'site' .. path_sep ..'after'
.. ',\\,=\\,=\\,' .. path_sep ..'' .. data_dir .. '' .. path_sep ..'site' .. path_sep ..'after'
.. ',-\\,-\\,-' .. path_sep ..'nvim' .. path_sep ..'after'
.. ',\\,-\\,-\\,' .. path_sep ..'nvim' .. path_sep ..'after'
.. ',\\, \\, \\,' .. path_sep ..'nvim' .. path_sep ..'after'
), meths.get_option('runtimepath'))
eq('.,\\,=\\,=\\,/nvim/backup', meths.get_option('backupdir'))
eq('\\,=\\,=\\,/nvim/swap//', meths.get_option('directory'))
eq('\\,=\\,=\\,/nvim/undo', meths.get_option('undodir'))
eq('\\,=\\,=\\,/nvim/view', meths.get_option('viewdir'))
eq('.,\\,=\\,=\\,' .. path_sep .. data_dir .. '' .. path_sep ..'backup',
meths.get_option('backupdir'))
eq('\\,=\\,=\\,' .. path_sep ..'' .. data_dir .. '' .. path_sep ..'swap' .. (path_sep):rep(2),
meths.get_option('directory'))
eq('\\,=\\,=\\,' .. path_sep ..'' .. data_dir .. '' .. path_sep ..'undo',
meths.get_option('undodir'))
eq('\\,=\\,=\\,' .. path_sep ..'' .. data_dir .. '' .. path_sep ..'view',
meths.get_option('viewdir'))
end)
end)
end)
@ -491,6 +508,7 @@ describe('stdpath()', function()
-- Windows appends 'nvim-data' instead of just 'nvim' to prevent collisions
-- due to XDG_CONFIG_HOME and XDG_DATA_HOME being the same.
local datadir = iswin() and 'nvim-data' or 'nvim'
local env_sep = iswin() and ';' or ':'
it('acceptance', function()
clear() -- Do not explicitly set any env vars.
@ -634,13 +652,13 @@ describe('stdpath()', function()
local function set_paths_via_system(var_name, paths)
local env = base_env()
env[var_name] = table.concat(paths, ':')
env[var_name] = table.concat(paths, env_sep)
clear({env=env})
end
local function set_paths_at_runtime(var_name, paths)
clear({env=base_env()})
meths.set_var('env_val', table.concat(paths, ':'))
meths.set_var('env_val', table.concat(paths, env_sep))
command(('let $%s=g:env_val'):format(var_name))
end