mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 11:15:14 -07:00
Add test/functional/ex_cmds/profile_spec.lua
This adds two new tests for: :profile dump :profile stop
This commit is contained in:
parent
e4d9176e4d
commit
69085113b3
51
test/functional/ex_cmds/profile_spec.lua
Normal file
51
test/functional/ex_cmds/profile_spec.lua
Normal file
@ -0,0 +1,51 @@
|
||||
require('os')
|
||||
require('lfs')
|
||||
|
||||
local helpers = require('test.functional.helpers')
|
||||
local eval = helpers.eval
|
||||
local command = helpers.command
|
||||
local eq, neq = helpers.eq, helpers.neq
|
||||
local tempfile = os.tmpname()
|
||||
|
||||
-- os.tmpname() also creates the file on POSIX systems. Remove it again.
|
||||
-- We just need the name, ignoring any race conditions.
|
||||
if lfs.attributes(tempfile, 'uid') then
|
||||
os.remove(tempfile)
|
||||
end
|
||||
|
||||
local function assert_file_exists(filepath)
|
||||
-- Use 2-argument lfs.attributes() so no extra table gets created.
|
||||
-- We don't really care for the uid.
|
||||
neq(nil, lfs.attributes(filepath, 'uid'))
|
||||
end
|
||||
|
||||
local function assert_file_exists_not(filepath)
|
||||
eq(nil, lfs.attributes(filepath, 'uid'))
|
||||
end
|
||||
|
||||
describe(':profile', function()
|
||||
before_each(helpers.clear)
|
||||
|
||||
after_each(function()
|
||||
if lfs.attributes(tempfile, 'uid') ~= nil then
|
||||
os.remove(tempfile)
|
||||
end
|
||||
end)
|
||||
|
||||
it('dump', function()
|
||||
eq(0, eval('v:profiling'))
|
||||
command('profile start ' .. tempfile)
|
||||
eq(1, eval('v:profiling'))
|
||||
assert_file_exists_not(tempfile)
|
||||
command('profile dump')
|
||||
assert_file_exists(tempfile)
|
||||
end)
|
||||
|
||||
it('stop', function()
|
||||
command('profile start ' .. tempfile)
|
||||
assert_file_exists_not(tempfile)
|
||||
command('profile stop')
|
||||
assert_file_exists(tempfile)
|
||||
eq(0, eval('v:profiling'))
|
||||
end)
|
||||
end)
|
Loading…
Reference in New Issue
Block a user