aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/functional/ex_cmds/echo_spec.lua14
-rw-r--r--test/functional/helpers.lua17
2 files changed, 23 insertions, 8 deletions
diff --git a/test/functional/ex_cmds/echo_spec.lua b/test/functional/ex_cmds/echo_spec.lua
index 4936c5af8c..10c7230896 100644
--- a/test/functional/ex_cmds/echo_spec.lua
+++ b/test/functional/ex_cmds/echo_spec.lua
@@ -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)
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index 4a170d993b..d7858cacd5 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -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)