functests: Ensure different SIDs on successive source() calls

This commit is contained in:
ZyX
2017-07-04 15:15:23 +03:00
parent 480598dcda
commit 2208b64891
2 changed files with 23 additions and 8 deletions

View File

@@ -337,11 +337,23 @@ local function read_file(name)
return ret
end
local sourced_fnames = {}
local function source(code)
local fname = tmpname()
write_file(fname, code)
nvim_command('source '..fname)
os.remove(fname)
-- DO NOT REMOVE FILE HERE.
-- do_source() has a habit of checking whether files are “same” by using inode
-- and device IDs. If you run two source() calls in quick succession there is
-- a good chance that underlying filesystem will reuse the inode, making files
-- appear as “symlinks” to do_source when it checks FileIDs. With current
-- setup linux machines (both QB, travis and mine(ZyX-I) with XFS) do reuse
-- inodes, Mac OS machines (again, both QB and travis) do not.
--
-- Files appearing as “symlinks” mean that both the first and the second
-- source() calls will use same SID, which may fail some tests which check for
-- exact numbers after `<SNR>` in e.g. function names.
sourced_fnames[#sourced_fnames + 1] = fname
return fname
end
@@ -673,6 +685,9 @@ local module = {
return function(after_each)
if after_each then
after_each(function()
for _, fname in ipairs(sourced_fnames) do
os.remove(fname)
end
check_logs()
check_cores('build/bin/nvim')
end)