mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
functests: Ensure different SIDs on successive source() calls
This commit is contained in:
parent
480598dcda
commit
2208b64891
@ -137,7 +137,7 @@ describe(':echo', function()
|
||||
end)
|
||||
|
||||
it('dumps references to script functions', function()
|
||||
eq('<SNR>1_Test2', eval('String(Test2_f)'))
|
||||
eq('<SNR>2_Test2', eval('String(Test2_f)'))
|
||||
end)
|
||||
|
||||
it('dumps partials with self referencing a partial', function()
|
||||
@ -156,9 +156,9 @@ describe(':echo', function()
|
||||
end)
|
||||
|
||||
it('dumps automatically created partials', function()
|
||||
eq('function(\'<SNR>1_Test2\', {\'f\': function(\'<SNR>1_Test2\')})',
|
||||
eq('function(\'<SNR>2_Test2\', {\'f\': function(\'<SNR>2_Test2\')})',
|
||||
eval('String({"f": Test2_f}.f)'))
|
||||
eq('function(\'<SNR>1_Test2\', [1], {\'f\': function(\'<SNR>1_Test2\', [1])})',
|
||||
eq('function(\'<SNR>2_Test2\', [1], {\'f\': function(\'<SNR>2_Test2\', [1])})',
|
||||
eval('String({"f": function(Test2_f, [1])}.f)'))
|
||||
end)
|
||||
|
||||
@ -176,8 +176,8 @@ describe(':echo', function()
|
||||
meths.set_var('d', {v=true})
|
||||
eq(dedent([[
|
||||
|
||||
{'p': function('<SNR>1_Test2', {...@0}), 'f': function('<SNR>1_Test2'), 'v': v:true}
|
||||
{'p': function('<SNR>1_Test2', {...@0}), 'f': function('<SNR>1_Test2'), 'v': v:true}]]),
|
||||
{'p': function('<SNR>2_Test2', {...@0}), 'f': function('<SNR>2_Test2'), 'v': v:true}
|
||||
{'p': function('<SNR>2_Test2', {...@0}), 'f': function('<SNR>2_Test2'), 'v': v:true}]]),
|
||||
redir_exec('echo String(extend(extend(g:d, {"f": g:Test2_f}), {"p": g:d.f}))'))
|
||||
end)
|
||||
|
||||
@ -217,8 +217,8 @@ describe(':echo', function()
|
||||
eval('add(l, function("Test1", d))')
|
||||
eq(dedent([=[
|
||||
|
||||
{'p': function('<SNR>1_Test2', [[[...@3], function('Test1', [[...@3]]), function('Test1', {...@0})], function('Test1', [[[...@5], function('Test1', [[...@5]]), function('Test1', {...@0})]]), function('Test1', {...@0})], {...@0}), 'f': function('<SNR>1_Test2'), 'v': v:true}
|
||||
{'p': function('<SNR>1_Test2', [[[...@3], function('Test1', [[...@3]]), function('Test1', {...@0})], function('Test1', [[[...@5], function('Test1', [[...@5]]), function('Test1', {...@0})]]), function('Test1', {...@0})], {...@0}), 'f': function('<SNR>1_Test2'), 'v': v:true}]=]),
|
||||
{'p': function('<SNR>2_Test2', [[[...@3], function('Test1', [[...@3]]), function('Test1', {...@0})], function('Test1', [[[...@5], function('Test1', [[...@5]]), function('Test1', {...@0})]]), function('Test1', {...@0})], {...@0}), 'f': function('<SNR>2_Test2'), 'v': v:true}
|
||||
{'p': function('<SNR>2_Test2', [[[...@3], function('Test1', [[...@3]]), function('Test1', {...@0})], function('Test1', [[[...@5], function('Test1', [[...@5]]), function('Test1', {...@0})]]), function('Test1', {...@0})], {...@0}), 'f': function('<SNR>2_Test2'), 'v': v:true}]=]),
|
||||
redir_exec('echo String(extend(extend(g:d, {"f": g:Test2_f}), {"p": function(g:d.f, l)}))'))
|
||||
end)
|
||||
end)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user