mirror of
https://github.com/neovim/neovim.git
synced 2026-08-29 10:31:48 +00:00
feat(test): use nvim_exec in helpers.source() #16064
helpers.source() was a hack to work around the lack of anonymous :source. Its "create tempfile" behavior is not a required part of most tests that use it. Some tests still need the old "create tempfile" behavior either because they test SID behavior, or because of missing nvim_exec features: #16071
This commit is contained in:
@@ -10,6 +10,7 @@ local source = helpers.source
|
||||
local poke_eventloop = helpers.poke_eventloop
|
||||
local uname = helpers.uname
|
||||
local load_adjust = helpers.load_adjust
|
||||
local write_file = helpers.write_file
|
||||
local isCI = helpers.isCI
|
||||
|
||||
local function isasan()
|
||||
@@ -84,6 +85,12 @@ setmetatable(monitor_memory_usage,
|
||||
end})
|
||||
|
||||
describe('memory usage', function()
|
||||
local tmpfile = 'X_memory_usage'
|
||||
|
||||
after_each(function()
|
||||
os.remove(tmpfile)
|
||||
end)
|
||||
|
||||
local function check_result(tbl, status, result)
|
||||
if not status then
|
||||
print('')
|
||||
@@ -103,7 +110,7 @@ describe('memory usage', function()
|
||||
it('function capture vargs', function()
|
||||
local pid = eval('getpid()')
|
||||
local before = monitor_memory_usage(pid)
|
||||
source([[
|
||||
write_file(tmpfile, [[
|
||||
func s:f(...)
|
||||
let x = a:000
|
||||
endfunc
|
||||
@@ -111,6 +118,8 @@ describe('memory usage', function()
|
||||
call s:f(0)
|
||||
endfor
|
||||
]])
|
||||
-- TODO: check_result fails if command() is used here. Why? #16064
|
||||
feed_command('source '..tmpfile)
|
||||
poke_eventloop()
|
||||
local after = monitor_memory_usage(pid)
|
||||
-- Estimate the limit of max usage as 2x initial usage.
|
||||
@@ -136,7 +145,7 @@ describe('memory usage', function()
|
||||
it('function capture lvars', function()
|
||||
local pid = eval('getpid()')
|
||||
local before = monitor_memory_usage(pid)
|
||||
local fname = source([[
|
||||
write_file(tmpfile, [[
|
||||
if !exists('s:defined_func')
|
||||
func s:f()
|
||||
let x = l:
|
||||
@@ -147,10 +156,12 @@ describe('memory usage', function()
|
||||
call s:f()
|
||||
endfor
|
||||
]])
|
||||
feed_command('source '..tmpfile)
|
||||
poke_eventloop()
|
||||
local after = monitor_memory_usage(pid)
|
||||
for _ = 1, 3 do
|
||||
feed_command('so '..fname)
|
||||
-- TODO: check_result fails if command() is used here. Why? #16064
|
||||
feed_command('source '..tmpfile)
|
||||
poke_eventloop()
|
||||
end
|
||||
local last = monitor_memory_usage(pid)
|
||||
|
||||
Reference in New Issue
Block a user