tests: Make helper.source() return tempname.

This commit is contained in:
watiko 2015-12-30 19:14:33 +09:00
parent feed81f45f
commit 59b04d856b
2 changed files with 6 additions and 15 deletions

View File

@ -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)

View File

@ -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()