mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Use unique filenames to avoid test conflicts. Use read_file() instead of io.popen(), to ensures the file is closed. Use helpers.rmdir(), it is far more robust than lfs. closes #7911
This commit is contained in:
parent
648fed975e
commit
f8010ea3ec
@ -14,6 +14,7 @@ local curbufmeths = helpers.curbufmeths
|
|||||||
local curwinmeths = helpers.curwinmeths
|
local curwinmeths = helpers.curwinmeths
|
||||||
local curtabmeths = helpers.curtabmeths
|
local curtabmeths = helpers.curtabmeths
|
||||||
local get_pathsep = helpers.get_pathsep
|
local get_pathsep = helpers.get_pathsep
|
||||||
|
local rmdir = helpers.rmdir
|
||||||
|
|
||||||
local fname = 'Xtest-functional-eval-buf_functions'
|
local fname = 'Xtest-functional-eval-buf_functions'
|
||||||
local fname2 = fname .. '.2'
|
local fname2 = fname .. '.2'
|
||||||
@ -61,7 +62,7 @@ describe('bufname() function', function()
|
|||||||
lfs.mkdir(dirname)
|
lfs.mkdir(dirname)
|
||||||
end)
|
end)
|
||||||
after_each(function()
|
after_each(function()
|
||||||
lfs.rmdir(dirname)
|
rmdir(dirname)
|
||||||
end)
|
end)
|
||||||
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
|
||||||
@ -143,7 +144,7 @@ describe('bufwinnr() function', function()
|
|||||||
lfs.mkdir(dirname)
|
lfs.mkdir(dirname)
|
||||||
end)
|
end)
|
||||||
after_each(function()
|
after_each(function()
|
||||||
lfs.rmdir(dirname)
|
rmdir(dirname)
|
||||||
end)
|
end)
|
||||||
it('returns expected window number', function()
|
it('returns expected window number', function()
|
||||||
eq(1, funcs.bufwinnr('%'))
|
eq(1, funcs.bufwinnr('%'))
|
||||||
|
@ -6,6 +6,7 @@ local command = helpers.command
|
|||||||
local get_pathsep = helpers.get_pathsep
|
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 file_prefix = 'Xtest-functional-ex_cmds-mksession_spec'
|
local file_prefix = 'Xtest-functional-ex_cmds-mksession_spec'
|
||||||
|
|
||||||
@ -20,7 +21,7 @@ describe(':mksession', function()
|
|||||||
|
|
||||||
after_each(function()
|
after_each(function()
|
||||||
os.remove(session_file)
|
os.remove(session_file)
|
||||||
lfs.rmdir(tab_dir)
|
rmdir(tab_dir)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('restores tab-local working directories', function()
|
it('restores tab-local working directories', function()
|
||||||
|
@ -24,7 +24,7 @@ describe(':mkview', function()
|
|||||||
after_each(function()
|
after_each(function()
|
||||||
-- Remove any views created in the view directory
|
-- Remove any views created in the view directory
|
||||||
rmdir(view_dir)
|
rmdir(view_dir)
|
||||||
lfs.rmdir(local_dir)
|
rmdir(local_dir)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('viewoption curdir restores local current directory', function()
|
it('viewoption curdir restores local current directory', function()
|
||||||
|
@ -5,9 +5,10 @@ local helpers = require('test.functional.helpers')(after_each)
|
|||||||
local feed, source = helpers.feed, helpers.source
|
local feed, source = helpers.feed, helpers.source
|
||||||
local clear, feed_command, expect, eq, eval = helpers.clear, helpers.feed_command, helpers.expect, helpers.eq, helpers.eval
|
local clear, feed_command, expect, eq, eval = helpers.clear, helpers.feed_command, helpers.expect, helpers.eq, helpers.eval
|
||||||
local write_file, wait, dedent = helpers.write_file, helpers.wait, helpers.dedent
|
local write_file, wait, dedent = helpers.write_file, helpers.wait, helpers.dedent
|
||||||
local io = require('io')
|
local read_file = helpers.read_file
|
||||||
|
|
||||||
describe('autocommands that delete and unload buffers:', function()
|
describe('autocommands that delete and unload buffers:', function()
|
||||||
|
local test_file = 'Xtest-008_autocommands.out'
|
||||||
local text1 = dedent([[
|
local text1 = dedent([[
|
||||||
start of Xxx1
|
start of Xxx1
|
||||||
test
|
test
|
||||||
@ -18,7 +19,7 @@ describe('autocommands that delete and unload buffers:', function()
|
|||||||
write_file('Xxx2', text2..'\n')
|
write_file('Xxx2', text2..'\n')
|
||||||
end)
|
end)
|
||||||
teardown(function()
|
teardown(function()
|
||||||
os.remove('test.out')
|
os.remove(test_file)
|
||||||
os.remove('Xxx1')
|
os.remove('Xxx1')
|
||||||
os.remove('Xxx2')
|
os.remove('Xxx2')
|
||||||
end)
|
end)
|
||||||
@ -65,7 +66,8 @@ describe('autocommands that delete and unload buffers:', function()
|
|||||||
endwhile
|
endwhile
|
||||||
endfunc
|
endfunc
|
||||||
func WriteToOut()
|
func WriteToOut()
|
||||||
edit! test.out
|
edit! ]]..test_file..[[
|
||||||
|
|
||||||
$put ='VimLeave done'
|
$put ='VimLeave done'
|
||||||
write
|
write
|
||||||
endfunc
|
endfunc
|
||||||
@ -86,6 +88,6 @@ describe('autocommands that delete and unload buffers:', function()
|
|||||||
feed_command('q')
|
feed_command('q')
|
||||||
wait()
|
wait()
|
||||||
eq('VimLeave done',
|
eq('VimLeave done',
|
||||||
string.match(io.open('test.out', 'r'):read('*all'), "^%s*(.-)%s*$"))
|
string.match(read_file(test_file), "^%s*(.-)%s*$"))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@ -11,10 +11,10 @@ local source = helpers.source
|
|||||||
local clear, command, expect = helpers.clear, helpers.command, helpers.expect
|
local clear, command, expect = helpers.clear, helpers.command, helpers.expect
|
||||||
|
|
||||||
describe('location list', function()
|
describe('location list', function()
|
||||||
|
local test_file = 'Xtest-096_location_list.out'
|
||||||
setup(clear)
|
setup(clear)
|
||||||
|
|
||||||
teardown(function()
|
teardown(function()
|
||||||
os.remove('test.out')
|
os.remove(test_file)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('is working', function()
|
it('is working', function()
|
||||||
@ -70,9 +70,9 @@ describe('location list', function()
|
|||||||
endfor
|
endfor
|
||||||
]])
|
]])
|
||||||
|
|
||||||
-- Set up the result buffer "test.out".
|
-- Set up the result buffer.
|
||||||
command('enew')
|
command('enew')
|
||||||
command('w! test.out')
|
command('w! '..test_file)
|
||||||
command('b 1')
|
command('b 1')
|
||||||
|
|
||||||
-- Test A.
|
-- Test A.
|
||||||
@ -99,7 +99,7 @@ describe('location list', function()
|
|||||||
command([[let locationListFileName = substitute(getline(line('.')), '\([^|]*\)|.*', '\1', '')]])
|
command([[let locationListFileName = substitute(getline(line('.')), '\([^|]*\)|.*', '\1', '')]])
|
||||||
command('wincmd n')
|
command('wincmd n')
|
||||||
command('wincmd K')
|
command('wincmd K')
|
||||||
command('b test.out')
|
command('b '..test_file)
|
||||||
|
|
||||||
-- Prepare test output and write it to the result buffer.
|
-- Prepare test output and write it to the result buffer.
|
||||||
command([[let fileName = substitute(fileName, '\\', '/', 'g')]])
|
command([[let fileName = substitute(fileName, '\\', '/', 'g')]])
|
||||||
@ -132,7 +132,7 @@ describe('location list', function()
|
|||||||
command('let numberOfWindowsOpen = winnr("$")')
|
command('let numberOfWindowsOpen = winnr("$")')
|
||||||
command('wincmd n')
|
command('wincmd n')
|
||||||
command('wincmd K')
|
command('wincmd K')
|
||||||
command('b test.out')
|
command('b '..test_file)
|
||||||
|
|
||||||
-- Prepare test output and write it to the result buffer.
|
-- Prepare test output and write it to the result buffer.
|
||||||
command('call append(line("$"), "Test B:")')
|
command('call append(line("$"), "Test B:")')
|
||||||
@ -170,7 +170,7 @@ describe('location list', function()
|
|||||||
command('let bufferName = expand("%")')
|
command('let bufferName = expand("%")')
|
||||||
command('wincmd n')
|
command('wincmd n')
|
||||||
command('wincmd K')
|
command('wincmd K')
|
||||||
command('b test.out')
|
command('b '..test_file)
|
||||||
|
|
||||||
-- Prepare test output and write it to the result buffer.
|
-- Prepare test output and write it to the result buffer.
|
||||||
command([[let bufferName = substitute(bufferName, '\\', '/', 'g')]])
|
command([[let bufferName = substitute(bufferName, '\\', '/', 'g')]])
|
||||||
|
@ -3,6 +3,7 @@ local eq, nvim_eval, nvim_command, nvim, exc_exec, funcs, nvim_feed, curbuf =
|
|||||||
helpers.eq, helpers.eval, helpers.command, helpers.nvim, helpers.exc_exec,
|
helpers.eq, helpers.eval, helpers.command, helpers.nvim, helpers.exc_exec,
|
||||||
helpers.funcs, helpers.feed, helpers.curbuf
|
helpers.funcs, helpers.feed, helpers.curbuf
|
||||||
local neq = helpers.neq
|
local neq = helpers.neq
|
||||||
|
local read_file = helpers.read_file
|
||||||
|
|
||||||
local mpack = require('mpack')
|
local mpack = require('mpack')
|
||||||
|
|
||||||
@ -2152,9 +2153,7 @@ describe('plugin/shada.vim', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
local shada_eq = function(expected, fname_)
|
local shada_eq = function(expected, fname_)
|
||||||
local fd = io.open(fname_)
|
local mpack_result = read_file(fname_)
|
||||||
local mpack_result = fd:read('*a')
|
|
||||||
fd:close()
|
|
||||||
mpack_eq(expected, mpack_result)
|
mpack_eq(expected, mpack_result)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2278,7 +2277,7 @@ describe('plugin/shada.vim', function()
|
|||||||
' + f file name ["foo"]',
|
' + f file name ["foo"]',
|
||||||
' + l line number 2',
|
' + l line number 2',
|
||||||
' + c column -200',
|
' + c column -200',
|
||||||
}, eol) .. eol, io.open(fname .. '.tst'):read('*a'))
|
}, eol) .. eol, read_file(fname .. '.tst'))
|
||||||
shada_eq({{
|
shada_eq({{
|
||||||
timestamp=0,
|
timestamp=0,
|
||||||
type=8,
|
type=8,
|
||||||
@ -2326,7 +2325,7 @@ describe('plugin/shada.vim', function()
|
|||||||
'Jump with timestamp ' .. epoch .. ':',
|
'Jump with timestamp ' .. epoch .. ':',
|
||||||
' % Key________ Description Value',
|
' % Key________ Description Value',
|
||||||
' + n name \'A\'',
|
' + n name \'A\'',
|
||||||
}, eol) .. eol, io.open(fname .. '.tst'):read('*a'))
|
}, eol) .. eol, read_file(fname .. '.tst'))
|
||||||
shada_eq({{
|
shada_eq({{
|
||||||
timestamp=0,
|
timestamp=0,
|
||||||
type=8,
|
type=8,
|
||||||
@ -2383,7 +2382,7 @@ describe('plugin/shada.vim', function()
|
|||||||
' + f file name ["foo"]',
|
' + f file name ["foo"]',
|
||||||
' + l line number 2',
|
' + l line number 2',
|
||||||
' + c column -200',
|
' + c column -200',
|
||||||
}, eol) .. eol, io.open(fname .. '.tst'):read('*a'))
|
}, eol) .. eol, read_file(fname .. '.tst'))
|
||||||
shada_eq({{
|
shada_eq({{
|
||||||
timestamp=0,
|
timestamp=0,
|
||||||
type=8,
|
type=8,
|
||||||
|
Loading…
Reference in New Issue
Block a user