aboutsummaryrefslogtreecommitdiff
path: root/test/functional/vimscript/executable_spec.lua
diff options
context:
space:
mode:
authortao <2471314@gmail.com>2026-07-13 01:23:44 +0800
committerGitHub <noreply@github.com>2026-07-12 13:23:44 -0400
commit4a0859631407bc9279a935f3219faabc0991a826 (patch)
treeb221c58d86f4f47523f64ec523bb38790976439d /test/functional/vimscript/executable_spec.lua
parent543a96e49179060999ebcb12372ce36ea6be646d (diff)
downloadrneovim-4a0859631407bc9279a935f3219faabc0991a826.tar.gz
rneovim-4a0859631407bc9279a935f3219faabc0991a826.tar.bz2
rneovim-4a0859631407bc9279a935f3219faabc0991a826.zip
fix(path): normalize separators (slashes) #39155
Problem: Continue separators normalization, and try to keep it at the nvim <-> external boundary, e.g., `fn.xxx`, `api.xxx`, `:xxx` Solution: some key changes - normalize `$HOME-windows` - normalize entry points of changing directory - `nvim_set_current_dir()`, `chdir()` - normalize the named pipe - `--listen` arg, `--server` arg, `:restart` - `serverstart()`, `sockconnect()`, `serverstop()` - make `expand()` respect 'shellslash' again - clean up `did_set_shellslash` - replace `forward_slash` with `TO_SLASH` - remove obsolete `TMP_PATHSEPSTR` - remove `slash_adjust` in `do_autocmd_dirchanged`? - make `fnamemodify()` always return `/` (except when substituting separators via `:s`, `:gs` ?) Note: - these funcs still apply `slash_adjust` on return, as before: `:pwd`, `chdir()`, `exepath()`, `getcwd()` - these funcs alwarys return `/`, unlike before the normalization PRs - `getcompletion()`, `finddir()`, `findfile()` Also - clean up code, comments, formatting and tests - move `TO_SLASH` from `f_chdir` to `changedir_func` - move `TO_SLASH` from `f_bufadd` to `buflist_new` Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
Diffstat (limited to 'test/functional/vimscript/executable_spec.lua')
-rw-r--r--test/functional/vimscript/executable_spec.lua48
1 files changed, 18 insertions, 30 deletions
diff --git a/test/functional/vimscript/executable_spec.lua b/test/functional/vimscript/executable_spec.lua
index bb52c861f0..4101d8f32d 100644
--- a/test/functional/vimscript/executable_spec.lua
+++ b/test/functional/vimscript/executable_spec.lua
@@ -2,7 +2,7 @@ local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local eq, clear, call, write_file, command = t.eq, n.clear, n.call, t.write_file, n.command
-local eval = n.eval
+local eval, fn = n.eval, n.fn
local is_os = t.is_os
local pcall_err = t.pcall_err
@@ -18,38 +18,26 @@ describe('executable()', function()
eq(1, call('executable', 'false'))
end)
- if is_os('win') then
- it('exepath returns consistent slashes #13787', function()
- -- test/ cannot be a symlink in this test.
- n.api.nvim_set_current_dir(t.paths.test_source_path)
+ it('exepath respects shellslash #13787', function()
+ t.skip(not is_os('win'), 'N/A for non-Windows')
+ -- test/ cannot be a symlink in this test.
+ n.api.nvim_set_current_dir(t.paths.test_source_path)
- command('let $PATH = fnamemodify("./test/functional/fixtures/bin", ":p")')
- eq(
- [[test/functional/fixtures/bin/null.CMD]],
- call('fnamemodify', call('exepath', 'null'), ':.')
- )
- command('set shellslash')
- eq(
- 'test/functional/fixtures/bin/null.CMD',
- call('fnamemodify', call('exepath', 'null'), ':.')
- )
- end)
+ command('let $PATH = fnamemodify("./test/functional/fixtures/bin", ":p")')
+ eq(([[%s\test\functional\fixtures\bin\null.CMD]]):format(fn.getcwd()), fn.exepath('null'))
+ command('set shellslash')
+ eq(('%s/test/functional/fixtures/bin/null.CMD'):format(fn.getcwd()), fn.exepath('null'))
+ end)
- it('stdpath returns consistent slashes #13787', function()
- -- Needs to check paths relative to repo root dir.
- n.api.nvim_set_current_dir(t.paths.test_source_path)
+ it('stdpath returns consistent slashes #13787', function()
+ t.skip(not is_os('win'), 'N/A for non-Windows')
+ -- Needs to check paths relative to repo root dir.
+ n.api.nvim_set_current_dir(t.paths.test_source_path)
- t.matches(
- [[build/Xtest_xdg[%w_]*/share/nvim%-data]],
- call('fnamemodify', call('stdpath', 'data'), ':.')
- )
- command('set shellslash')
- t.matches(
- 'build/Xtest_xdg[%w_]*/share/nvim%-data',
- call('fnamemodify', call('stdpath', 'data'), ':.')
- )
- end)
- end
+ t.matches('build/Xtest_xdg[%w_]*/share/nvim%-data', fn.stdpath('data'))
+ command('set shellslash')
+ t.matches('build/Xtest_xdg[%w_]*/share/nvim%-data', fn.stdpath('data'))
+ end)
it('fails for invalid values', function()
for _, input in ipairs({ 'v:null', 'v:true', 'v:false', '{}', '[]' }) do