mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 03:48:18 +00:00
test: add more profile tests
- Add a test to make sure that 'profile dump' does not reset the profile. - Add a test to make sure that 'profile stop' does reset the profile.
This commit is contained in:
@@ -6,6 +6,9 @@ local eval = helpers.eval
|
|||||||
local command = helpers.command
|
local command = helpers.command
|
||||||
local eq, neq = helpers.eq, helpers.neq
|
local eq, neq = helpers.eq, helpers.neq
|
||||||
local tempfile = helpers.tmpname()
|
local tempfile = helpers.tmpname()
|
||||||
|
local source = helpers.source
|
||||||
|
local matches = helpers.matches
|
||||||
|
local read_file = helpers.read_file
|
||||||
|
|
||||||
-- tmpname() also creates the file on POSIX systems. Remove it again.
|
-- tmpname() also creates the file on POSIX systems. Remove it again.
|
||||||
-- We just need the name, ignoring any race conditions.
|
-- We just need the name, ignoring any race conditions.
|
||||||
@@ -32,20 +35,67 @@ describe(':profile', function()
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('dump', function()
|
describe('dump', function()
|
||||||
eq(0, eval('v:profiling'))
|
it('works', function()
|
||||||
command('profile start ' .. tempfile)
|
eq(0, eval('v:profiling'))
|
||||||
eq(1, eval('v:profiling'))
|
command('profile start ' .. tempfile)
|
||||||
assert_file_exists_not(tempfile)
|
eq(1, eval('v:profiling'))
|
||||||
command('profile dump')
|
assert_file_exists_not(tempfile)
|
||||||
assert_file_exists(tempfile)
|
command('profile dump')
|
||||||
|
assert_file_exists(tempfile)
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('not resetting the profile', function()
|
||||||
|
source([[
|
||||||
|
function! Test()
|
||||||
|
endfunction
|
||||||
|
]])
|
||||||
|
command('profile start ' .. tempfile)
|
||||||
|
assert_file_exists_not(tempfile)
|
||||||
|
command('profile func Test')
|
||||||
|
command('call Test()')
|
||||||
|
command('profile dump')
|
||||||
|
assert_file_exists(tempfile)
|
||||||
|
local profile = read_file(tempfile)
|
||||||
|
matches('Called 1 time', profile)
|
||||||
|
command('call Test()')
|
||||||
|
command('profile dump')
|
||||||
|
assert_file_exists(tempfile)
|
||||||
|
profile = read_file(tempfile)
|
||||||
|
matches('Called 2 time', profile)
|
||||||
|
command('profile stop')
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('stop', function()
|
describe('stop', function()
|
||||||
command('profile start ' .. tempfile)
|
it('works', function()
|
||||||
assert_file_exists_not(tempfile)
|
command('profile start ' .. tempfile)
|
||||||
command('profile stop')
|
assert_file_exists_not(tempfile)
|
||||||
assert_file_exists(tempfile)
|
command('profile stop')
|
||||||
eq(0, eval('v:profiling'))
|
assert_file_exists(tempfile)
|
||||||
|
eq(0, eval('v:profiling'))
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('resetting the profile', function()
|
||||||
|
source([[
|
||||||
|
function! Test()
|
||||||
|
endfunction
|
||||||
|
]])
|
||||||
|
command('profile start ' .. tempfile)
|
||||||
|
assert_file_exists_not(tempfile)
|
||||||
|
command('profile func Test')
|
||||||
|
command('call Test()')
|
||||||
|
command('profile stop')
|
||||||
|
assert_file_exists(tempfile)
|
||||||
|
local profile = read_file(tempfile)
|
||||||
|
matches('Called 1 time', profile)
|
||||||
|
command('profile start ' .. tempfile)
|
||||||
|
command('profile func Test')
|
||||||
|
command('call Test()')
|
||||||
|
command('profile stop')
|
||||||
|
assert_file_exists(tempfile)
|
||||||
|
profile = read_file(tempfile)
|
||||||
|
matches('Called 1 time', profile)
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user