mirror of
https://github.com/neovim/neovim.git
synced 2025-11-07 11:14:26 +00:00
functests: Ensure different SIDs on successive source() calls
This commit is contained in:
@@ -137,7 +137,7 @@ describe(':echo', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('dumps references to script functions', function()
|
it('dumps references to script functions', function()
|
||||||
eq('<SNR>1_Test2', eval('String(Test2_f)'))
|
eq('<SNR>2_Test2', eval('String(Test2_f)'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('dumps partials with self referencing a partial', function()
|
it('dumps partials with self referencing a partial', function()
|
||||||
@@ -156,9 +156,9 @@ describe(':echo', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('dumps automatically created partials', function()
|
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)'))
|
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)'))
|
eval('String({"f": function(Test2_f, [1])}.f)'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -176,8 +176,8 @@ describe(':echo', function()
|
|||||||
meths.set_var('d', {v=true})
|
meths.set_var('d', {v=true})
|
||||||
eq(dedent([[
|
eq(dedent([[
|
||||||
|
|
||||||
{'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>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}]]),
|
||||||
redir_exec('echo String(extend(extend(g:d, {"f": g:Test2_f}), {"p": g:d.f}))'))
|
redir_exec('echo String(extend(extend(g:d, {"f": g:Test2_f}), {"p": g:d.f}))'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -217,8 +217,8 @@ describe(':echo', function()
|
|||||||
eval('add(l, function("Test1", d))')
|
eval('add(l, function("Test1", d))')
|
||||||
eq(dedent([=[
|
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>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>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}]=]),
|
||||||
redir_exec('echo String(extend(extend(g:d, {"f": g:Test2_f}), {"p": function(g:d.f, l)}))'))
|
redir_exec('echo String(extend(extend(g:d, {"f": g:Test2_f}), {"p": function(g:d.f, l)}))'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -337,11 +337,23 @@ local function read_file(name)
|
|||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local sourced_fnames = {}
|
||||||
local function source(code)
|
local function source(code)
|
||||||
local fname = tmpname()
|
local fname = tmpname()
|
||||||
write_file(fname, code)
|
write_file(fname, code)
|
||||||
nvim_command('source '..fname)
|
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
|
return fname
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -673,6 +685,9 @@ local module = {
|
|||||||
return function(after_each)
|
return function(after_each)
|
||||||
if after_each then
|
if after_each then
|
||||||
after_each(function()
|
after_each(function()
|
||||||
|
for _, fname in ipairs(sourced_fnames) do
|
||||||
|
os.remove(fname)
|
||||||
|
end
|
||||||
check_logs()
|
check_logs()
|
||||||
check_cores('build/bin/nvim')
|
check_cores('build/bin/nvim')
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user