aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/fs_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/lua/fs_spec.lua')
-rw-r--r--test/functional/lua/fs_spec.lua64
1 files changed, 23 insertions, 41 deletions
diff --git a/test/functional/lua/fs_spec.lua b/test/functional/lua/fs_spec.lua
index aba02ab01b..4848787ed2 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(dir, nvim)
+ for name, type in vim.fs.dir(dir) do
+ if name == nvim and type == 'file' then
+ return true
+ end
end
- end
- return false
- ]],
- nvim_dir,
- nvim_prog_basename
- )
+ return false
+ end, nvim_dir, nvim_prog_basename)
)
end)
@@ -172,27 +167,21 @@ 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 = ...
+ local r = exec_lua(function(dir0, depth0, skip0)
local r = {}
local skip_f
- if skip then
- skip_f = function(n)
- if vim.tbl_contains(skip or {}, n) then
+ if skip0 then
+ skip_f = function(n0)
+ if vim.tbl_contains(skip0 or {}, n0) then
return false
end
end
end
- for name, type_ in vim.fs.dir(dir, { depth = depth, skip = skip_f }) do
+ for name, type_ in vim.fs.dir(dir0, { depth = depth0, skip = skip_f }) do
r[name] = type_
end
return r
- ]],
- dir,
- depth,
- skip
- )
+ end, dir, depth, skip)
return r
end
@@ -263,13 +252,9 @@ 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(dir)
+ return vim.tbl_map(vim.fs.basename, vim.fn.glob(dir .. '/contrib/*', false, true))
+ end, test_source_path),
vim.tbl_map(
vim.fs.basename,
vim.fs.find(function(_, d)
@@ -299,11 +284,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 +337,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 = ...
+ return vim.fs.normalize('$XDG_CONFIG_HOME/nvim')
+ end, xdg_config_home)
)
end)