aboutsummaryrefslogtreecommitdiff
path: root/test/functional/helpers.lua
diff options
context:
space:
mode:
authorckelsel <ckelsel@hotmail.com>2017-07-10 08:10:15 +0800
committerckelsel <ckelsel@hotmail.com>2017-07-10 08:10:15 +0800
commit465bbee520d1b1b57477fd7d80fbdeaf5e1e1e77 (patch)
treeedae38568202ba41dee4a49f78884da313fd114b /test/functional/helpers.lua
parent1514cdc7d8863eeee6b04883b1c50aac40048b49 (diff)
parent6725667d31591e8025589c4c1df34469f3bfdb52 (diff)
downloadrneovim-465bbee520d1b1b57477fd7d80fbdeaf5e1e1e77.tar.gz
rneovim-465bbee520d1b1b57477fd7d80fbdeaf5e1e1e77.tar.bz2
rneovim-465bbee520d1b1b57477fd7d80fbdeaf5e1e1e77.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'test/functional/helpers.lua')
-rw-r--r--test/functional/helpers.lua26
1 files changed, 24 insertions, 2 deletions
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index 4a170d993b..f4b2a8dfdc 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -319,7 +319,14 @@ end
-- Dedent the given text and write it to the file name.
local function write_file(name, text, dont_dedent)
local file = io.open(name, 'w')
- if not dont_dedent then
+ if type(text) == 'table' then
+ -- Byte blob
+ local bytes = text
+ text = ''
+ for _, char in ipairs(bytes) do
+ text = ('%s%c'):format(text, char)
+ end
+ elseif not dont_dedent then
text = dedent(text)
end
file:write(text)
@@ -337,11 +344,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 +692,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)