aboutsummaryrefslogtreecommitdiff
path: root/test/functional/legacy/memory_usage_spec.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2022-03-27 10:25:55 -0700
committerGitHub <noreply@github.com>2022-03-27 10:25:55 -0700
commit72652cbc46f568128bfc296ba63fb2d26941da8e (patch)
tree45883e033228aacc55df313edb7acac1e1d76698 /test/functional/legacy/memory_usage_spec.lua
parent05edab85d7edad63c3b449689b57f9f658782c11 (diff)
downloadrneovim-72652cbc46f568128bfc296ba63fb2d26941da8e.tar.gz
rneovim-72652cbc46f568128bfc296ba63fb2d26941da8e.tar.bz2
rneovim-72652cbc46f568128bfc296ba63fb2d26941da8e.zip
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
Diffstat (limited to 'test/functional/legacy/memory_usage_spec.lua')
-rw-r--r--test/functional/legacy/memory_usage_spec.lua17
1 files changed, 14 insertions, 3 deletions
diff --git a/test/functional/legacy/memory_usage_spec.lua b/test/functional/legacy/memory_usage_spec.lua
index 8d25b9d927..eec89aa919 100644
--- a/test/functional/legacy/memory_usage_spec.lua
+++ b/test/functional/legacy/memory_usage_spec.lua
@@ -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)