mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 05:05:00 -07:00
tests: Make helper.source() return tempname.
This commit is contained in:
parent
feed81f45f
commit
59b04d856b
@ -1,4 +1,5 @@
|
||||
require('coxpcall')
|
||||
local ffi = require('ffi')
|
||||
local lfs = require('lfs')
|
||||
local assert = require('luassert')
|
||||
local Loop = require('nvim.loop')
|
||||
@ -246,9 +247,13 @@ end
|
||||
|
||||
local function source(code)
|
||||
local tmpname = os.tmpname()
|
||||
if ffi.os == 'OSX' and string.match(tmpname, '^/tmp') then
|
||||
tmpname = '/private'..tmpname
|
||||
end
|
||||
write_file(tmpname, code)
|
||||
nvim_command('source '..tmpname)
|
||||
os.remove(tmpname)
|
||||
return tmpname
|
||||
end
|
||||
|
||||
local function eq(expected, actual)
|
||||
|
@ -1,8 +1,7 @@
|
||||
local ffi = require('ffi')
|
||||
local helpers = require('test.functional.helpers')
|
||||
local nvim, call = helpers.meths, helpers.call
|
||||
local clear, eq = helpers.clear, helpers.eq
|
||||
local write_file, execute = helpers.write_file, helpers.execute
|
||||
local source, execute = helpers.source, helpers.execute
|
||||
|
||||
local function expected_errors(errors)
|
||||
eq(errors, nvim.get_vvar('errors'))
|
||||
@ -12,19 +11,6 @@ local function expected_empty()
|
||||
eq({}, nvim.get_vvar('errors'))
|
||||
end
|
||||
|
||||
local function source(code)
|
||||
local tmpname = os.tmpname()
|
||||
|
||||
if ffi.os == 'OSX' and string.match(tmpname, '^/tmp') then
|
||||
tmpname = '/private'..tmpname
|
||||
end
|
||||
|
||||
write_file(tmpname, code)
|
||||
nvim.command('source '..tmpname)
|
||||
os.remove(tmpname)
|
||||
return tmpname
|
||||
end
|
||||
|
||||
describe('assert function:', function()
|
||||
|
||||
before_each(function()
|
||||
|
Loading…
Reference in New Issue
Block a user