aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/fs_spec.lua
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-11-19 22:57:13 +0000
committerJosh Rahm <joshuarahm@gmail.com>2024-11-19 22:57:13 +0000
commit9be89f131f87608f224f0ee06d199fcd09d32176 (patch)
tree11022dcfa9e08cb4ac5581b16734196128688d48 /test/functional/lua/fs_spec.lua
parentff7ed8f586589d620a806c3758fac4a47a8e7e15 (diff)
parent88085c2e80a7e3ac29aabb6b5420377eed99b8b6 (diff)
downloadrneovim-9be89f131f87608f224f0ee06d199fcd09d32176.tar.gz
rneovim-9be89f131f87608f224f0ee06d199fcd09d32176.tar.bz2
rneovim-9be89f131f87608f224f0ee06d199fcd09d32176.zip
Merge remote-tracking branch 'upstream/master' into mix_20240309
Diffstat (limited to 'test/functional/lua/fs_spec.lua')
-rw-r--r--test/functional/lua/fs_spec.lua64
1 files changed, 24 insertions, 40 deletions
diff --git a/test/functional/lua/fs_spec.lua b/test/functional/lua/fs_spec.lua
index aba02ab01b..f0d49205e7 100644
--- a/test/functional/lua/fs_spec.lua
+++ b/test/functional/lua/fs_spec.lua
@@ -141,19 +141,14 @@ describe('vim.fs', function()
it('works', function()
eq(
true,
- exec_lua(
- [[
- local dir, nvim = ...
- for name, type in vim.fs.dir(dir) do
- if name == nvim and type == 'file' then
- return true
+ exec_lua(function()
+ for name, type in vim.fs.dir(nvim_dir) do
+ if name == nvim_prog_basename and type == 'file' then
+ return true
+ end
end
- end
- return false
- ]],
- nvim_dir,
- nvim_prog_basename
- )
+ return false
+ end)
)
end)
@@ -172,14 +167,12 @@ describe('vim.fs', function()
io.open('testd/a/b/c/c4', 'w'):close()
local function run(dir, depth, skip)
- local r = exec_lua(
- [[
- local dir, depth, skip = ...
+ return exec_lua(function()
local r = {}
local skip_f
if skip then
- skip_f = function(n)
- if vim.tbl_contains(skip or {}, n) then
+ skip_f = function(n0)
+ if vim.tbl_contains(skip or {}, n0) then
return false
end
end
@@ -188,12 +181,7 @@ describe('vim.fs', function()
r[name] = type_
end
return r
- ]],
- dir,
- depth,
- skip
- )
- return r
+ end)
end
local exp = {}
@@ -263,13 +251,12 @@ describe('vim.fs', function()
opts = { path = test_source_path .. '/contrib', limit = math.huge }
eq(
- exec_lua(
- [[
- local dir = ...
- return vim.tbl_map(vim.fs.basename, vim.fn.glob(dir..'/contrib/*', false, true))
- ]],
- test_source_path
- ),
+ exec_lua(function()
+ return vim.tbl_map(
+ vim.fs.basename,
+ vim.fn.glob(test_source_path .. '/contrib/*', false, true)
+ )
+ end),
vim.tbl_map(
vim.fs.basename,
vim.fs.find(function(_, d)
@@ -299,11 +286,11 @@ describe('vim.fs', function()
it('works with a function', function()
---@type string
- local result = exec_lua([[
- return vim.fs.root(0, function(name, path)
+ local result = exec_lua(function()
+ return vim.fs.root(0, function(name, _)
return name:match('%.txt$')
end)
- ]])
+ end)
eq(vim.fs.joinpath(test_source_path, 'test/functional/fixtures'), result)
end)
@@ -352,13 +339,10 @@ describe('vim.fs', function()
local xdg_config_home = test_build_dir .. '/.config'
eq(
xdg_config_home .. '/nvim',
- exec_lua(
- [[
- vim.env.XDG_CONFIG_HOME = ...
- return vim.fs.normalize('$XDG_CONFIG_HOME/nvim')
- ]],
- xdg_config_home
- )
+ exec_lua(function()
+ vim.env.XDG_CONFIG_HOME = xdg_config_home
+ return vim.fs.normalize('$XDG_CONFIG_HOME/nvim')
+ end)
)
end)