Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(lua/fs_spec): fix vim.fs.dir() test #21503

Merged
merged 1 commit into from
Dec 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test(lua/fs_spec): fix vim.fs.dir() test
  • Loading branch information
zeertzjq committed Dec 22, 2022
commit 37a4dd0d8cbb8d162b702711bd4b477314381664
42 changes: 24 additions & 18 deletions test/functional/lua/fs_spec.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local helpers = require('test.functional.helpers')(after_each)
local lfs = require('lfs')

local clear = helpers.clear
local exec_lua = helpers.exec_lua
Expand Down Expand Up @@ -130,6 +131,17 @@ describe('vim.fs', function()
end)

describe('dir()', function()
before_each(function()
lfs.mkdir('testd')
lfs.mkdir('testd/a')
lfs.mkdir('testd/a/b')
lfs.mkdir('testd/a/b/c')
end)

after_each(function()
rmdir('testd')
end)

it('works', function()
eq(true, exec_lua([[
local dir, nvim = ...
Expand All @@ -143,24 +155,18 @@ describe('vim.fs', function()
end)

it('works with opts.depth and opts.skip', function()
if is_os('win') then
pending()
end
helpers.funcs.system 'mkdir -p testd/a/b/c'
helpers.funcs.system('touch '..table.concat({
'testd/a1',
'testd/b1',
'testd/c1',
'testd/a/a2',
'testd/a/b2',
'testd/a/c2',
'testd/a/b/a3',
'testd/a/b/b3',
'testd/a/b/c3',
'testd/a/b/c/a4',
'testd/a/b/c/b4',
'testd/a/b/c/c4',
}, ' '))
io.open('testd/a1', 'w'):close()
io.open('testd/b1', 'w'):close()
io.open('testd/c1', 'w'):close()
io.open('testd/a/a2', 'w'):close()
io.open('testd/a/b2', 'w'):close()
io.open('testd/a/c2', 'w'):close()
io.open('testd/a/b/a3', 'w'):close()
io.open('testd/a/b/b3', 'w'):close()
io.open('testd/a/b/c3', 'w'):close()
io.open('testd/a/b/c/a4', 'w'):close()
io.open('testd/a/b/c/b4', 'w'):close()
io.open('testd/a/b/c/c4', 'w'):close()

local function run(dir, depth, skip)
local r = exec_lua([[
Expand Down