aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/fs_spec.lua
diff options
context:
space:
mode:
authorWillaaaaaaa <willaaaaaaa936@gmail.com>2026-03-12 17:46:18 +0800
committerGitHub <noreply@github.com>2026-03-12 05:46:18 -0400
commitc5146362d8564b581042a82019cbae3f7d0d4843 (patch)
tree2e759538aaa41b74f15689d9c9f571936c06755e /test/functional/lua/fs_spec.lua
parent32aee065a898aa125e5ae87dcce513606112398d (diff)
downloadrneovim-c5146362d8564b581042a82019cbae3f7d0d4843.tar.gz
rneovim-c5146362d8564b581042a82019cbae3f7d0d4843.tar.bz2
rneovim-c5146362d8564b581042a82019cbae3f7d0d4843.zip
test: fs_spec fails if home is a symlink #38258
Diffstat (limited to 'test/functional/lua/fs_spec.lua')
-rw-r--r--test/functional/lua/fs_spec.lua47
1 files changed, 21 insertions, 26 deletions
diff --git a/test/functional/lua/fs_spec.lua b/test/functional/lua/fs_spec.lua
index 8ffdef3566..4d93ce053b 100644
--- a/test/functional/lua/fs_spec.lua
+++ b/test/functional/lua/fs_spec.lua
@@ -4,6 +4,7 @@ local n = require('test.functional.testnvim')()
local clear = n.clear
local exec_lua = n.exec_lua
local eq = t.eq
+local eq_paths = t.eq_paths
local mkdir_p = n.mkdir_p
local rmdir = n.rmdir
local nvim_dir = n.nvim_dir
@@ -295,8 +296,8 @@ describe('vim.fs', function()
if t.is_zig_build() then
return pending('broken/slow with build.zig')
end
- local cwd = test_source_path ---@type string
- local symlink = test_source_path .. '/loop_link' ---@type string
+ local cwd = vim.uv.fs_realpath(test_source_path) ---@type string
+ local symlink = cwd .. '/loop_link' ---@type string
vim.uv.fs_symlink(cwd, symlink, { junction = true, dir = true })
finally(function()
@@ -304,7 +305,7 @@ describe('vim.fs', function()
end)
eq(link_limit, #vim.fs.find(nvim_prog_basename, {
- path = test_source_path,
+ path = cwd,
type = 'file',
limit = math.huge,
follow = true,
@@ -360,12 +361,12 @@ describe('vim.fs', function()
end)
it('works with a single marker', function()
- eq(test_source_path, exec_lua([[return vim.fs.root(0, 'CMakePresets.json')]]))
+ eq_paths(test_source_path, exec_lua([[return vim.fs.root(0, 'CMakePresets.json')]]))
end)
it('works with multiple markers', function()
local bufnr = api.nvim_get_current_buf()
- eq(
+ eq_paths(
vim.fs.joinpath(test_source_path, 'test/functional/fixtures'),
exec_lua([[return vim.fs.root(..., {'CMakeLists.txt', 'CMakePresets.json'})]], bufnr)
)
@@ -373,29 +374,29 @@ describe('vim.fs', function()
it('nested markers have equal priority', function()
local bufnr = api.nvim_get_current_buf()
- eq(
+ eq_paths(
vim.fs.joinpath(test_source_path, 'test/functional'),
exec_lua(
[[return vim.fs.root(..., { 'example_spec.lua', {'CMakeLists.txt', 'CMakePresets.json'}, '.luarc.json'})]],
bufnr
)
)
- eq(
+ eq_paths(
vim.fs.joinpath(test_source_path, 'test/functional/fixtures'),
exec_lua(
[[return vim.fs.root(..., { {'CMakeLists.txt', 'CMakePresets.json'}, 'example_spec.lua', '.luarc.json'})]],
bufnr
)
)
- eq(
+ eq_paths(
vim.fs.joinpath(test_source_path, 'test/functional/fixtures'),
exec_lua(
[[return vim.fs.root(..., {
- function(name, _)
- return name:match('%.txt$')
- end,
- 'example_spec.lua',
- '.luarc.json' })]],
+ function(name, _)
+ return name:match('%.txt$')
+ end,
+ 'example_spec.lua',
+ '.luarc.json' })]],
bufnr
)
)
@@ -408,7 +409,7 @@ describe('vim.fs', function()
return name:match('%.txt$')
end)
end)
- eq(vim.fs.joinpath(test_source_path, 'test/functional/fixtures'), result)
+ eq_paths(vim.fs.joinpath(test_source_path, 'test/functional/fixtures'), result)
end)
it('works with a filename argument', function()
@@ -416,7 +417,7 @@ describe('vim.fs', function()
end)
it('works with a relative path', function()
- eq(
+ eq_paths(
test_source_path,
exec_lua([[return vim.fs.root(..., 'CMakePresets.json')]], vim.fs.basename(nvim_prog))
)
@@ -425,10 +426,7 @@ describe('vim.fs', function()
it('returns CWD (absolute path) for unnamed buffers', function()
assert(n.fn.isabsolutepath(test_source_path) == 1)
command('new')
- eq(
- t.fix_slashes(test_source_path),
- t.fix_slashes(exec_lua([[return vim.fs.root(0, 'CMakePresets.json')]]))
- )
+ eq_paths(test_source_path, exec_lua([[return vim.fs.root(0, 'CMakePresets.json')]]))
end)
it("returns CWD (absolute path) for buffers with non-empty 'buftype'", function()
@@ -436,17 +434,14 @@ describe('vim.fs', function()
command('new')
command('set buftype=nofile')
command('file lua://')
- eq(
- t.fix_slashes(test_source_path),
- t.fix_slashes(exec_lua([[return vim.fs.root(0, 'CMakePresets.json')]]))
- )
+ eq_paths(test_source_path, exec_lua([[return vim.fs.root(0, 'CMakePresets.json')]]))
end)
it('returns CWD (absolute path) if no match is found', function()
assert(n.fn.isabsolutepath(test_source_path) == 1)
- eq(
- t.fix_slashes(test_source_path),
- t.fix_slashes(exec_lua([[return vim.fs.root('file://bogus', 'CMakePresets.json')]]))
+ eq_paths(
+ test_source_path,
+ exec_lua([[return vim.fs.root('file://bogus', 'CMakePresets.json')]])
)
end)
end)