mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
test: replace lfs with luv and vim.fs
test: replace lfs with luv luv already pretty much does everything lfs does, so this duplication of dependencies isn't needed.
This commit is contained in:
parent
b1de4820b7
commit
743860de40
@ -36,7 +36,6 @@ for k, v in pairs({
|
|||||||
keymap = true,
|
keymap = true,
|
||||||
ui = true,
|
ui = true,
|
||||||
health = true,
|
health = true,
|
||||||
fs = true,
|
|
||||||
secure = true,
|
secure = true,
|
||||||
_watch = true,
|
_watch = true,
|
||||||
}) do
|
}) do
|
||||||
|
@ -54,6 +54,7 @@ require('vim.shared')
|
|||||||
vim._submodules = {
|
vim._submodules = {
|
||||||
inspect = true,
|
inspect = true,
|
||||||
version = true,
|
version = true,
|
||||||
|
fs = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- These are for loading runtime modules in the vim namespace lazily.
|
-- These are for loading runtime modules in the vim namespace lazily.
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local Screen = require('test.functional.ui.screen')
|
local Screen = require('test.functional.ui.screen')
|
||||||
local lfs = require('lfs')
|
|
||||||
local luv = require('luv')
|
local luv = require('luv')
|
||||||
|
|
||||||
local fmt = string.format
|
local fmt = string.format
|
||||||
@ -4193,7 +4192,7 @@ describe('API', function()
|
|||||||
vim.api.nvim_echo({{ opts.fargs[1] }}, false, {})
|
vim.api.nvim_echo({{ opts.fargs[1] }}, false, {})
|
||||||
end, { nargs = 1 })
|
end, { nargs = 1 })
|
||||||
]])
|
]])
|
||||||
eq(lfs.currentdir(),
|
eq(luv.cwd(),
|
||||||
meths.cmd({ cmd = "Foo", args = { '%:p:h' }, magic = { file = true } },
|
meths.cmd({ cmd = "Foo", args = { '%:p:h' }, magic = { file = true } },
|
||||||
{ output = true }))
|
{ output = true }))
|
||||||
end)
|
end)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
local lfs = require('lfs')
|
local luv = require('luv')
|
||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
|
|
||||||
local clear = helpers.clear
|
local clear = helpers.clear
|
||||||
@ -9,7 +9,7 @@ local request = helpers.request
|
|||||||
local is_os = helpers.is_os
|
local is_os = helpers.is_os
|
||||||
|
|
||||||
describe('autocmd DirChanged and DirChangedPre', function()
|
describe('autocmd DirChanged and DirChangedPre', function()
|
||||||
local curdir = string.gsub(lfs.currentdir(), '\\', '/')
|
local curdir = string.gsub(luv.cwd(), '\\', '/')
|
||||||
local dirs = {
|
local dirs = {
|
||||||
curdir .. '/Xtest-functional-autocmd-dirchanged.dir1',
|
curdir .. '/Xtest-functional-autocmd-dirchanged.dir1',
|
||||||
curdir .. '/Xtest-functional-autocmd-dirchanged.dir2',
|
curdir .. '/Xtest-functional-autocmd-dirchanged.dir2',
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local thelpers = require('test.functional.terminal.helpers')
|
local thelpers = require('test.functional.terminal.helpers')
|
||||||
local lfs = require('lfs')
|
local luv = require('luv')
|
||||||
local clear = helpers.clear
|
local clear = helpers.clear
|
||||||
local nvim_prog = helpers.nvim_prog
|
local nvim_prog = helpers.nvim_prog
|
||||||
local feed_command = helpers.feed_command
|
local feed_command = helpers.feed_command
|
||||||
@ -32,7 +32,8 @@ describe('autoread TUI FocusGained/FocusLost', function()
|
|||||||
]]
|
]]
|
||||||
|
|
||||||
helpers.write_file(path, '')
|
helpers.write_file(path, '')
|
||||||
lfs.touch(path, os.time() - 10)
|
local atime = os.time() - 10
|
||||||
|
luv.fs_utime(path, atime, atime)
|
||||||
|
|
||||||
screen:expect{grid=[[
|
screen:expect{grid=[[
|
||||||
{1: } |
|
{1: } |
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
local lfs = require('lfs')
|
local luv = require('luv')
|
||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
|
|
||||||
local assert_log = helpers.assert_log
|
local assert_log = helpers.assert_log
|
||||||
@ -142,7 +142,7 @@ describe('fileio', function()
|
|||||||
local backup_file_name = link_file_name .. '~'
|
local backup_file_name = link_file_name .. '~'
|
||||||
|
|
||||||
write_file('Xtest_startup_file1', initial_content, false)
|
write_file('Xtest_startup_file1', initial_content, false)
|
||||||
lfs.link('Xtest_startup_file1', link_file_name, true)
|
luv.fs_symlink('Xtest_startup_file1', link_file_name)
|
||||||
command('set backup')
|
command('set backup')
|
||||||
command('set backupcopy=yes')
|
command('set backupcopy=yes')
|
||||||
command('edit ' .. link_file_name)
|
command('edit ' .. link_file_name)
|
||||||
@ -166,7 +166,7 @@ describe('fileio', function()
|
|||||||
local backup_file_name = backup_dir .. sep .. link_file_name .. '~'
|
local backup_file_name = backup_dir .. sep .. link_file_name .. '~'
|
||||||
|
|
||||||
write_file('Xtest_startup_file1', initial_content, false)
|
write_file('Xtest_startup_file1', initial_content, false)
|
||||||
lfs.link('Xtest_startup_file1', link_file_name, true)
|
luv.fs_symlink('Xtest_startup_file1', link_file_name)
|
||||||
mkdir(backup_dir)
|
mkdir(backup_dir)
|
||||||
command('set backup')
|
command('set backup')
|
||||||
command('set backupcopy=yes')
|
command('set backupcopy=yes')
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
local lfs = require('lfs')
|
local luv = require('luv')
|
||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local Screen = require('test.functional.ui.screen')
|
local Screen = require('test.functional.ui.screen')
|
||||||
|
|
||||||
@ -28,18 +28,18 @@ describe('Command-line option', function()
|
|||||||
os.remove(dollar_fname)
|
os.remove(dollar_fname)
|
||||||
end)
|
end)
|
||||||
it('treats - as stdin', function()
|
it('treats - as stdin', function()
|
||||||
eq(nil, lfs.attributes(fname))
|
eq(nil, luv.fs_stat(fname))
|
||||||
funcs.system(
|
funcs.system(
|
||||||
{nvim_prog_abs(), '-u', 'NONE', '-i', 'NONE', '--headless',
|
{nvim_prog_abs(), '-u', 'NONE', '-i', 'NONE', '--headless',
|
||||||
'--cmd', 'set noswapfile shortmess+=IFW fileformats=unix',
|
'--cmd', 'set noswapfile shortmess+=IFW fileformats=unix',
|
||||||
'-s', '-', fname},
|
'-s', '-', fname},
|
||||||
{':call setline(1, "42")', ':wqall!', ''})
|
{':call setline(1, "42")', ':wqall!', ''})
|
||||||
eq(0, eval('v:shell_error'))
|
eq(0, eval('v:shell_error'))
|
||||||
local attrs = lfs.attributes(fname)
|
local attrs = luv.fs_stat(fname)
|
||||||
eq(#('42\n'), attrs.size)
|
eq(#('42\n'), attrs.size)
|
||||||
end)
|
end)
|
||||||
it('does not expand $VAR', function()
|
it('does not expand $VAR', function()
|
||||||
eq(nil, lfs.attributes(fname))
|
eq(nil, luv.fs_stat(fname))
|
||||||
eq(true, not not dollar_fname:find('%$%w+'))
|
eq(true, not not dollar_fname:find('%$%w+'))
|
||||||
write_file(dollar_fname, ':call setline(1, "100500")\n:wqall!\n')
|
write_file(dollar_fname, ':call setline(1, "100500")\n:wqall!\n')
|
||||||
funcs.system(
|
funcs.system(
|
||||||
@ -47,7 +47,7 @@ describe('Command-line option', function()
|
|||||||
'--cmd', 'set noswapfile shortmess+=IFW fileformats=unix',
|
'--cmd', 'set noswapfile shortmess+=IFW fileformats=unix',
|
||||||
'-s', dollar_fname, fname})
|
'-s', dollar_fname, fname})
|
||||||
eq(0, eval('v:shell_error'))
|
eq(0, eval('v:shell_error'))
|
||||||
local attrs = lfs.attributes(fname)
|
local attrs = luv.fs_stat(fname)
|
||||||
eq(#('100500\n'), attrs.size)
|
eq(#('100500\n'), attrs.size)
|
||||||
end)
|
end)
|
||||||
it('does not crash after reading from stdin in non-headless mode', function()
|
it('does not crash after reading from stdin in non-headless mode', function()
|
||||||
@ -121,7 +121,7 @@ describe('Command-line option', function()
|
|||||||
'--cmd', 'language C',
|
'--cmd', 'language C',
|
||||||
'-s', fname, '-s', dollar_fname, fname_2}))
|
'-s', fname, '-s', dollar_fname, fname_2}))
|
||||||
eq(2, eval('v:shell_error'))
|
eq(2, eval('v:shell_error'))
|
||||||
eq(nil, lfs.attributes(fname_2))
|
eq(nil, luv.fs_stat(fname_2))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local lfs = require('lfs')
|
|
||||||
|
|
||||||
local eq = helpers.eq
|
local eq = helpers.eq
|
||||||
local clear = helpers.clear
|
local clear = helpers.clear
|
||||||
@ -7,6 +6,7 @@ local meths = helpers.meths
|
|||||||
local exc_exec = helpers.exc_exec
|
local exc_exec = helpers.exc_exec
|
||||||
local rmdir = helpers.rmdir
|
local rmdir = helpers.rmdir
|
||||||
local write_file = helpers.write_file
|
local write_file = helpers.write_file
|
||||||
|
local mkdir = helpers.mkdir
|
||||||
|
|
||||||
local testdir = 'Xtest-functional-spell-spellfile.d'
|
local testdir = 'Xtest-functional-spell-spellfile.d'
|
||||||
|
|
||||||
@ -14,8 +14,8 @@ describe('spellfile', function()
|
|||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
rmdir(testdir)
|
rmdir(testdir)
|
||||||
lfs.mkdir(testdir)
|
mkdir(testdir)
|
||||||
lfs.mkdir(testdir .. '/spell')
|
mkdir(testdir .. '/spell')
|
||||||
end)
|
end)
|
||||||
after_each(function()
|
after_each(function()
|
||||||
rmdir(testdir)
|
rmdir(testdir)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
-- Specs for :cd, :tcd, :lcd and getcwd()
|
-- Specs for :cd, :tcd, :lcd and getcwd()
|
||||||
|
|
||||||
local lfs = require('lfs')
|
local luv = require('luv')
|
||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
|
|
||||||
local eq = helpers.eq
|
local eq = helpers.eq
|
||||||
@ -11,6 +11,7 @@ local exc_exec = helpers.exc_exec
|
|||||||
local pathsep = helpers.get_pathsep()
|
local pathsep = helpers.get_pathsep()
|
||||||
local skip = helpers.skip
|
local skip = helpers.skip
|
||||||
local is_os = helpers.is_os
|
local is_os = helpers.is_os
|
||||||
|
local mkdir = helpers.mkdir
|
||||||
|
|
||||||
-- These directories will be created for testing
|
-- These directories will be created for testing
|
||||||
local directories = {
|
local directories = {
|
||||||
@ -36,14 +37,14 @@ for _, cmd in ipairs {'cd', 'chdir'} do
|
|||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
for _, d in pairs(directories) do
|
for _, d in pairs(directories) do
|
||||||
lfs.mkdir(d)
|
mkdir(d)
|
||||||
end
|
end
|
||||||
directories.start = cwd()
|
directories.start = cwd()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
after_each(function()
|
after_each(function()
|
||||||
for _, d in pairs(directories) do
|
for _, d in pairs(directories) do
|
||||||
lfs.rmdir(d)
|
luv.fs_rmdir(d)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -273,7 +274,7 @@ end
|
|||||||
describe("getcwd()", function ()
|
describe("getcwd()", function ()
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
lfs.mkdir(directories.global)
|
mkdir(directories.global)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
after_each(function()
|
after_each(function()
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local lfs = require('lfs')
|
local luv = require('luv')
|
||||||
local clear = helpers.clear
|
local clear = helpers.clear
|
||||||
local command = helpers.command
|
local command = helpers.command
|
||||||
local eq = helpers.eq
|
local eq = helpers.eq
|
||||||
local funcs = helpers.funcs
|
local funcs = helpers.funcs
|
||||||
local rmdir = helpers.rmdir
|
local rmdir = helpers.rmdir
|
||||||
|
local mkdir = helpers.mkdir
|
||||||
|
|
||||||
describe(':file', function()
|
describe(':file', function()
|
||||||
local swapdir = lfs.currentdir()..'/Xtest-file_spec'
|
local swapdir = luv.cwd()..'/Xtest-file_spec'
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
rmdir(swapdir)
|
rmdir(swapdir)
|
||||||
lfs.mkdir(swapdir)
|
mkdir(swapdir)
|
||||||
end)
|
end)
|
||||||
after_each(function()
|
after_each(function()
|
||||||
command('%bwipeout!')
|
command('%bwipeout!')
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
local lfs = require('lfs')
|
|
||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local Screen = require('test.functional.ui.screen')
|
local Screen = require('test.functional.ui.screen')
|
||||||
|
|
||||||
@ -15,6 +14,7 @@ local sleep = helpers.sleep
|
|||||||
local meths = helpers.meths
|
local meths = helpers.meths
|
||||||
local skip = helpers.skip
|
local skip = helpers.skip
|
||||||
local is_os = helpers.is_os
|
local is_os = helpers.is_os
|
||||||
|
local mkdir = helpers.mkdir
|
||||||
|
|
||||||
local file_prefix = 'Xtest-functional-ex_cmds-mksession_spec'
|
local file_prefix = 'Xtest-functional-ex_cmds-mksession_spec'
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ describe(':mksession', function()
|
|||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
lfs.mkdir(tab_dir)
|
mkdir(tab_dir)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
after_each(function()
|
after_each(function()
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
local lfs = require('lfs')
|
|
||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
|
|
||||||
local clear = helpers.clear
|
local clear = helpers.clear
|
||||||
@ -7,6 +6,7 @@ local get_pathsep = helpers.get_pathsep
|
|||||||
local eq = helpers.eq
|
local eq = helpers.eq
|
||||||
local funcs = helpers.funcs
|
local funcs = helpers.funcs
|
||||||
local rmdir = helpers.rmdir
|
local rmdir = helpers.rmdir
|
||||||
|
local mkdir = helpers.mkdir
|
||||||
|
|
||||||
local file_prefix = 'Xtest-functional-ex_cmds-mkview_spec'
|
local file_prefix = 'Xtest-functional-ex_cmds-mkview_spec'
|
||||||
|
|
||||||
@ -17,8 +17,8 @@ describe(':mkview', function()
|
|||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
lfs.mkdir(view_dir)
|
mkdir(view_dir)
|
||||||
lfs.mkdir(local_dir)
|
mkdir(local_dir)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
after_each(function()
|
after_each(function()
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
require('os')
|
require('os')
|
||||||
local lfs = require('lfs')
|
local luv = require('luv')
|
||||||
|
|
||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local eval = helpers.eval
|
local eval = helpers.eval
|
||||||
@ -12,18 +12,16 @@ local read_file = helpers.read_file
|
|||||||
|
|
||||||
-- tmpname() also creates the file on POSIX systems. Remove it again.
|
-- tmpname() also creates the file on POSIX systems. Remove it again.
|
||||||
-- We just need the name, ignoring any race conditions.
|
-- We just need the name, ignoring any race conditions.
|
||||||
if lfs.attributes(tempfile, 'uid') then
|
if luv.fs_stat(tempfile).uid then
|
||||||
os.remove(tempfile)
|
os.remove(tempfile)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function assert_file_exists(filepath)
|
local function assert_file_exists(filepath)
|
||||||
-- Use 2-argument lfs.attributes() so no extra table gets created.
|
neq(nil, luv.fs_stat(filepath).uid)
|
||||||
-- We don't really care for the uid.
|
|
||||||
neq(nil, lfs.attributes(filepath, 'uid'))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function assert_file_exists_not(filepath)
|
local function assert_file_exists_not(filepath)
|
||||||
eq(nil, lfs.attributes(filepath, 'uid'))
|
eq(nil, luv.fs_stat(filepath))
|
||||||
end
|
end
|
||||||
|
|
||||||
describe(':profile', function()
|
describe(':profile', function()
|
||||||
@ -31,7 +29,7 @@ describe(':profile', function()
|
|||||||
|
|
||||||
after_each(function()
|
after_each(function()
|
||||||
helpers.expect_exit(command, 'qall!')
|
helpers.expect_exit(command, 'qall!')
|
||||||
if lfs.attributes(tempfile, 'uid') ~= nil then
|
if luv.fs_stat(tempfile).uid ~= nil then
|
||||||
os.remove(tempfile)
|
os.remove(tempfile)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
local Screen = require('test.functional.ui.screen')
|
local Screen = require('test.functional.ui.screen')
|
||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local lfs = require('lfs')
|
|
||||||
local luv = require('luv')
|
local luv = require('luv')
|
||||||
local eq, eval, expect, exec =
|
local eq, eval, expect, exec =
|
||||||
helpers.eq, helpers.eval, helpers.expect, helpers.exec
|
helpers.eq, helpers.eval, helpers.expect, helpers.exec
|
||||||
@ -21,6 +20,7 @@ local spawn = helpers.spawn
|
|||||||
local nvim_async = helpers.nvim_async
|
local nvim_async = helpers.nvim_async
|
||||||
local expect_msg_seq = helpers.expect_msg_seq
|
local expect_msg_seq = helpers.expect_msg_seq
|
||||||
local pcall_err = helpers.pcall_err
|
local pcall_err = helpers.pcall_err
|
||||||
|
local mkdir = helpers.mkdir
|
||||||
|
|
||||||
describe(':recover', function()
|
describe(':recover', function()
|
||||||
before_each(clear)
|
before_each(clear)
|
||||||
@ -39,7 +39,7 @@ describe(':recover', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
describe("preserve and (R)ecover with custom 'directory'", function()
|
describe("preserve and (R)ecover with custom 'directory'", function()
|
||||||
local swapdir = lfs.currentdir()..'/Xtest_recover_dir'
|
local swapdir = luv.cwd()..'/Xtest_recover_dir'
|
||||||
local testfile = 'Xtest_recover_file1'
|
local testfile = 'Xtest_recover_file1'
|
||||||
-- Put swapdir at the start of the 'directory' list. #1836
|
-- Put swapdir at the start of the 'directory' list. #1836
|
||||||
-- Note: `set swapfile` *must* go after `set directory`: otherwise it may
|
-- Note: `set swapfile` *must* go after `set directory`: otherwise it may
|
||||||
@ -54,7 +54,7 @@ describe("preserve and (R)ecover with custom 'directory'", function()
|
|||||||
nvim1 = spawn(new_argv())
|
nvim1 = spawn(new_argv())
|
||||||
set_session(nvim1)
|
set_session(nvim1)
|
||||||
rmdir(swapdir)
|
rmdir(swapdir)
|
||||||
lfs.mkdir(swapdir)
|
mkdir(swapdir)
|
||||||
end)
|
end)
|
||||||
after_each(function()
|
after_each(function()
|
||||||
command('%bwipeout!')
|
command('%bwipeout!')
|
||||||
@ -126,7 +126,7 @@ describe("preserve and (R)ecover with custom 'directory'", function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
describe('swapfile detection', function()
|
describe('swapfile detection', function()
|
||||||
local swapdir = lfs.currentdir()..'/Xtest_swapdialog_dir'
|
local swapdir = luv.cwd()..'/Xtest_swapdialog_dir'
|
||||||
local nvim0
|
local nvim0
|
||||||
-- Put swapdir at the start of the 'directory' list. #1836
|
-- Put swapdir at the start of the 'directory' list. #1836
|
||||||
-- Note: `set swapfile` *must* go after `set directory`: otherwise it may
|
-- Note: `set swapfile` *must* go after `set directory`: otherwise it may
|
||||||
@ -139,7 +139,7 @@ describe('swapfile detection', function()
|
|||||||
nvim0 = spawn(new_argv())
|
nvim0 = spawn(new_argv())
|
||||||
set_session(nvim0)
|
set_session(nvim0)
|
||||||
rmdir(swapdir)
|
rmdir(swapdir)
|
||||||
lfs.mkdir(swapdir)
|
mkdir(swapdir)
|
||||||
end)
|
end)
|
||||||
after_each(function()
|
after_each(function()
|
||||||
set_session(nvim0)
|
set_session(nvim0)
|
||||||
@ -361,7 +361,8 @@ describe('swapfile detection', function()
|
|||||||
]])
|
]])
|
||||||
|
|
||||||
-- pretend that the swapfile was created before boot
|
-- pretend that the swapfile was created before boot
|
||||||
lfs.touch(swname, os.time() - luv.uptime() - 10)
|
local atime = os.time() - luv.uptime() - 10
|
||||||
|
luv.fs_utime(swname, atime, atime)
|
||||||
|
|
||||||
feed(':edit Xswaptest<CR>')
|
feed(':edit Xswaptest<CR>')
|
||||||
screen:expect({any = table.concat({
|
screen:expect({any = table.concat({
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local lfs = require('lfs')
|
local luv = require('luv')
|
||||||
local eq, eval, clear, write_file, source, insert =
|
local eq, eval, clear, write_file, source, insert =
|
||||||
helpers.eq, helpers.eval, helpers.clear, helpers.write_file,
|
helpers.eq, helpers.eval, helpers.clear, helpers.write_file,
|
||||||
helpers.source, helpers.insert
|
helpers.source, helpers.insert
|
||||||
@ -153,7 +153,7 @@ describe(':write', function()
|
|||||||
end
|
end
|
||||||
write_file(fname_bak, 'TTYX')
|
write_file(fname_bak, 'TTYX')
|
||||||
skip(is_os('win'), [[FIXME: exc_exec('write!') outputs 0 in Windows]])
|
skip(is_os('win'), [[FIXME: exc_exec('write!') outputs 0 in Windows]])
|
||||||
lfs.link(fname_bak .. ('/xxxxx'):rep(20), fname, true)
|
luv.fs_symlink(fname_bak .. ('/xxxxx'):rep(20), fname)
|
||||||
eq('Vim(write):E166: Can\'t open linked file for writing',
|
eq('Vim(write):E166: Can\'t open linked file for writing',
|
||||||
pcall_err(command, 'write!'))
|
pcall_err(command, 'write!'))
|
||||||
end)
|
end)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local lfs = require('lfs')
|
local luv = require('luv')
|
||||||
local clear = helpers.clear
|
local clear = helpers.clear
|
||||||
local command, eq, neq, write_file =
|
local command, eq, neq, write_file =
|
||||||
helpers.command, helpers.eq, helpers.neq, helpers.write_file
|
helpers.command, helpers.eq, helpers.neq, helpers.write_file
|
||||||
@ -21,10 +21,10 @@ describe(':wshada', function()
|
|||||||
|
|
||||||
it('creates a shada file', function()
|
it('creates a shada file', function()
|
||||||
-- file should _not_ exist
|
-- file should _not_ exist
|
||||||
eq(nil, lfs.attributes(shada_file))
|
eq(nil, luv.fs_stat(shada_file))
|
||||||
command('wsh! '..shada_file)
|
command('wsh! '..shada_file)
|
||||||
-- file _should_ exist
|
-- file _should_ exist
|
||||||
neq(nil, lfs.attributes(shada_file))
|
neq(nil, luv.fs_stat(shada_file))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('overwrites existing files', function()
|
it('overwrites existing files', function()
|
||||||
@ -35,7 +35,7 @@ describe(':wshada', function()
|
|||||||
|
|
||||||
-- sanity check
|
-- sanity check
|
||||||
eq(text, read_file(shada_file))
|
eq(text, read_file(shada_file))
|
||||||
neq(nil, lfs.attributes(shada_file))
|
neq(nil, luv.fs_stat(shada_file))
|
||||||
|
|
||||||
command('wsh! '..shada_file)
|
command('wsh! '..shada_file)
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
local luv = require('luv')
|
local luv = require('luv')
|
||||||
local lfs = require('lfs')
|
|
||||||
local global_helpers = require('test.helpers')
|
local global_helpers = require('test.helpers')
|
||||||
|
|
||||||
local Session = require('test.client.session')
|
local Session = require('test.client.session')
|
||||||
@ -20,10 +19,9 @@ local tbl_contains = global_helpers.tbl_contains
|
|||||||
local fail = global_helpers.fail
|
local fail = global_helpers.fail
|
||||||
|
|
||||||
local module = {
|
local module = {
|
||||||
mkdir = lfs.mkdir,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
local start_dir = lfs.currentdir()
|
local start_dir = luv.cwd()
|
||||||
local runtime_set = 'set runtimepath^=./build/lib/nvim/'
|
local runtime_set = 'set runtimepath^=./build/lib/nvim/'
|
||||||
module.nvim_prog = (
|
module.nvim_prog = (
|
||||||
os.getenv('NVIM_PRG')
|
os.getenv('NVIM_PRG')
|
||||||
@ -730,21 +728,17 @@ function module.assert_visible(bufnr, visible)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function do_rmdir(path)
|
local function do_rmdir(path)
|
||||||
local mode, errmsg, errcode = lfs.attributes(path, 'mode')
|
local stat = luv.fs_stat(path)
|
||||||
if mode == nil then
|
if stat == nil then
|
||||||
if errcode == 2 then
|
return
|
||||||
-- "No such file or directory", don't complain.
|
|
||||||
return
|
|
||||||
end
|
|
||||||
error(string.format('rmdir: %s (%d)', errmsg, errcode))
|
|
||||||
end
|
end
|
||||||
if mode ~= 'directory' then
|
if stat.type ~= 'directory' then
|
||||||
error(string.format('rmdir: not a directory: %s', path))
|
error(string.format('rmdir: not a directory: %s', path))
|
||||||
end
|
end
|
||||||
for file in lfs.dir(path) do
|
for file in vim.fs.dir(path) do
|
||||||
if file ~= '.' and file ~= '..' then
|
if file ~= '.' and file ~= '..' then
|
||||||
local abspath = path..'/'..file
|
local abspath = path..'/'..file
|
||||||
if lfs.attributes(abspath, 'mode') == 'directory' then
|
if global_helpers.isdir(abspath) then
|
||||||
do_rmdir(abspath) -- recurse
|
do_rmdir(abspath) -- recurse
|
||||||
else
|
else
|
||||||
local ret, err = os.remove(abspath)
|
local ret, err = os.remove(abspath)
|
||||||
@ -764,9 +758,9 @@ local function do_rmdir(path)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local ret, err = lfs.rmdir(path)
|
local ret, err = luv.fs_rmdir(path)
|
||||||
if not ret then
|
if not ret then
|
||||||
error('lfs.rmdir('..path..'): '..err)
|
error('luv.fs_rmdir('..path..'): '..err)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
-- being modified outside of Vim (noticed on Solaris).
|
-- being modified outside of Vim (noticed on Solaris).
|
||||||
|
|
||||||
local helpers= require('test.functional.helpers')(after_each)
|
local helpers= require('test.functional.helpers')(after_each)
|
||||||
local lfs = require('lfs')
|
local luv = require('luv')
|
||||||
local clear, feed_command, expect, eq, neq, dedent, write_file, feed =
|
local clear, feed_command, expect, eq, neq, dedent, write_file, feed =
|
||||||
helpers.clear, helpers.feed_command, helpers.expect, helpers.eq, helpers.neq,
|
helpers.clear, helpers.feed_command, helpers.expect, helpers.eq, helpers.neq,
|
||||||
helpers.dedent, helpers.write_file, helpers.feed
|
helpers.dedent, helpers.write_file, helpers.feed
|
||||||
@ -31,8 +31,8 @@ local function prepare_gz_file(name, text)
|
|||||||
-- Compress the file with gzip.
|
-- Compress the file with gzip.
|
||||||
command([[call system(['gzip', '--force', ']]..name..[['])]])
|
command([[call system(['gzip', '--force', ']]..name..[['])]])
|
||||||
-- This should create the .gz file and delete the original.
|
-- This should create the .gz file and delete the original.
|
||||||
neq(nil, lfs.attributes(name..'.gz'))
|
neq(nil, luv.fs_stat(name..'.gz'))
|
||||||
eq(nil, lfs.attributes(name))
|
eq(nil, luv.fs_stat(name))
|
||||||
end
|
end
|
||||||
|
|
||||||
describe('file reading, writing and bufnew and filter autocommands', function()
|
describe('file reading, writing and bufnew and filter autocommands', function()
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
-- - "dir", in directory relative to current dir
|
-- - "dir", in directory relative to current dir
|
||||||
|
|
||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local lfs = require('lfs')
|
local luv = require('luv')
|
||||||
|
|
||||||
local eq = helpers.eq
|
local eq = helpers.eq
|
||||||
local neq = helpers.neq
|
local neq = helpers.neq
|
||||||
@ -17,10 +17,11 @@ local command = helpers.command
|
|||||||
local write_file = helpers.write_file
|
local write_file = helpers.write_file
|
||||||
local curbufmeths = helpers.curbufmeths
|
local curbufmeths = helpers.curbufmeths
|
||||||
local expect_exit = helpers.expect_exit
|
local expect_exit = helpers.expect_exit
|
||||||
|
local mkdir = helpers.mkdir
|
||||||
|
|
||||||
local function ls_dir_sorted(dirname)
|
local function ls_dir_sorted(dirname)
|
||||||
local files = {}
|
local files = {}
|
||||||
for f in lfs.dir(dirname) do
|
for f in vim.fs.dir(dirname) do
|
||||||
if f ~= "." and f~= ".." then
|
if f ~= "." and f~= ".." then
|
||||||
table.insert(files, f)
|
table.insert(files, f)
|
||||||
end
|
end
|
||||||
@ -38,8 +39,8 @@ describe("'directory' option", function()
|
|||||||
end of testfile
|
end of testfile
|
||||||
]]
|
]]
|
||||||
write_file('Xtest1', text)
|
write_file('Xtest1', text)
|
||||||
lfs.mkdir('Xtest.je')
|
mkdir('Xtest.je')
|
||||||
lfs.mkdir('Xtest2')
|
mkdir('Xtest2')
|
||||||
write_file('Xtest2/Xtest3', text)
|
write_file('Xtest2/Xtest3', text)
|
||||||
clear()
|
clear()
|
||||||
end)
|
end)
|
||||||
@ -62,21 +63,21 @@ describe("'directory' option", function()
|
|||||||
meths.set_option('directory', '.')
|
meths.set_option('directory', '.')
|
||||||
|
|
||||||
-- sanity check: files should not exist yet.
|
-- sanity check: files should not exist yet.
|
||||||
eq(nil, lfs.attributes('.Xtest1.swp'))
|
eq(nil, luv.fs_stat('.Xtest1.swp'))
|
||||||
|
|
||||||
command('edit! Xtest1')
|
command('edit! Xtest1')
|
||||||
poke_eventloop()
|
poke_eventloop()
|
||||||
eq('Xtest1', funcs.buffer_name('%'))
|
eq('Xtest1', funcs.buffer_name('%'))
|
||||||
-- Verify that the swapfile exists. In the legacy test this was done by
|
-- Verify that the swapfile exists. In the legacy test this was done by
|
||||||
-- reading the output from :!ls.
|
-- reading the output from :!ls.
|
||||||
neq(nil, lfs.attributes('.Xtest1.swp'))
|
neq(nil, luv.fs_stat('.Xtest1.swp'))
|
||||||
|
|
||||||
meths.set_option('directory', './Xtest2,.')
|
meths.set_option('directory', './Xtest2,.')
|
||||||
command('edit Xtest1')
|
command('edit Xtest1')
|
||||||
poke_eventloop()
|
poke_eventloop()
|
||||||
|
|
||||||
-- swapfile should no longer exist in CWD.
|
-- swapfile should no longer exist in CWD.
|
||||||
eq(nil, lfs.attributes('.Xtest1.swp'))
|
eq(nil, luv.fs_stat('.Xtest1.swp'))
|
||||||
|
|
||||||
eq({ "Xtest1.swp", "Xtest3" }, ls_dir_sorted("Xtest2"))
|
eq({ "Xtest1.swp", "Xtest3" }, ls_dir_sorted("Xtest2"))
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
-- Tests for storing global variables in the .shada file
|
-- Tests for storing global variables in the .shada file
|
||||||
|
|
||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local lfs = require('lfs')
|
local luv = require('luv')
|
||||||
local clear, command, eq, neq, eval, poke_eventloop =
|
local clear, command, eq, neq, eval, poke_eventloop =
|
||||||
helpers.clear, helpers.command, helpers.eq, helpers.neq, helpers.eval,
|
helpers.clear, helpers.command, helpers.eq, helpers.neq, helpers.eval,
|
||||||
helpers.poke_eventloop
|
helpers.poke_eventloop
|
||||||
@ -39,7 +39,7 @@ describe('storing global variables in ShaDa files', function()
|
|||||||
poke_eventloop()
|
poke_eventloop()
|
||||||
|
|
||||||
-- Assert that the shada file exists.
|
-- Assert that the shada file exists.
|
||||||
neq(nil, lfs.attributes(tempname))
|
neq(nil, luv.fs_stat(tempname))
|
||||||
command('unlet MY_GLOBAL_DICT')
|
command('unlet MY_GLOBAL_DICT')
|
||||||
command('unlet MY_GLOBAL_LIST')
|
command('unlet MY_GLOBAL_LIST')
|
||||||
-- Assert that the variables where deleted.
|
-- Assert that the variables where deleted.
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
local lfs = require('lfs')
|
|
||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local clear, eq, matches = helpers.clear, helpers.eq, helpers.matches
|
local clear, eq, matches = helpers.clear, helpers.eq, helpers.matches
|
||||||
local eval, command, call, meths = helpers.eval, helpers.command, helpers.call, helpers.meths
|
local eval, command, call, meths = helpers.eval, helpers.command, helpers.call, helpers.meths
|
||||||
local source, exec_capture = helpers.source, helpers.exec_capture
|
local source, exec_capture = helpers.source, helpers.exec_capture
|
||||||
|
local mkdir = helpers.mkdir
|
||||||
|
|
||||||
local function expected_empty()
|
local function expected_empty()
|
||||||
eq({}, meths.get_vvar('errors'))
|
eq({}, meths.get_vvar('errors'))
|
||||||
@ -12,7 +12,7 @@ describe('autochdir behavior', function()
|
|||||||
local dir = 'Xtest_functional_legacy_autochdir'
|
local dir = 'Xtest_functional_legacy_autochdir'
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
lfs.mkdir(dir)
|
mkdir(dir)
|
||||||
clear()
|
clear()
|
||||||
command('set shellslash')
|
command('set shellslash')
|
||||||
end)
|
end)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
-- Test suite for testing interactions with API bindings
|
-- Test suite for testing interactions with API bindings
|
||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local lfs = require('lfs')
|
local luv = require('luv')
|
||||||
|
|
||||||
local command = helpers.command
|
local command = helpers.command
|
||||||
local meths = helpers.meths
|
local meths = helpers.meths
|
||||||
@ -754,7 +754,8 @@ describe('lua: nvim_buf_attach on_bytes', function()
|
|||||||
write_file("Xtest-reload", dedent [[
|
write_file("Xtest-reload", dedent [[
|
||||||
old line 1
|
old line 1
|
||||||
old line 2]])
|
old line 2]])
|
||||||
lfs.touch("Xtest-reload", os.time() - 10)
|
local atime = os.time() - 10
|
||||||
|
luv.fs_utime("Xtest-reload", atime, atime)
|
||||||
command "e Xtest-reload"
|
command "e Xtest-reload"
|
||||||
command "set autoread"
|
command "set autoread"
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local lfs = require('lfs')
|
|
||||||
|
|
||||||
local clear = helpers.clear
|
local clear = helpers.clear
|
||||||
local exec_lua = helpers.exec_lua
|
local exec_lua = helpers.exec_lua
|
||||||
@ -11,6 +10,7 @@ local test_build_dir = helpers.test_build_dir
|
|||||||
local test_source_path = helpers.test_source_path
|
local test_source_path = helpers.test_source_path
|
||||||
local nvim_prog = helpers.nvim_prog
|
local nvim_prog = helpers.nvim_prog
|
||||||
local is_os = helpers.is_os
|
local is_os = helpers.is_os
|
||||||
|
local mkdir = helpers.mkdir
|
||||||
|
|
||||||
local nvim_prog_basename = is_os('win') and 'nvim.exe' or 'nvim'
|
local nvim_prog_basename = is_os('win') and 'nvim.exe' or 'nvim'
|
||||||
|
|
||||||
@ -133,10 +133,10 @@ describe('vim.fs', function()
|
|||||||
|
|
||||||
describe('dir()', function()
|
describe('dir()', function()
|
||||||
before_each(function()
|
before_each(function()
|
||||||
lfs.mkdir('testd')
|
mkdir('testd')
|
||||||
lfs.mkdir('testd/a')
|
mkdir('testd/a')
|
||||||
lfs.mkdir('testd/a/b')
|
mkdir('testd/a/b')
|
||||||
lfs.mkdir('testd/a/b/c')
|
mkdir('testd/a/b/c')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
after_each(function()
|
after_each(function()
|
||||||
|
@ -3,7 +3,7 @@ local eq = helpers.eq
|
|||||||
local exec_lua = helpers.exec_lua
|
local exec_lua = helpers.exec_lua
|
||||||
local clear = helpers.clear
|
local clear = helpers.clear
|
||||||
local is_os = helpers.is_os
|
local is_os = helpers.is_os
|
||||||
local lfs = require('lfs')
|
local mkdir = helpers.mkdir
|
||||||
|
|
||||||
describe('vim._watch', function()
|
describe('vim._watch', function()
|
||||||
before_each(function()
|
before_each(function()
|
||||||
@ -14,7 +14,7 @@ describe('vim._watch', function()
|
|||||||
it('detects file changes', function()
|
it('detects file changes', function()
|
||||||
local root_dir = helpers.tmpname()
|
local root_dir = helpers.tmpname()
|
||||||
os.remove(root_dir)
|
os.remove(root_dir)
|
||||||
lfs.mkdir(root_dir)
|
mkdir(root_dir)
|
||||||
|
|
||||||
local result = exec_lua(
|
local result = exec_lua(
|
||||||
[[
|
[[
|
||||||
@ -102,7 +102,7 @@ describe('vim._watch', function()
|
|||||||
it('detects file changes', function()
|
it('detects file changes', function()
|
||||||
local root_dir = helpers.tmpname()
|
local root_dir = helpers.tmpname()
|
||||||
os.remove(root_dir)
|
os.remove(root_dir)
|
||||||
lfs.mkdir(root_dir)
|
mkdir(root_dir)
|
||||||
|
|
||||||
local result = exec_lua(
|
local result = exec_lua(
|
||||||
[[
|
[[
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
local lfs = require('lfs')
|
local luv = require('luv')
|
||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local clear = helpers.clear
|
local clear = helpers.clear
|
||||||
local eq = helpers.eq
|
local eq = helpers.eq
|
||||||
local funcs = helpers.funcs
|
local funcs = helpers.funcs
|
||||||
local command = helpers.command
|
local command = helpers.command
|
||||||
|
local mkdir = helpers.mkdir
|
||||||
|
|
||||||
describe("'autochdir'", function()
|
describe("'autochdir'", function()
|
||||||
it('given on the shell gets processed properly', function()
|
it('given on the shell gets processed properly', function()
|
||||||
@ -20,11 +21,11 @@ describe("'autochdir'", function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('is not overwritten by getwinvar() call #17609',function()
|
it('is not overwritten by getwinvar() call #17609',function()
|
||||||
local curdir = string.gsub(lfs.currentdir(), '\\', '/')
|
local curdir = string.gsub(luv.cwd(), '\\', '/')
|
||||||
local dir_a = curdir..'/Xtest-functional-options-autochdir.dir_a'
|
local dir_a = curdir..'/Xtest-functional-options-autochdir.dir_a'
|
||||||
local dir_b = curdir..'/Xtest-functional-options-autochdir.dir_b'
|
local dir_b = curdir..'/Xtest-functional-options-autochdir.dir_b'
|
||||||
lfs.mkdir(dir_a)
|
mkdir(dir_a)
|
||||||
lfs.mkdir(dir_b)
|
mkdir(dir_b)
|
||||||
clear()
|
clear()
|
||||||
command('set shellslash')
|
command('set shellslash')
|
||||||
command('set autochdir')
|
command('set autochdir')
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local lsp_helpers = require('test.functional.plugin.lsp.helpers')
|
local lsp_helpers = require('test.functional.plugin.lsp.helpers')
|
||||||
local lfs = require('lfs')
|
|
||||||
|
|
||||||
local assert_log = helpers.assert_log
|
local assert_log = helpers.assert_log
|
||||||
local buf_lines = helpers.buf_lines
|
local buf_lines = helpers.buf_lines
|
||||||
@ -24,6 +23,7 @@ local is_ci = helpers.is_ci
|
|||||||
local meths = helpers.meths
|
local meths = helpers.meths
|
||||||
local is_os = helpers.is_os
|
local is_os = helpers.is_os
|
||||||
local skip = helpers.skip
|
local skip = helpers.skip
|
||||||
|
local mkdir = helpers.mkdir
|
||||||
|
|
||||||
local clear_notrace = lsp_helpers.clear_notrace
|
local clear_notrace = lsp_helpers.clear_notrace
|
||||||
local create_server_definition = lsp_helpers.create_server_definition
|
local create_server_definition = lsp_helpers.create_server_definition
|
||||||
@ -3768,7 +3768,7 @@ describe('LSP', function()
|
|||||||
it('sends notifications when files change', function()
|
it('sends notifications when files change', function()
|
||||||
local root_dir = helpers.tmpname()
|
local root_dir = helpers.tmpname()
|
||||||
os.remove(root_dir)
|
os.remove(root_dir)
|
||||||
lfs.mkdir(root_dir)
|
mkdir(root_dir)
|
||||||
|
|
||||||
exec_lua(create_server_definition)
|
exec_lua(create_server_definition)
|
||||||
local result = exec_lua([[
|
local result = exec_lua([[
|
||||||
|
@ -8,7 +8,7 @@ local write_file, spawn, set_session, nvim_prog, exc_exec =
|
|||||||
local is_os = helpers.is_os
|
local is_os = helpers.is_os
|
||||||
local skip = helpers.skip
|
local skip = helpers.skip
|
||||||
|
|
||||||
local lfs = require('lfs')
|
local luv = require('luv')
|
||||||
local paths = require('test.cmakeconfig.paths')
|
local paths = require('test.cmakeconfig.paths')
|
||||||
|
|
||||||
local mpack = require('mpack')
|
local mpack = require('mpack')
|
||||||
@ -29,7 +29,7 @@ describe('ShaDa support code', function()
|
|||||||
after_each(function()
|
after_each(function()
|
||||||
clear()
|
clear()
|
||||||
clean()
|
clean()
|
||||||
lfs.rmdir(dirname)
|
luv.fs_rmdir(dirname)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('preserves `s` item size limit with unknown entries', function()
|
it('preserves `s` item size limit with unknown entries', function()
|
||||||
@ -81,7 +81,7 @@ describe('ShaDa support code', function()
|
|||||||
wshada('Some text file')
|
wshada('Some text file')
|
||||||
eq(0, exc_exec('wshada! ' .. shada_fname))
|
eq(0, exc_exec('wshada! ' .. shada_fname))
|
||||||
eq(1, read_shada_file(shada_fname)[1].type)
|
eq(1, read_shada_file(shada_fname)[1].type)
|
||||||
eq(nil, lfs.attributes(shada_fname .. '.tmp.a'))
|
eq(nil, luv.fs_stat(shada_fname .. '.tmp.a'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('leaves .tmp.b in-place when there is error in original ShaDa and it has .tmp.a', function()
|
it('leaves .tmp.b in-place when there is error in original ShaDa and it has .tmp.a', function()
|
||||||
@ -251,8 +251,8 @@ describe('ShaDa support code', function()
|
|||||||
local session = spawn({nvim_prog, '-u', 'NONE', '-i', 'NONE', '--embed',
|
local session = spawn({nvim_prog, '-u', 'NONE', '-i', 'NONE', '--embed',
|
||||||
'--headless', '--cmd', 'qall'}, true)
|
'--headless', '--cmd', 'qall'}, true)
|
||||||
session:close()
|
session:close()
|
||||||
eq(nil, lfs.attributes('NONE'))
|
eq(nil, luv.fs_stat('NONE'))
|
||||||
eq(nil, lfs.attributes('NONE.tmp.a'))
|
eq(nil, luv.fs_stat('NONE.tmp.a'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not read NONE file', function()
|
it('does not read NONE file', function()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local Screen = require('test.functional.ui.screen')
|
local Screen = require('test.functional.ui.screen')
|
||||||
local lfs = require('lfs')
|
local luv = require('luv')
|
||||||
local neq, eq, command = helpers.neq, helpers.eq, helpers.command
|
local neq, eq, command = helpers.neq, helpers.eq, helpers.command
|
||||||
local clear, curbufmeths = helpers.clear, helpers.curbufmeths
|
local clear, curbufmeths = helpers.clear, helpers.curbufmeths
|
||||||
local exc_exec, expect, eval = helpers.exc_exec, helpers.expect, helpers.eval
|
local exc_exec, expect, eval = helpers.exc_exec, helpers.expect, helpers.eval
|
||||||
@ -118,7 +118,7 @@ describe('eval-API', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('are highlighted by vim.vim syntax file', function()
|
it('are highlighted by vim.vim syntax file', function()
|
||||||
if lfs.attributes("build/runtime/syntax/vim/generated.vim",'uid') == nil then
|
if luv.fs_stat("build/runtime/syntax/vim/generated.vim").uid == nil then
|
||||||
pending("runtime was not built, skipping test")
|
pending("runtime was not built, skipping test")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
|
|
||||||
local lfs = require('lfs')
|
local luv = require('luv')
|
||||||
|
|
||||||
local eq = helpers.eq
|
local eq = helpers.eq
|
||||||
local clear = helpers.clear
|
local clear = helpers.clear
|
||||||
@ -16,6 +16,7 @@ local curtabmeths = helpers.curtabmeths
|
|||||||
local get_pathsep = helpers.get_pathsep
|
local get_pathsep = helpers.get_pathsep
|
||||||
local rmdir = helpers.rmdir
|
local rmdir = helpers.rmdir
|
||||||
local pcall_err = helpers.pcall_err
|
local pcall_err = helpers.pcall_err
|
||||||
|
local mkdir = helpers.mkdir
|
||||||
|
|
||||||
local fname = 'Xtest-functional-eval-buf_functions'
|
local fname = 'Xtest-functional-eval-buf_functions'
|
||||||
local fname2 = fname .. '.2'
|
local fname2 = fname .. '.2'
|
||||||
@ -62,7 +63,7 @@ describe('bufname() function', function()
|
|||||||
eq('', funcs.bufname('X'))
|
eq('', funcs.bufname('X'))
|
||||||
end)
|
end)
|
||||||
before_each(function()
|
before_each(function()
|
||||||
lfs.mkdir(dirname)
|
mkdir(dirname)
|
||||||
end)
|
end)
|
||||||
after_each(function()
|
after_each(function()
|
||||||
rmdir(dirname)
|
rmdir(dirname)
|
||||||
@ -70,7 +71,7 @@ describe('bufname() function', function()
|
|||||||
it('returns expected buffer name', function()
|
it('returns expected buffer name', function()
|
||||||
eq('', funcs.bufname('%')) -- Buffer has no name yet
|
eq('', funcs.bufname('%')) -- Buffer has no name yet
|
||||||
command('file ' .. fname)
|
command('file ' .. fname)
|
||||||
local wd = lfs.currentdir()
|
local wd = luv.cwd()
|
||||||
local sep = get_pathsep()
|
local sep = get_pathsep()
|
||||||
local curdirname = funcs.fnamemodify(wd, ':t')
|
local curdirname = funcs.fnamemodify(wd, ':t')
|
||||||
for _, arg in ipairs({'%', 1, 'X', wd}) do
|
for _, arg in ipairs({'%', 1, 'X', wd}) do
|
||||||
@ -103,7 +104,7 @@ describe('bufnr() function', function()
|
|||||||
it('returns expected buffer number', function()
|
it('returns expected buffer number', function()
|
||||||
eq(1, funcs.bufnr('%'))
|
eq(1, funcs.bufnr('%'))
|
||||||
command('file ' .. fname)
|
command('file ' .. fname)
|
||||||
local wd = lfs.currentdir()
|
local wd = luv.cwd()
|
||||||
local curdirname = funcs.fnamemodify(wd, ':t')
|
local curdirname = funcs.fnamemodify(wd, ':t')
|
||||||
eq(1, funcs.bufnr(fname))
|
eq(1, funcs.bufnr(fname))
|
||||||
eq(1, funcs.bufnr(wd))
|
eq(1, funcs.bufnr(wd))
|
||||||
@ -144,7 +145,7 @@ describe('bufwinnr() function', function()
|
|||||||
eq(-1, funcs.bufwinnr('X'))
|
eq(-1, funcs.bufwinnr('X'))
|
||||||
end)
|
end)
|
||||||
before_each(function()
|
before_each(function()
|
||||||
lfs.mkdir(dirname)
|
mkdir(dirname)
|
||||||
end)
|
end)
|
||||||
after_each(function()
|
after_each(function()
|
||||||
rmdir(dirname)
|
rmdir(dirname)
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local Screen = require('test.functional.ui.screen')
|
local Screen = require('test.functional.ui.screen')
|
||||||
|
|
||||||
local lfs = require('lfs')
|
local mkdir = helpers.mkdir
|
||||||
local clear = helpers.clear
|
local clear = helpers.clear
|
||||||
local eq = helpers.eq
|
local eq = helpers.eq
|
||||||
local exc_exec = helpers.exc_exec
|
local exc_exec = helpers.exc_exec
|
||||||
@ -56,11 +56,11 @@ end)
|
|||||||
describe("backtick expansion", function()
|
describe("backtick expansion", function()
|
||||||
setup(function()
|
setup(function()
|
||||||
clear()
|
clear()
|
||||||
lfs.mkdir("test-backticks")
|
mkdir("test-backticks")
|
||||||
write_file("test-backticks/file1", "test file 1")
|
write_file("test-backticks/file1", "test file 1")
|
||||||
write_file("test-backticks/file2", "test file 2")
|
write_file("test-backticks/file2", "test file 2")
|
||||||
write_file("test-backticks/file3", "test file 3")
|
write_file("test-backticks/file3", "test file 3")
|
||||||
lfs.mkdir("test-backticks/subdir")
|
mkdir("test-backticks/subdir")
|
||||||
write_file("test-backticks/subdir/file4", "test file 4")
|
write_file("test-backticks/subdir/file4", "test file 4")
|
||||||
-- Long path might cause "Press ENTER" prompt; use :silent to avoid it.
|
-- Long path might cause "Press ENTER" prompt; use :silent to avoid it.
|
||||||
command('silent cd test-backticks')
|
command('silent cd test-backticks')
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
local lfs = require('lfs')
|
local luv = require('luv')
|
||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local clear, command, eval, eq = helpers.clear, helpers.command, helpers.eval, helpers.eq
|
local clear, command, eval, eq = helpers.clear, helpers.command, helpers.eval, helpers.eq
|
||||||
|
local mkdir = helpers.mkdir
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
lfs.mkdir('test-glob')
|
mkdir('test-glob')
|
||||||
|
|
||||||
-- Long path might cause "Press ENTER" prompt; use :silent to avoid it.
|
-- Long path might cause "Press ENTER" prompt; use :silent to avoid it.
|
||||||
command('silent cd test-glob')
|
command('silent cd test-glob')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
after_each(function()
|
after_each(function()
|
||||||
lfs.rmdir('test-glob')
|
luv.fs_rmdir('test-glob')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('glob()', function()
|
describe('glob()', function()
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local lfs = require('lfs')
|
local luv = require('luv')
|
||||||
|
|
||||||
|
local mkdir = helpers.mkdir
|
||||||
local clear = helpers.clear
|
local clear = helpers.clear
|
||||||
local eq = helpers.eq
|
local eq = helpers.eq
|
||||||
local funcs = helpers.funcs
|
local funcs = helpers.funcs
|
||||||
@ -19,16 +20,16 @@ local ddname_tail = '2'
|
|||||||
local ddname = dname .. '/' .. ddname_tail
|
local ddname = dname .. '/' .. ddname_tail
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
lfs.mkdir(dname)
|
mkdir(dname)
|
||||||
lfs.mkdir(ddname)
|
mkdir(ddname)
|
||||||
clear()
|
clear()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
after_each(function()
|
after_each(function()
|
||||||
os.remove(fname)
|
os.remove(fname)
|
||||||
os.remove(dfname)
|
os.remove(dfname)
|
||||||
lfs.rmdir(ddname)
|
luv.fs_rmdir(ddname)
|
||||||
lfs.rmdir(dname)
|
luv.fs_rmdir(dname)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('writefile()', function()
|
describe('writefile()', function()
|
||||||
|
@ -3,7 +3,6 @@ local shared = vim
|
|||||||
local assert = require('luassert')
|
local assert = require('luassert')
|
||||||
local busted = require('busted')
|
local busted = require('busted')
|
||||||
local luv = require('luv')
|
local luv = require('luv')
|
||||||
local lfs = require('lfs')
|
|
||||||
local relpath = require('pl.path').relpath
|
local relpath = require('pl.path').relpath
|
||||||
local Paths = require('test.cmakeconfig.paths')
|
local Paths = require('test.cmakeconfig.paths')
|
||||||
|
|
||||||
@ -22,6 +21,28 @@ local module = {
|
|||||||
REMOVE_THIS = {},
|
REMOVE_THIS = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function module.isdir(path)
|
||||||
|
if not path then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
local stat = luv.fs_stat(path)
|
||||||
|
if not stat then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return stat.type == 'directory'
|
||||||
|
end
|
||||||
|
|
||||||
|
function module.isfile(path)
|
||||||
|
if not path then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
local stat = luv.fs_stat(path)
|
||||||
|
if not stat then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return stat.type == 'file'
|
||||||
|
end
|
||||||
|
|
||||||
function module.argss_to_cmd(...)
|
function module.argss_to_cmd(...)
|
||||||
local cmd = ''
|
local cmd = ''
|
||||||
for i = 1, select('#', ...) do
|
for i = 1, select('#', ...) do
|
||||||
@ -228,16 +249,16 @@ function module.glob(initial_path, re, exc_re)
|
|||||||
while #paths_to_check > 0 do
|
while #paths_to_check > 0 do
|
||||||
local cur_path = paths_to_check[#paths_to_check]
|
local cur_path = paths_to_check[#paths_to_check]
|
||||||
paths_to_check[#paths_to_check] = nil
|
paths_to_check[#paths_to_check] = nil
|
||||||
for e in lfs.dir(cur_path) do
|
for e in vim.fs.dir(cur_path) do
|
||||||
local full_path = cur_path .. '/' .. e
|
local full_path = cur_path .. '/' .. e
|
||||||
local checked_path = full_path:sub(#initial_path + 1)
|
local checked_path = full_path:sub(#initial_path + 1)
|
||||||
if (not is_excluded(checked_path)) and e:sub(1, 1) ~= '.' then
|
if (not is_excluded(checked_path)) and e:sub(1, 1) ~= '.' then
|
||||||
local attrs = lfs.attributes(full_path)
|
local stat = luv.fs_stat(full_path)
|
||||||
if attrs then
|
if stat then
|
||||||
local check_key = attrs.dev .. ':' .. tostring(attrs.ino)
|
local check_key = stat.dev .. ':' .. tostring(stat.ino)
|
||||||
if not checked_files[check_key] then
|
if not checked_files[check_key] then
|
||||||
checked_files[check_key] = true
|
checked_files[check_key] = true
|
||||||
if attrs.mode == 'directory' then
|
if stat.type == 'directory' then
|
||||||
paths_to_check[#paths_to_check + 1] = full_path
|
paths_to_check[#paths_to_check + 1] = full_path
|
||||||
elseif not re or checked_path:match(re) then
|
elseif not re or checked_path:match(re) then
|
||||||
ret[#ret + 1] = full_path
|
ret[#ret + 1] = full_path
|
||||||
@ -253,8 +274,8 @@ end
|
|||||||
function module.check_logs()
|
function module.check_logs()
|
||||||
local log_dir = os.getenv('LOG_DIR')
|
local log_dir = os.getenv('LOG_DIR')
|
||||||
local runtime_errors = {}
|
local runtime_errors = {}
|
||||||
if log_dir and lfs.attributes(log_dir, 'mode') == 'directory' then
|
if log_dir and module.isdir(log_dir) then
|
||||||
for tail in lfs.dir(log_dir) do
|
for tail in vim.fs.dir(log_dir) do
|
||||||
if tail:sub(1, 30) == 'valgrind-' or tail:find('san%.') then
|
if tail:sub(1, 30) == 'valgrind-' or tail:find('san%.') then
|
||||||
local file = log_dir .. '/' .. tail
|
local file = log_dir .. '/' .. tail
|
||||||
local fd = io.open(file)
|
local fd = io.open(file)
|
||||||
@ -843,6 +864,11 @@ function module.read_nvim_log(logfile, ci_rename)
|
|||||||
return log
|
return log
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function module.mkdir(path)
|
||||||
|
-- 493 is 0755 in decimal
|
||||||
|
return luv.fs_mkdir(path, 493)
|
||||||
|
end
|
||||||
|
|
||||||
module = shared.tbl_extend('error', module, Paths, shared, require('test.deprecated'))
|
module = shared.tbl_extend('error', module, Paths, shared, require('test.deprecated'))
|
||||||
|
|
||||||
return module
|
return module
|
||||||
|
@ -10,8 +10,6 @@ local to_cstr = helpers.to_cstr
|
|||||||
local NULL = helpers.NULL
|
local NULL = helpers.NULL
|
||||||
local OK = 0
|
local OK = 0
|
||||||
|
|
||||||
require('lfs')
|
|
||||||
|
|
||||||
local cimp = cimport('./src/nvim/os/os.h')
|
local cimp = cimport('./src/nvim/os/os.h')
|
||||||
|
|
||||||
describe('env.c', function()
|
describe('env.c', function()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
local lfs = require('lfs')
|
local luv = require('luv')
|
||||||
|
|
||||||
local helpers = require('test.unit.helpers')(after_each)
|
local helpers = require('test.unit.helpers')(after_each)
|
||||||
local itp = helpers.gen_itp(it)
|
local itp = helpers.gen_itp(it)
|
||||||
@ -7,6 +7,7 @@ local eq = helpers.eq
|
|||||||
local ffi = helpers.ffi
|
local ffi = helpers.ffi
|
||||||
local cimport = helpers.cimport
|
local cimport = helpers.cimport
|
||||||
local cppimport = helpers.cppimport
|
local cppimport = helpers.cppimport
|
||||||
|
local mkdir = helpers.mkdir
|
||||||
|
|
||||||
local m = cimport('./src/nvim/os/os.h', './src/nvim/os/fileio.h')
|
local m = cimport('./src/nvim/os/os.h', './src/nvim/os/fileio.h')
|
||||||
cppimport('fcntl.h')
|
cppimport('fcntl.h')
|
||||||
@ -25,7 +26,7 @@ local linkb = dir .. '/broken.lnk'
|
|||||||
local filec = dir .. '/created-file.dat'
|
local filec = dir .. '/created-file.dat'
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
lfs.mkdir(dir);
|
mkdir(dir);
|
||||||
|
|
||||||
local f1 = io.open(file1, 'w')
|
local f1 = io.open(file1, 'w')
|
||||||
f1:write(fcontents)
|
f1:write(fcontents)
|
||||||
@ -35,8 +36,8 @@ before_each(function()
|
|||||||
f2:write(fcontents)
|
f2:write(fcontents)
|
||||||
f2:close()
|
f2:close()
|
||||||
|
|
||||||
lfs.link('file1.dat', linkf, true)
|
luv.fs_symlink('file1.dat', linkf)
|
||||||
lfs.link('broken.dat', linkb, true)
|
luv.fs_symlink('broken.dat', linkb)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
after_each(function()
|
after_each(function()
|
||||||
@ -45,7 +46,7 @@ after_each(function()
|
|||||||
os.remove(linkf)
|
os.remove(linkf)
|
||||||
os.remove(linkb)
|
os.remove(linkb)
|
||||||
os.remove(filec)
|
os.remove(filec)
|
||||||
lfs.rmdir(dir)
|
luv.fs_rmdir(dir)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local function file_open(fname, flags, mode)
|
local function file_open(fname, flags, mode)
|
||||||
@ -119,13 +120,13 @@ describe('file_open_fd', function()
|
|||||||
eq(0, m.file_close(fp, false))
|
eq(0, m.file_close(fp, false))
|
||||||
end)
|
end)
|
||||||
itp('can use file descriptor returned by os_open for writing', function()
|
itp('can use file descriptor returned by os_open for writing', function()
|
||||||
eq(nil, lfs.attributes(filec))
|
eq(nil, luv.fs_stat(filec))
|
||||||
local fd = m.os_open(filec, m.kO_WRONLY + m.kO_CREAT, 384)
|
local fd = m.os_open(filec, m.kO_WRONLY + m.kO_CREAT, 384)
|
||||||
local err, fp = file_open_fd(fd, m.kFileWriteOnly)
|
local err, fp = file_open_fd(fd, m.kFileWriteOnly)
|
||||||
eq(0, err)
|
eq(0, err)
|
||||||
eq(4, file_write(fp, 'test'))
|
eq(4, file_write(fp, 'test'))
|
||||||
eq(0, m.file_close(fp, false))
|
eq(0, m.file_close(fp, false))
|
||||||
eq(4, lfs.attributes(filec).size)
|
eq(4, luv.fs_stat(filec).size)
|
||||||
eq('test', io.open(filec):read('*a'))
|
eq('test', io.open(filec):read('*a'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
@ -139,13 +140,13 @@ describe('file_open_fd_new', function()
|
|||||||
eq(0, m.file_free(fp, false))
|
eq(0, m.file_free(fp, false))
|
||||||
end)
|
end)
|
||||||
itp('can use file descriptor returned by os_open for writing', function()
|
itp('can use file descriptor returned by os_open for writing', function()
|
||||||
eq(nil, lfs.attributes(filec))
|
eq(nil, luv.fs_stat(filec))
|
||||||
local fd = m.os_open(filec, m.kO_WRONLY + m.kO_CREAT, 384)
|
local fd = m.os_open(filec, m.kO_WRONLY + m.kO_CREAT, 384)
|
||||||
local err, fp = file_open_fd_new(fd, m.kFileWriteOnly)
|
local err, fp = file_open_fd_new(fd, m.kFileWriteOnly)
|
||||||
eq(0, err)
|
eq(0, err)
|
||||||
eq(4, file_write(fp, 'test'))
|
eq(4, file_write(fp, 'test'))
|
||||||
eq(0, m.file_free(fp, false))
|
eq(0, m.file_free(fp, false))
|
||||||
eq(4, lfs.attributes(filec).size)
|
eq(4, luv.fs_stat(filec).size)
|
||||||
eq('test', io.open(filec):read('*a'))
|
eq('test', io.open(filec):read('*a'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
@ -154,32 +155,32 @@ describe('file_open', function()
|
|||||||
itp('can create a rwx------ file with kFileCreate', function()
|
itp('can create a rwx------ file with kFileCreate', function()
|
||||||
local err, fp = file_open(filec, m.kFileCreate, 448)
|
local err, fp = file_open(filec, m.kFileCreate, 448)
|
||||||
eq(0, err)
|
eq(0, err)
|
||||||
local attrs = lfs.attributes(filec)
|
local attrs = luv.fs_stat(filec)
|
||||||
eq('rwx------', attrs.permissions)
|
eq(33216, attrs.mode)
|
||||||
eq(0, m.file_close(fp, false))
|
eq(0, m.file_close(fp, false))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
itp('can create a rw------- file with kFileCreate', function()
|
itp('can create a rw------- file with kFileCreate', function()
|
||||||
local err, fp = file_open(filec, m.kFileCreate, 384)
|
local err, fp = file_open(filec, m.kFileCreate, 384)
|
||||||
eq(0, err)
|
eq(0, err)
|
||||||
local attrs = lfs.attributes(filec)
|
local attrs = luv.fs_stat(filec)
|
||||||
eq('rw-------', attrs.permissions)
|
eq(33152, attrs.mode)
|
||||||
eq(0, m.file_close(fp, false))
|
eq(0, m.file_close(fp, false))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
itp('can create a rwx------ file with kFileCreateOnly', function()
|
itp('can create a rwx------ file with kFileCreateOnly', function()
|
||||||
local err, fp = file_open(filec, m.kFileCreateOnly, 448)
|
local err, fp = file_open(filec, m.kFileCreateOnly, 448)
|
||||||
eq(0, err)
|
eq(0, err)
|
||||||
local attrs = lfs.attributes(filec)
|
local attrs = luv.fs_stat(filec)
|
||||||
eq('rwx------', attrs.permissions)
|
eq(33216, attrs.mode)
|
||||||
eq(0, m.file_close(fp, false))
|
eq(0, m.file_close(fp, false))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
itp('can create a rw------- file with kFileCreateOnly', function()
|
itp('can create a rw------- file with kFileCreateOnly', function()
|
||||||
local err, fp = file_open(filec, m.kFileCreateOnly, 384)
|
local err, fp = file_open(filec, m.kFileCreateOnly, 384)
|
||||||
eq(0, err)
|
eq(0, err)
|
||||||
local attrs = lfs.attributes(filec)
|
local attrs = luv.fs_stat(filec)
|
||||||
eq('rw-------', attrs.permissions)
|
eq(33152, attrs.mode)
|
||||||
eq(0, m.file_close(fp, false))
|
eq(0, m.file_close(fp, false))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -228,7 +229,7 @@ describe('file_open', function()
|
|||||||
eq(0, err)
|
eq(0, err)
|
||||||
eq(true, fp.wr)
|
eq(true, fp.wr)
|
||||||
eq(0, m.file_close(fp, false))
|
eq(0, m.file_close(fp, false))
|
||||||
local attrs = lfs.attributes(file1)
|
local attrs = luv.fs_stat(file1)
|
||||||
eq(0, attrs.size)
|
eq(0, attrs.size)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -237,14 +238,14 @@ describe('file_open', function()
|
|||||||
eq(0, err)
|
eq(0, err)
|
||||||
eq(true, fp.wr)
|
eq(true, fp.wr)
|
||||||
eq(0, m.file_close(fp, false))
|
eq(0, m.file_close(fp, false))
|
||||||
local attrs = lfs.attributes(file1)
|
local attrs = luv.fs_stat(file1)
|
||||||
eq(4096, attrs.size)
|
eq(4096, attrs.size)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
itp('fails to create a file with just kFileWriteOnly', function()
|
itp('fails to create a file with just kFileWriteOnly', function()
|
||||||
local err, _ = file_open(filec, m.kFileWriteOnly, 384)
|
local err, _ = file_open(filec, m.kFileWriteOnly, 384)
|
||||||
eq(m.UV_ENOENT, err)
|
eq(m.UV_ENOENT, err)
|
||||||
local attrs = lfs.attributes(filec)
|
local attrs = luv.fs_stat(filec)
|
||||||
eq(nil, attrs)
|
eq(nil, attrs)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -254,7 +255,7 @@ describe('file_open', function()
|
|||||||
eq(0, err)
|
eq(0, err)
|
||||||
eq(true, fp.wr)
|
eq(true, fp.wr)
|
||||||
eq(0, m.file_close(fp, false))
|
eq(0, m.file_close(fp, false))
|
||||||
local attrs = lfs.attributes(file1)
|
local attrs = luv.fs_stat(file1)
|
||||||
eq(0, attrs.size)
|
eq(0, attrs.size)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -295,9 +296,9 @@ describe('file_close', function()
|
|||||||
eq(0, err)
|
eq(0, err)
|
||||||
local wsize = file_write(fp, 'test')
|
local wsize = file_write(fp, 'test')
|
||||||
eq(4, wsize)
|
eq(4, wsize)
|
||||||
eq(0, lfs.attributes(filec).size)
|
eq(0, luv.fs_stat(filec).size)
|
||||||
eq(0, m.file_close(fp, true))
|
eq(0, m.file_close(fp, true))
|
||||||
eq(wsize, lfs.attributes(filec).size)
|
eq(wsize, luv.fs_stat(filec).size)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -307,9 +308,9 @@ describe('file_free', function()
|
|||||||
eq(0, err)
|
eq(0, err)
|
||||||
local wsize = file_write(fp, 'test')
|
local wsize = file_write(fp, 'test')
|
||||||
eq(4, wsize)
|
eq(4, wsize)
|
||||||
eq(0, lfs.attributes(filec).size)
|
eq(0, luv.fs_stat(filec).size)
|
||||||
eq(0, m.file_free(fp, true))
|
eq(0, m.file_free(fp, true))
|
||||||
eq(wsize, lfs.attributes(filec).size)
|
eq(wsize, luv.fs_stat(filec).size)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -318,12 +319,12 @@ describe('file_fsync', function()
|
|||||||
local err, fp = file_open(filec, m.kFileCreateOnly, 384)
|
local err, fp = file_open(filec, m.kFileCreateOnly, 384)
|
||||||
eq(0, file_fsync(fp))
|
eq(0, file_fsync(fp))
|
||||||
eq(0, err)
|
eq(0, err)
|
||||||
eq(0, lfs.attributes(filec).size)
|
eq(0, luv.fs_stat(filec).size)
|
||||||
local wsize = file_write(fp, 'test')
|
local wsize = file_write(fp, 'test')
|
||||||
eq(4, wsize)
|
eq(4, wsize)
|
||||||
eq(0, lfs.attributes(filec).size)
|
eq(0, luv.fs_stat(filec).size)
|
||||||
eq(0, file_fsync(fp))
|
eq(0, file_fsync(fp))
|
||||||
eq(wsize, lfs.attributes(filec).size)
|
eq(wsize, luv.fs_stat(filec).size)
|
||||||
eq(0, m.file_close(fp, false))
|
eq(0, m.file_close(fp, false))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
@ -333,12 +334,12 @@ describe('file_flush', function()
|
|||||||
local err, fp = file_open(filec, m.kFileCreateOnly, 384)
|
local err, fp = file_open(filec, m.kFileCreateOnly, 384)
|
||||||
eq(0, file_flush(fp))
|
eq(0, file_flush(fp))
|
||||||
eq(0, err)
|
eq(0, err)
|
||||||
eq(0, lfs.attributes(filec).size)
|
eq(0, luv.fs_stat(filec).size)
|
||||||
local wsize = file_write(fp, 'test')
|
local wsize = file_write(fp, 'test')
|
||||||
eq(4, wsize)
|
eq(4, wsize)
|
||||||
eq(0, lfs.attributes(filec).size)
|
eq(0, luv.fs_stat(filec).size)
|
||||||
eq(0, file_flush(fp))
|
eq(0, file_flush(fp))
|
||||||
eq(wsize, lfs.attributes(filec).size)
|
eq(wsize, luv.fs_stat(filec).size)
|
||||||
eq(0, m.file_close(fp, false))
|
eq(0, m.file_close(fp, false))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
@ -412,7 +413,7 @@ describe('file_write', function()
|
|||||||
local wr = file_write(fp, fcontents)
|
local wr = file_write(fp, fcontents)
|
||||||
eq(#fcontents, wr)
|
eq(#fcontents, wr)
|
||||||
eq(0, m.file_close(fp, false))
|
eq(0, m.file_close(fp, false))
|
||||||
eq(wr, lfs.attributes(filec).size)
|
eq(wr, luv.fs_stat(filec).size)
|
||||||
eq(fcontents, io.open(filec):read('*a'))
|
eq(fcontents, io.open(filec):read('*a'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -429,7 +430,7 @@ describe('file_write', function()
|
|||||||
shift = shift + size
|
shift = shift + size
|
||||||
end
|
end
|
||||||
eq(0, m.file_close(fp, false))
|
eq(0, m.file_close(fp, false))
|
||||||
eq(#fcontents, lfs.attributes(filec).size)
|
eq(#fcontents, luv.fs_stat(filec).size)
|
||||||
eq(fcontents, io.open(filec):read('*a'))
|
eq(fcontents, io.open(filec):read('*a'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -446,7 +447,7 @@ describe('file_write', function()
|
|||||||
shift = shift + size
|
shift = shift + size
|
||||||
end
|
end
|
||||||
eq(0, m.file_close(fp, false))
|
eq(0, m.file_close(fp, false))
|
||||||
eq(#fcontents, lfs.attributes(filec).size)
|
eq(#fcontents, luv.fs_stat(filec).size)
|
||||||
eq(fcontents, io.open(filec):read('*a'))
|
eq(fcontents, io.open(filec):read('*a'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
local lfs = require('lfs')
|
local luv = require('luv')
|
||||||
local bit = require('bit')
|
local bit = require('bit')
|
||||||
|
|
||||||
local helpers = require('test.unit.helpers')(after_each)
|
local helpers = require('test.unit.helpers')(after_each)
|
||||||
@ -16,6 +16,7 @@ local to_cstr = helpers.to_cstr
|
|||||||
local OK = helpers.OK
|
local OK = helpers.OK
|
||||||
local FAIL = helpers.FAIL
|
local FAIL = helpers.FAIL
|
||||||
local NULL = helpers.NULL
|
local NULL = helpers.NULL
|
||||||
|
local mkdir = helpers.mkdir
|
||||||
|
|
||||||
local NODE_NORMAL = 0
|
local NODE_NORMAL = 0
|
||||||
local NODE_WRITABLE = 1
|
local NODE_WRITABLE = 1
|
||||||
@ -48,11 +49,11 @@ local function unset_bit(number, to_unset)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function assert_file_exists(filepath)
|
local function assert_file_exists(filepath)
|
||||||
neq(nil, lfs.attributes(filepath))
|
neq(nil, luv.fs_stat(filepath))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function assert_file_does_not_exist(filepath)
|
local function assert_file_does_not_exist(filepath)
|
||||||
eq(nil, lfs.attributes(filepath))
|
eq(nil, luv.fs_stat(filepath))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function os_setperm(filename, perm)
|
local function os_setperm(filename, perm)
|
||||||
@ -70,14 +71,14 @@ describe('fs.c', function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
lfs.mkdir('unit-test-directory');
|
mkdir('unit-test-directory');
|
||||||
|
|
||||||
io.open('unit-test-directory/test.file', 'w'):close()
|
io.open('unit-test-directory/test.file', 'w'):close()
|
||||||
|
|
||||||
io.open('unit-test-directory/test_2.file', 'w'):close()
|
io.open('unit-test-directory/test_2.file', 'w'):close()
|
||||||
lfs.link('test.file', 'unit-test-directory/test_link.file', true)
|
luv.fs_symlink('test.file', 'unit-test-directory/test_link.file')
|
||||||
|
|
||||||
lfs.link('non_existing_file.file', 'unit-test-directory/test_broken_link.file', true)
|
luv.fs_symlink('non_existing_file.file', 'unit-test-directory/test_broken_link.file')
|
||||||
-- The tests are invoked with an absolute path to `busted` executable.
|
-- The tests are invoked with an absolute path to `busted` executable.
|
||||||
absolute_executable = arg[0]
|
absolute_executable = arg[0]
|
||||||
-- Split the absolute_executable path into a directory and filename.
|
-- Split the absolute_executable path into a directory and filename.
|
||||||
@ -90,19 +91,19 @@ describe('fs.c', function()
|
|||||||
os.remove('unit-test-directory/test_link.file')
|
os.remove('unit-test-directory/test_link.file')
|
||||||
os.remove('unit-test-directory/test_hlink.file')
|
os.remove('unit-test-directory/test_hlink.file')
|
||||||
os.remove('unit-test-directory/test_broken_link.file')
|
os.remove('unit-test-directory/test_broken_link.file')
|
||||||
lfs.rmdir('unit-test-directory')
|
luv.fs_rmdir('unit-test-directory')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('os_dirname', function()
|
describe('os_dirname', function()
|
||||||
itp('returns OK and writes current directory to the buffer', function()
|
itp('returns OK and writes current directory to the buffer', function()
|
||||||
local length = string.len(lfs.currentdir()) + 1
|
local length = string.len(luv.cwd()) + 1
|
||||||
local buf = cstr(length, '')
|
local buf = cstr(length, '')
|
||||||
eq(OK, fs.os_dirname(buf, length))
|
eq(OK, fs.os_dirname(buf, length))
|
||||||
eq(lfs.currentdir(), ffi.string(buf))
|
eq(luv.cwd(), ffi.string(buf))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
itp('returns FAIL if the buffer is too small', function()
|
itp('returns FAIL if the buffer is too small', function()
|
||||||
local length = string.len(lfs.currentdir()) + 1
|
local length = string.len(luv.cwd()) + 1
|
||||||
local buf = cstr(length - 1, '')
|
local buf = cstr(length - 1, '')
|
||||||
eq(FAIL, fs.os_dirname(buf, length - 1))
|
eq(FAIL, fs.os_dirname(buf, length - 1))
|
||||||
end)
|
end)
|
||||||
@ -203,20 +204,20 @@ describe('fs.c', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
itp('returns the absolute path when given an executable relative to the current dir', function()
|
itp('returns the absolute path when given an executable relative to the current dir', function()
|
||||||
local old_dir = lfs.currentdir()
|
local old_dir = luv.cwd()
|
||||||
|
|
||||||
lfs.chdir(directory)
|
luv.chdir(directory)
|
||||||
|
|
||||||
-- Rely on currentdir to resolve symlinks, if any. Testing against
|
-- Rely on currentdir to resolve symlinks, if any. Testing against
|
||||||
-- the absolute path taken from arg[0] may result in failure where
|
-- the absolute path taken from arg[0] may result in failure where
|
||||||
-- the path has a symlink in it.
|
-- the path has a symlink in it.
|
||||||
local canonical = lfs.currentdir() .. '/' .. executable_name
|
local canonical = luv.cwd() .. '/' .. executable_name
|
||||||
local expected = exe(canonical)
|
local expected = exe(canonical)
|
||||||
local relative_executable = './' .. executable_name
|
local relative_executable = './' .. executable_name
|
||||||
local res = exe(relative_executable)
|
local res = exe(relative_executable)
|
||||||
|
|
||||||
-- Don't test yet; we need to chdir back first.
|
-- Don't test yet; we need to chdir back first.
|
||||||
lfs.chdir(old_dir)
|
luv.chdir(old_dir)
|
||||||
eq(expected, res)
|
eq(expected, res)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
@ -278,11 +279,11 @@ describe('fs.c', function()
|
|||||||
describe('os_fchown', function()
|
describe('os_fchown', function()
|
||||||
local filename = 'unit-test-directory/test.file'
|
local filename = 'unit-test-directory/test.file'
|
||||||
itp('does not change owner and group if respective IDs are equal to -1', function()
|
itp('does not change owner and group if respective IDs are equal to -1', function()
|
||||||
local uid = lfs.attributes(filename, 'uid')
|
local uid = luv.fs_stat(filename).uid
|
||||||
local gid = lfs.attributes(filename, 'gid')
|
local gid = luv.fs_stat(filename).gid
|
||||||
eq(0, os_fchown(filename, -1, -1))
|
eq(0, os_fchown(filename, -1, -1))
|
||||||
eq(uid, lfs.attributes(filename, 'uid'))
|
eq(uid, luv.fs_stat(filename).uid)
|
||||||
return eq(gid, lfs.attributes(filename, 'gid'))
|
return eq(gid, luv.fs_stat(filename).gid)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Some systems may not have `id` utility.
|
-- Some systems may not have `id` utility.
|
||||||
@ -290,7 +291,7 @@ describe('fs.c', function()
|
|||||||
pending('skipped (missing `id` utility)', function() end)
|
pending('skipped (missing `id` utility)', function() end)
|
||||||
else
|
else
|
||||||
itp('owner of a file may change the group of the file to any group of which that owner is a member', function()
|
itp('owner of a file may change the group of the file to any group of which that owner is a member', function()
|
||||||
local file_gid = lfs.attributes(filename, 'gid')
|
local file_gid = luv.fs_stat(filename).gid
|
||||||
|
|
||||||
-- Gets ID of any group of which current user is a member except the
|
-- Gets ID of any group of which current user is a member except the
|
||||||
-- group that owns the file.
|
-- group that owns the file.
|
||||||
@ -305,7 +306,7 @@ describe('fs.c', function()
|
|||||||
-- In that case we can not perform this test.
|
-- In that case we can not perform this test.
|
||||||
if new_gid then
|
if new_gid then
|
||||||
eq(0, (os_fchown(filename, -1, new_gid)))
|
eq(0, (os_fchown(filename, -1, new_gid)))
|
||||||
eq(new_gid, (lfs.attributes(filename, 'gid')))
|
eq(new_gid, luv.fs_stat(filename).gid)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@ -548,7 +549,7 @@ describe('fs.c', function()
|
|||||||
--create the file
|
--create the file
|
||||||
local fd = os_open(new_file, ffi.C.kO_CREAT, tonumber("700", 8))
|
local fd = os_open(new_file, ffi.C.kO_CREAT, tonumber("700", 8))
|
||||||
--verify permissions
|
--verify permissions
|
||||||
eq('rwx------', lfs.attributes(new_file)['permissions'])
|
eq(33216, luv.fs_stat(new_file).mode)
|
||||||
eq(0, os_close(fd))
|
eq(0, os_close(fd))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -557,7 +558,7 @@ describe('fs.c', function()
|
|||||||
--create the file
|
--create the file
|
||||||
local fd = os_open(new_file, ffi.C.kO_CREAT, tonumber("600", 8))
|
local fd = os_open(new_file, ffi.C.kO_CREAT, tonumber("600", 8))
|
||||||
--verify permissions
|
--verify permissions
|
||||||
eq('rw-------', lfs.attributes(new_file)['permissions'])
|
eq(33152, luv.fs_stat(new_file).mode)
|
||||||
eq(0, os_close(fd))
|
eq(0, os_close(fd))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -766,7 +767,7 @@ describe('fs.c', function()
|
|||||||
eq(false, (os_isdir('unit-test-directory/new-dir')))
|
eq(false, (os_isdir('unit-test-directory/new-dir')))
|
||||||
eq(0, (os_mkdir('unit-test-directory/new-dir', mode)))
|
eq(0, (os_mkdir('unit-test-directory/new-dir', mode)))
|
||||||
eq(true, (os_isdir('unit-test-directory/new-dir')))
|
eq(true, (os_isdir('unit-test-directory/new-dir')))
|
||||||
lfs.rmdir('unit-test-directory/new-dir')
|
luv.fs_rmdir('unit-test-directory/new-dir')
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -801,7 +802,7 @@ describe('fs.c', function()
|
|||||||
eq(0, ret)
|
eq(0, ret)
|
||||||
eq(nil, failed_str)
|
eq(nil, failed_str)
|
||||||
eq(true, os_isdir('unit-test-directory/new-dir-recurse'))
|
eq(true, os_isdir('unit-test-directory/new-dir-recurse'))
|
||||||
lfs.rmdir('unit-test-directory/new-dir-recurse')
|
luv.fs_rmdir('unit-test-directory/new-dir-recurse')
|
||||||
eq(false, os_isdir('unit-test-directory/new-dir-recurse'))
|
eq(false, os_isdir('unit-test-directory/new-dir-recurse'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -812,7 +813,7 @@ describe('fs.c', function()
|
|||||||
eq(0, ret)
|
eq(0, ret)
|
||||||
eq(nil, failed_str)
|
eq(nil, failed_str)
|
||||||
eq(true, os_isdir('unit-test-directory/new-dir-recurse'))
|
eq(true, os_isdir('unit-test-directory/new-dir-recurse'))
|
||||||
lfs.rmdir('unit-test-directory/new-dir-recurse')
|
luv.fs_rmdir('unit-test-directory/new-dir-recurse')
|
||||||
eq(false, os_isdir('unit-test-directory/new-dir-recurse'))
|
eq(false, os_isdir('unit-test-directory/new-dir-recurse'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -823,7 +824,7 @@ describe('fs.c', function()
|
|||||||
eq(0, ret)
|
eq(0, ret)
|
||||||
eq(nil, failed_str)
|
eq(nil, failed_str)
|
||||||
eq(true, os_isdir('unit-test-directory/new-dir-recurse'))
|
eq(true, os_isdir('unit-test-directory/new-dir-recurse'))
|
||||||
lfs.rmdir('unit-test-directory/new-dir-recurse')
|
luv.fs_rmdir('unit-test-directory/new-dir-recurse')
|
||||||
eq(false, os_isdir('unit-test-directory/new-dir-recurse'))
|
eq(false, os_isdir('unit-test-directory/new-dir-recurse'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -837,10 +838,10 @@ describe('fs.c', function()
|
|||||||
eq(true, os_isdir('unit-test-directory/new-dir-recurse/1'))
|
eq(true, os_isdir('unit-test-directory/new-dir-recurse/1'))
|
||||||
eq(true, os_isdir('unit-test-directory/new-dir-recurse/1/2'))
|
eq(true, os_isdir('unit-test-directory/new-dir-recurse/1/2'))
|
||||||
eq(true, os_isdir('unit-test-directory/new-dir-recurse/1/2/3'))
|
eq(true, os_isdir('unit-test-directory/new-dir-recurse/1/2/3'))
|
||||||
lfs.rmdir('unit-test-directory/new-dir-recurse/1/2/3')
|
luv.fs_rmdir('unit-test-directory/new-dir-recurse/1/2/3')
|
||||||
lfs.rmdir('unit-test-directory/new-dir-recurse/1/2')
|
luv.fs_rmdir('unit-test-directory/new-dir-recurse/1/2')
|
||||||
lfs.rmdir('unit-test-directory/new-dir-recurse/1')
|
luv.fs_rmdir('unit-test-directory/new-dir-recurse/1')
|
||||||
lfs.rmdir('unit-test-directory/new-dir-recurse')
|
luv.fs_rmdir('unit-test-directory/new-dir-recurse')
|
||||||
eq(false, os_isdir('unit-test-directory/new-dir-recurse'))
|
eq(false, os_isdir('unit-test-directory/new-dir-recurse'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
@ -851,7 +852,7 @@ describe('fs.c', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
itp('removes the given directory and returns 0', function()
|
itp('removes the given directory and returns 0', function()
|
||||||
lfs.mkdir('unit-test-directory/new-dir')
|
mkdir('unit-test-directory/new-dir')
|
||||||
eq(0, os_rmdir('unit-test-directory/new-dir'))
|
eq(0, os_rmdir('unit-test-directory/new-dir'))
|
||||||
eq(false, (os_isdir('unit-test-directory/new-dir')))
|
eq(false, (os_isdir('unit-test-directory/new-dir')))
|
||||||
end)
|
end)
|
||||||
@ -1005,7 +1006,7 @@ describe('fs.c', function()
|
|||||||
file:write('some bytes to get filesize != 0')
|
file:write('some bytes to get filesize != 0')
|
||||||
file:flush()
|
file:flush()
|
||||||
file:close()
|
file:close()
|
||||||
local size = lfs.attributes(path, 'size')
|
local size = luv.fs_stat(path).size
|
||||||
local info = file_info_new()
|
local info = file_info_new()
|
||||||
assert.is_true(fs.os_fileinfo(path, info))
|
assert.is_true(fs.os_fileinfo(path, info))
|
||||||
eq(size, fs.os_fileinfo_size(info))
|
eq(size, fs.os_fileinfo_size(info))
|
||||||
@ -1019,7 +1020,7 @@ describe('fs.c', function()
|
|||||||
local info = file_info_new()
|
local info = file_info_new()
|
||||||
assert.is_true(fs.os_fileinfo(path, info))
|
assert.is_true(fs.os_fileinfo(path, info))
|
||||||
eq(1, fs.os_fileinfo_hardlinks(info))
|
eq(1, fs.os_fileinfo_hardlinks(info))
|
||||||
lfs.link(path, path_link)
|
luv.fs_link(path, path_link)
|
||||||
assert.is_true(fs.os_fileinfo(path, info))
|
assert.is_true(fs.os_fileinfo(path, info))
|
||||||
eq(2, fs.os_fileinfo_hardlinks(info))
|
eq(2, fs.os_fileinfo_hardlinks(info))
|
||||||
end)
|
end)
|
||||||
@ -1028,11 +1029,7 @@ describe('fs.c', function()
|
|||||||
describe('os_fileinfo_blocksize', function()
|
describe('os_fileinfo_blocksize', function()
|
||||||
itp('returns the correct blocksize of a file', function()
|
itp('returns the correct blocksize of a file', function()
|
||||||
local path = 'unit-test-directory/test.file'
|
local path = 'unit-test-directory/test.file'
|
||||||
-- there is a bug in luafilesystem where
|
local blksize = luv.fs_stat(path).blksize
|
||||||
-- `lfs.attributes path, 'blksize'` returns the wrong value:
|
|
||||||
-- https://github.com/keplerproject/luafilesystem/pull/44
|
|
||||||
-- using this workaround for now:
|
|
||||||
local blksize = lfs.attributes(path).blksize
|
|
||||||
local info = file_info_new()
|
local info = file_info_new()
|
||||||
assert.is_true(fs.os_fileinfo(path, info))
|
assert.is_true(fs.os_fileinfo(path, info))
|
||||||
if blksize then
|
if blksize then
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
local lfs = require('lfs')
|
local luv = require('luv')
|
||||||
local helpers = require('test.unit.helpers')(after_each)
|
local helpers = require('test.unit.helpers')(after_each)
|
||||||
local itp = helpers.gen_itp(it)
|
local itp = helpers.gen_itp(it)
|
||||||
|
|
||||||
@ -11,6 +11,7 @@ local to_cstr = helpers.to_cstr
|
|||||||
local NULL = helpers.NULL
|
local NULL = helpers.NULL
|
||||||
local OK = helpers.OK
|
local OK = helpers.OK
|
||||||
local FAIL = helpers.FAIL
|
local FAIL = helpers.FAIL
|
||||||
|
local mkdir = helpers.mkdir
|
||||||
|
|
||||||
cimport('string.h')
|
cimport('string.h')
|
||||||
local cimp = cimport('./src/nvim/os/os.h', './src/nvim/path.h')
|
local cimp = cimport('./src/nvim/os/os.h', './src/nvim/path.h')
|
||||||
@ -21,11 +22,11 @@ local buffer = nil
|
|||||||
describe('path.c', function()
|
describe('path.c', function()
|
||||||
describe('path_full_dir_name', function()
|
describe('path_full_dir_name', function()
|
||||||
setup(function()
|
setup(function()
|
||||||
lfs.mkdir('unit-test-directory')
|
mkdir('unit-test-directory')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
teardown(function()
|
teardown(function()
|
||||||
lfs.rmdir('unit-test-directory')
|
luv.fs_rmdir('unit-test-directory')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local function path_full_dir_name(directory, buf, len)
|
local function path_full_dir_name(directory, buf, len)
|
||||||
@ -35,34 +36,34 @@ describe('path.c', function()
|
|||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
-- Create empty string buffer which will contain the resulting path.
|
-- Create empty string buffer which will contain the resulting path.
|
||||||
length = string.len(lfs.currentdir()) + 22
|
length = string.len(luv.cwd()) + 22
|
||||||
buffer = cstr(length, '')
|
buffer = cstr(length, '')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
itp('returns the absolute directory name of a given relative one', function()
|
itp('returns the absolute directory name of a given relative one', function()
|
||||||
local result = path_full_dir_name('..', buffer, length)
|
local result = path_full_dir_name('..', buffer, length)
|
||||||
eq(OK, result)
|
eq(OK, result)
|
||||||
local old_dir = lfs.currentdir()
|
local old_dir = luv.cwd()
|
||||||
lfs.chdir('..')
|
luv.chdir('..')
|
||||||
local expected = lfs.currentdir()
|
local expected = luv.cwd()
|
||||||
lfs.chdir(old_dir)
|
luv.chdir(old_dir)
|
||||||
eq(expected, (ffi.string(buffer)))
|
eq(expected, (ffi.string(buffer)))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
itp('returns the current directory name if the given string is empty', function()
|
itp('returns the current directory name if the given string is empty', function()
|
||||||
eq(OK, (path_full_dir_name('', buffer, length)))
|
eq(OK, (path_full_dir_name('', buffer, length)))
|
||||||
eq(lfs.currentdir(), (ffi.string(buffer)))
|
eq(luv.cwd(), (ffi.string(buffer)))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
itp('works with a normal relative dir', function()
|
itp('works with a normal relative dir', function()
|
||||||
local result = path_full_dir_name('unit-test-directory', buffer, length)
|
local result = path_full_dir_name('unit-test-directory', buffer, length)
|
||||||
eq(lfs.currentdir() .. '/unit-test-directory', (ffi.string(buffer)))
|
eq(luv.cwd() .. '/unit-test-directory', (ffi.string(buffer)))
|
||||||
eq(OK, result)
|
eq(OK, result)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
itp('works with a non-existing relative dir', function()
|
itp('works with a non-existing relative dir', function()
|
||||||
local result = path_full_dir_name('does-not-exist', buffer, length)
|
local result = path_full_dir_name('does-not-exist', buffer, length)
|
||||||
eq(lfs.currentdir() .. '/does-not-exist', (ffi.string(buffer)))
|
eq(luv.cwd() .. '/does-not-exist', (ffi.string(buffer)))
|
||||||
eq(OK, result)
|
eq(OK, result)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -268,27 +269,27 @@ describe('path.c', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
describe('path_try_shorten_fname', function()
|
describe('path_try_shorten_fname', function()
|
||||||
local cwd = lfs.currentdir()
|
local cwd = luv.cwd()
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
lfs.mkdir('ut_directory')
|
mkdir('ut_directory')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
after_each(function()
|
after_each(function()
|
||||||
lfs.chdir(cwd)
|
luv.chdir(cwd)
|
||||||
lfs.rmdir('ut_directory')
|
luv.fs_rmdir('ut_directory')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('path_try_shorten_fname', function()
|
describe('path_try_shorten_fname', function()
|
||||||
itp('returns shortened path if possible', function()
|
itp('returns shortened path if possible', function()
|
||||||
lfs.chdir('ut_directory')
|
luv.chdir('ut_directory')
|
||||||
local full = to_cstr(lfs.currentdir() .. '/subdir/file.txt')
|
local full = to_cstr(luv.cwd() .. '/subdir/file.txt')
|
||||||
eq('subdir/file.txt', (ffi.string(cimp.path_try_shorten_fname(full))))
|
eq('subdir/file.txt', (ffi.string(cimp.path_try_shorten_fname(full))))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
itp('returns `full_path` if a shorter version is not possible', function()
|
itp('returns `full_path` if a shorter version is not possible', function()
|
||||||
local old = lfs.currentdir()
|
local old = luv.cwd()
|
||||||
lfs.chdir('ut_directory')
|
luv.chdir('ut_directory')
|
||||||
local full = old .. '/subdir/file.txt'
|
local full = old .. '/subdir/file.txt'
|
||||||
eq(full, (ffi.string(cimp.path_try_shorten_fname(to_cstr(full)))))
|
eq(full, (ffi.string(cimp.path_try_shorten_fname(to_cstr(full)))))
|
||||||
end)
|
end)
|
||||||
@ -300,7 +301,7 @@ describe('path_try_shorten_fname', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
describe('path.c path_guess_exepath', function()
|
describe('path.c path_guess_exepath', function()
|
||||||
local cwd = lfs.currentdir()
|
local cwd = luv.cwd()
|
||||||
|
|
||||||
for _,name in ipairs({'./nvim', '.nvim', 'foo/nvim'}) do
|
for _,name in ipairs({'./nvim', '.nvim', 'foo/nvim'}) do
|
||||||
itp('"'..name..'" returns name catenated with CWD', function()
|
itp('"'..name..'" returns name catenated with CWD', function()
|
||||||
@ -354,7 +355,7 @@ end)
|
|||||||
|
|
||||||
describe('path.c', function()
|
describe('path.c', function()
|
||||||
setup(function()
|
setup(function()
|
||||||
lfs.mkdir('unit-test-directory');
|
mkdir('unit-test-directory');
|
||||||
io.open('unit-test-directory/test.file', 'w'):close()
|
io.open('unit-test-directory/test.file', 'w'):close()
|
||||||
|
|
||||||
-- Since the tests are executed, they are called by an executable. We use
|
-- Since the tests are executed, they are called by an executable. We use
|
||||||
@ -368,7 +369,7 @@ describe('path.c', function()
|
|||||||
|
|
||||||
teardown(function()
|
teardown(function()
|
||||||
os.remove('unit-test-directory/test.file')
|
os.remove('unit-test-directory/test.file')
|
||||||
lfs.rmdir('unit-test-directory')
|
luv.fs_rmdir('unit-test-directory')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('vim_FullName', function()
|
describe('vim_FullName', function()
|
||||||
@ -420,7 +421,7 @@ describe('path.c', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
itp('concatenates filename if it does not contain a slash', function()
|
itp('concatenates filename if it does not contain a slash', function()
|
||||||
local expected = lfs.currentdir() .. '/test.file'
|
local expected = luv.cwd() .. '/test.file'
|
||||||
local filename = 'test.file'
|
local filename = 'test.file'
|
||||||
local buflen = get_buf_len(expected, filename)
|
local buflen = get_buf_len(expected, filename)
|
||||||
local do_expand = 1
|
local do_expand = 1
|
||||||
@ -430,7 +431,7 @@ describe('path.c', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
itp('concatenates directory name if it does not contain a slash', function()
|
itp('concatenates directory name if it does not contain a slash', function()
|
||||||
local expected = lfs.currentdir() .. '/..'
|
local expected = luv.cwd() .. '/..'
|
||||||
local filename = '..'
|
local filename = '..'
|
||||||
local buflen = get_buf_len(expected, filename)
|
local buflen = get_buf_len(expected, filename)
|
||||||
local do_expand = 1
|
local do_expand = 1
|
||||||
@ -440,10 +441,10 @@ describe('path.c', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
itp('enters given directory (instead of just concatenating the strings) if possible and if path contains a slash', function()
|
itp('enters given directory (instead of just concatenating the strings) if possible and if path contains a slash', function()
|
||||||
local old_dir = lfs.currentdir()
|
local old_dir = luv.cwd()
|
||||||
lfs.chdir('..')
|
luv.chdir('..')
|
||||||
local expected = lfs.currentdir() .. '/test.file'
|
local expected = luv.cwd() .. '/test.file'
|
||||||
lfs.chdir(old_dir)
|
luv.chdir(old_dir)
|
||||||
local filename = '../test.file'
|
local filename = '../test.file'
|
||||||
local buflen = get_buf_len(expected, filename)
|
local buflen = get_buf_len(expected, filename)
|
||||||
local do_expand = 1
|
local do_expand = 1
|
||||||
@ -472,7 +473,7 @@ describe('path.c', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
itp('works with some "normal" relative path with directories', function()
|
itp('works with some "normal" relative path with directories', function()
|
||||||
local expected = lfs.currentdir() .. '/unit-test-directory/test.file'
|
local expected = luv.cwd() .. '/unit-test-directory/test.file'
|
||||||
local filename = 'unit-test-directory/test.file'
|
local filename = 'unit-test-directory/test.file'
|
||||||
local buflen = get_buf_len(expected, filename)
|
local buflen = get_buf_len(expected, filename)
|
||||||
local do_expand = 1
|
local do_expand = 1
|
||||||
@ -482,7 +483,7 @@ describe('path.c', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
itp('does not modify the given filename', function()
|
itp('does not modify the given filename', function()
|
||||||
local expected = lfs.currentdir() .. '/unit-test-directory/test.file'
|
local expected = luv.cwd() .. '/unit-test-directory/test.file'
|
||||||
local filename = to_cstr('unit-test-directory/test.file')
|
local filename = to_cstr('unit-test-directory/test.file')
|
||||||
local buflen = string.len(expected) + 1
|
local buflen = string.len(expected) + 1
|
||||||
local buf = cstr(buflen, '')
|
local buf = cstr(buflen, '')
|
||||||
@ -505,7 +506,7 @@ describe('path.c', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
itp('does not remove trailing slash from non-existing relative directory #20847', function()
|
itp('does not remove trailing slash from non-existing relative directory #20847', function()
|
||||||
local expected = lfs.currentdir() .. '/non_existing_dir/'
|
local expected = luv.cwd() .. '/non_existing_dir/'
|
||||||
local filename = 'non_existing_dir/'
|
local filename = 'non_existing_dir/'
|
||||||
local buflen = get_buf_len(expected, filename)
|
local buflen = get_buf_len(expected, filename)
|
||||||
local do_expand = 1
|
local do_expand = 1
|
||||||
@ -515,7 +516,7 @@ describe('path.c', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
itp('expands "./" to the current directory #7117', function()
|
itp('expands "./" to the current directory #7117', function()
|
||||||
local expected = lfs.currentdir() .. '/unit-test-directory/test.file'
|
local expected = luv.cwd() .. '/unit-test-directory/test.file'
|
||||||
local filename = './unit-test-directory/test.file'
|
local filename = './unit-test-directory/test.file'
|
||||||
local buflen = get_buf_len(expected, filename)
|
local buflen = get_buf_len(expected, filename)
|
||||||
local do_expand = 1
|
local do_expand = 1
|
||||||
@ -525,7 +526,7 @@ describe('path.c', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
itp('collapses "foo/../foo" to "foo" #7117', function()
|
itp('collapses "foo/../foo" to "foo" #7117', function()
|
||||||
local expected = lfs.currentdir() .. '/unit-test-directory/test.file'
|
local expected = luv.cwd() .. '/unit-test-directory/test.file'
|
||||||
local filename = 'unit-test-directory/../unit-test-directory/test.file'
|
local filename = 'unit-test-directory/../unit-test-directory/test.file'
|
||||||
local buflen = get_buf_len(expected, filename)
|
local buflen = get_buf_len(expected, filename)
|
||||||
local do_expand = 1
|
local do_expand = 1
|
||||||
@ -542,8 +543,8 @@ describe('path.c', function()
|
|||||||
return ffi.string(c_file)
|
return ffi.string(c_file)
|
||||||
end
|
end
|
||||||
|
|
||||||
before_each(function() lfs.mkdir('CamelCase') end)
|
before_each(function() mkdir('CamelCase') end)
|
||||||
after_each(function() lfs.rmdir('CamelCase') end)
|
after_each(function() luv.fs_rmdir('CamelCase') end)
|
||||||
|
|
||||||
if ffi.os == 'Windows' or ffi.os == 'OSX' then
|
if ffi.os == 'Windows' or ffi.os == 'OSX' then
|
||||||
itp('Corrects the case of file names in Mac and Windows', function()
|
itp('Corrects the case of file names in Mac and Windows', function()
|
||||||
|
@ -3,5 +3,4 @@
|
|||||||
-- for more information about this.
|
-- for more information about this.
|
||||||
local ffi = require('ffi')
|
local ffi = require('ffi')
|
||||||
local helpers = require('test.unit.helpers')(nil)
|
local helpers = require('test.unit.helpers')(nil)
|
||||||
local lfs = require('lfs')
|
|
||||||
local preprocess = require('test.unit.preprocess')
|
local preprocess = require('test.unit.preprocess')
|
||||||
|
@ -199,12 +199,6 @@ function Gcc:preprocess(previous_defines, ...)
|
|||||||
{pseudoheader_fname})
|
{pseudoheader_fname})
|
||||||
defines = self:filter_standard_defines(defines)
|
defines = self:filter_standard_defines(defines)
|
||||||
|
|
||||||
-- lfs = require("lfs")
|
|
||||||
-- print("CWD: #{lfs.currentdir!}")
|
|
||||||
-- print("CMD: #{cmd}")
|
|
||||||
-- io.stderr\write("CWD: #{lfs.currentdir!}\n")
|
|
||||||
-- io.stderr\write("CMD: #{cmd}\n")
|
|
||||||
|
|
||||||
local declarations = repeated_read_cmd(self.path,
|
local declarations = repeated_read_cmd(self.path,
|
||||||
self.preprocessor_extra_flags,
|
self.preprocessor_extra_flags,
|
||||||
self.get_declarations_extra_flags,
|
self.get_declarations_extra_flags,
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
local lfs = require('lfs')
|
|
||||||
local helpers = require('test.unit.helpers')(after_each)
|
local helpers = require('test.unit.helpers')(after_each)
|
||||||
local itp = helpers.gen_itp(it)
|
local itp = helpers.gen_itp(it)
|
||||||
|
|
||||||
@ -30,7 +29,7 @@ describe('tempfile related functions', function()
|
|||||||
-- os_file_is_writable returns 2 for a directory which we have rights
|
-- os_file_is_writable returns 2 for a directory which we have rights
|
||||||
-- to write into.
|
-- to write into.
|
||||||
eq(lib.os_file_is_writable(helpers.to_cstr(dir)), 2)
|
eq(lib.os_file_is_writable(helpers.to_cstr(dir)), 2)
|
||||||
for entry in lfs.dir(dir) do
|
for entry in vim.fs.dir(dir) do
|
||||||
assert.True(entry == '.' or entry == '..')
|
assert.True(entry == '.' or entry == '..')
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
local helpers = require('test.unit.helpers')(after_each)
|
local helpers = require('test.unit.helpers')(after_each)
|
||||||
local itp = helpers.gen_itp(it)
|
local itp = helpers.gen_itp(it)
|
||||||
local lfs = require('lfs')
|
local luv = require('luv')
|
||||||
local child_call_once = helpers.child_call_once
|
local child_call_once = helpers.child_call_once
|
||||||
local sleep = helpers.sleep
|
local sleep = helpers.sleep
|
||||||
|
|
||||||
@ -9,6 +9,7 @@ local cimport = helpers.cimport
|
|||||||
local to_cstr = helpers.to_cstr
|
local to_cstr = helpers.to_cstr
|
||||||
local neq = helpers.neq
|
local neq = helpers.neq
|
||||||
local eq = helpers.eq
|
local eq = helpers.eq
|
||||||
|
local mkdir = helpers.mkdir
|
||||||
|
|
||||||
cimport('./src/nvim/ex_cmds_defs.h')
|
cimport('./src/nvim/ex_cmds_defs.h')
|
||||||
cimport('./src/nvim/buffer_defs.h')
|
cimport('./src/nvim/buffer_defs.h')
|
||||||
@ -44,14 +45,14 @@ end)
|
|||||||
|
|
||||||
describe('u_write_undo', function()
|
describe('u_write_undo', function()
|
||||||
setup(function()
|
setup(function()
|
||||||
lfs.mkdir('unit-test-directory')
|
mkdir('unit-test-directory')
|
||||||
lfs.chdir('unit-test-directory')
|
luv.chdir('unit-test-directory')
|
||||||
options.p_udir = to_cstr(lfs.currentdir()) -- set p_udir to be the test dir
|
options.p_udir = to_cstr(luv.cwd()) -- set p_udir to be the test dir
|
||||||
end)
|
end)
|
||||||
|
|
||||||
teardown(function()
|
teardown(function()
|
||||||
lfs.chdir('..')
|
luv.chdir('..')
|
||||||
local success, err = lfs.rmdir('unit-test-directory')
|
local success, err = luv.fs_rmdir('unit-test-directory')
|
||||||
if not success then
|
if not success then
|
||||||
print(err) -- inform tester if directory fails to delete
|
print(err) -- inform tester if directory fails to delete
|
||||||
end
|
end
|
||||||
@ -102,7 +103,7 @@ describe('u_write_undo', function()
|
|||||||
local test_permission_file = io.open(test_file_name, "w")
|
local test_permission_file = io.open(test_file_name, "w")
|
||||||
test_permission_file:write("testing permissions")
|
test_permission_file:write("testing permissions")
|
||||||
test_permission_file:close()
|
test_permission_file:close()
|
||||||
local test_permissions = lfs.attributes(test_file_name).permissions
|
local test_permissions = luv.fs_stat(test_file_name).mode
|
||||||
|
|
||||||
-- Create vim buffer
|
-- Create vim buffer
|
||||||
local c_file = to_cstr(test_file_name)
|
local c_file = to_cstr(test_file_name)
|
||||||
@ -115,7 +116,7 @@ describe('u_write_undo', function()
|
|||||||
local undo_file_name = ffi.string(undo.u_get_undo_file_name(file_buffer.b_ffname, false))
|
local undo_file_name = ffi.string(undo.u_get_undo_file_name(file_buffer.b_ffname, false))
|
||||||
|
|
||||||
-- Find out the permissions of the new file
|
-- Find out the permissions of the new file
|
||||||
local permissions = lfs.attributes(undo_file_name).permissions
|
local permissions = luv.fs_stat(undo_file_name).mode
|
||||||
eq(test_permissions, permissions)
|
eq(test_permissions, permissions)
|
||||||
|
|
||||||
-- delete the file now that we're done with it.
|
-- delete the file now that we're done with it.
|
||||||
@ -130,7 +131,7 @@ describe('u_write_undo', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
itp('writes an undofile only readable by the user if the buffer is unnamed', function()
|
itp('writes an undofile only readable by the user if the buffer is unnamed', function()
|
||||||
local correct_permissions = "rw-------"
|
local correct_permissions = 33152
|
||||||
local undo_file_name = "test.undo"
|
local undo_file_name = "test.undo"
|
||||||
|
|
||||||
-- Create vim buffer
|
-- Create vim buffer
|
||||||
@ -140,7 +141,7 @@ describe('u_write_undo', function()
|
|||||||
u_write_undo(undo_file_name, false, file_buffer, buffer_hash)
|
u_write_undo(undo_file_name, false, file_buffer, buffer_hash)
|
||||||
|
|
||||||
-- Find out the permissions of the new file
|
-- Find out the permissions of the new file
|
||||||
local permissions = lfs.attributes(undo_file_name).permissions
|
local permissions = luv.fs_stat(undo_file_name).mode
|
||||||
eq(correct_permissions, permissions)
|
eq(correct_permissions, permissions)
|
||||||
|
|
||||||
-- delete the file now that we're done with it.
|
-- delete the file now that we're done with it.
|
||||||
@ -172,13 +173,13 @@ describe('u_write_undo', function()
|
|||||||
u_write_undo(nil, false, file_buffer, buffer_hash)
|
u_write_undo(nil, false, file_buffer, buffer_hash)
|
||||||
local correct_name = ffi.string(undo.u_get_undo_file_name(file_buffer.b_ffname, false))
|
local correct_name = ffi.string(undo.u_get_undo_file_name(file_buffer.b_ffname, false))
|
||||||
|
|
||||||
local file_last_modified = lfs.attributes(correct_name).modification
|
local file_last_modified = luv.fs_stat(correct_name).mtime.sec
|
||||||
|
|
||||||
sleep(1000) -- Ensure difference in timestamps.
|
sleep(1000) -- Ensure difference in timestamps.
|
||||||
file_buffer.b_u_numhead = 1 -- Mark it as if there are changes
|
file_buffer.b_u_numhead = 1 -- Mark it as if there are changes
|
||||||
u_write_undo(nil, false, file_buffer, buffer_hash)
|
u_write_undo(nil, false, file_buffer, buffer_hash)
|
||||||
|
|
||||||
local file_last_modified_2 = lfs.attributes(correct_name).modification
|
local file_last_modified_2 = luv.fs_stat(correct_name).mtime.sec
|
||||||
|
|
||||||
-- print(file_last_modified, file_last_modified_2)
|
-- print(file_last_modified, file_last_modified_2)
|
||||||
neq(file_last_modified, file_last_modified_2)
|
neq(file_last_modified, file_last_modified_2)
|
||||||
|
Loading…
Reference in New Issue
Block a user