test: robust cleanup, unique filenames #7950 (#7950)

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:
Justin M. Keyes
2018-02-01 03:12:37 +01:00
committed by GitHub
parent 648fed975e
commit f8010ea3ec
6 changed files with 24 additions and 21 deletions

View File

@@ -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.funcs, helpers.feed, helpers.curbuf
local neq = helpers.neq
local read_file = helpers.read_file
local mpack = require('mpack')
@@ -2152,9 +2153,7 @@ describe('plugin/shada.vim', function()
end)
local shada_eq = function(expected, fname_)
local fd = io.open(fname_)
local mpack_result = fd:read('*a')
fd:close()
local mpack_result = read_file(fname_)
mpack_eq(expected, mpack_result)
end
@@ -2278,7 +2277,7 @@ describe('plugin/shada.vim', function()
' + f file name ["foo"]',
' + l line number 2',
' + c column -200',
}, eol) .. eol, io.open(fname .. '.tst'):read('*a'))
}, eol) .. eol, read_file(fname .. '.tst'))
shada_eq({{
timestamp=0,
type=8,
@@ -2326,7 +2325,7 @@ describe('plugin/shada.vim', function()
'Jump with timestamp ' .. epoch .. ':',
' % Key________ Description Value',
' + n name \'A\'',
}, eol) .. eol, io.open(fname .. '.tst'):read('*a'))
}, eol) .. eol, read_file(fname .. '.tst'))
shada_eq({{
timestamp=0,
type=8,
@@ -2383,7 +2382,7 @@ describe('plugin/shada.vim', function()
' + f file name ["foo"]',
' + l line number 2',
' + c column -200',
}, eol) .. eol, io.open(fname .. '.tst'):read('*a'))
}, eol) .. eol, read_file(fname .. '.tst'))
shada_eq({{
timestamp=0,
type=8,