mirror of
https://github.com/neovim/neovim.git
synced 2025-12-15 19:05:40 +00:00
functionaltest: Create lua helper for os.tmpname()
In Windows Lua's os.tmpname() returns relative paths starting with \s, prepend them with $TEMP to generate a valid path. In OS X os.tmpname() returns paths in '/tmp' but they should be in '/private/tmp'. We cannot use os_name() for platform detection because some tests use tempname() before nvim is spawned, instead use one of the following: 1. Set SYSTEM_NAME environment variable before calling the tests, it is set from CMAKE_SYSTEM_NAME(i.e. uname -s or 'Windows') 2. Call uname -s 3. Assume windows
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
|
||||
local source, write_file = helpers.source, helpers.write_file
|
||||
local os_name = helpers.os_name
|
||||
|
||||
local function sixlines(text)
|
||||
local result = ''
|
||||
@@ -14,19 +13,16 @@ local function sixlines(text)
|
||||
end
|
||||
|
||||
local function diff(text, nodedent)
|
||||
local tmpname = os.tmpname()
|
||||
if os_name() == 'osx' and string.match(tmpname, '^/tmp') then
|
||||
tmpname = '/private'..tmpname
|
||||
end
|
||||
execute('w! '..tmpname)
|
||||
local fname = helpers.tmpname()
|
||||
execute('w! '..fname)
|
||||
helpers.wait()
|
||||
local data = io.open(tmpname):read('*all')
|
||||
local data = io.open(fname):read('*all')
|
||||
if nodedent then
|
||||
helpers.eq(text, data)
|
||||
else
|
||||
helpers.eq(helpers.dedent(text), data)
|
||||
end
|
||||
os.remove(tmpname)
|
||||
os.remove(fname)
|
||||
end
|
||||
|
||||
describe('character classes in regexp', function()
|
||||
|
||||
Reference in New Issue
Block a user