diff options
author | James McCoy <jamessan@jamessan.com> | 2020-08-08 08:57:35 -0400 |
---|---|---|
committer | James McCoy <jamessan@jamessan.com> | 2020-08-08 08:57:35 -0400 |
commit | 840c12c10741d8f70e1787534fb6ea6d2b70edee (patch) | |
tree | f89ad27acbbf0b36db7ac08eeae0b8362da1fabb /test/functional/ex_cmds/profile_spec.lua | |
parent | e813ec79c201c85c5af3b10c051ae92ab5cb8606 (diff) | |
parent | f26df8bb66158baacb79c79822babaf137607cd6 (diff) | |
download | rneovim-840c12c10741d8f70e1787534fb6ea6d2b70edee.tar.gz rneovim-840c12c10741d8f70e1787534fb6ea6d2b70edee.tar.bz2 rneovim-840c12c10741d8f70e1787534fb6ea6d2b70edee.zip |
Merge remote-tracking branch 'upstream/master' into libcallnr
Diffstat (limited to 'test/functional/ex_cmds/profile_spec.lua')
-rw-r--r-- | test/functional/ex_cmds/profile_spec.lua | 76 |
1 files changed, 63 insertions, 13 deletions
diff --git a/test/functional/ex_cmds/profile_spec.lua b/test/functional/ex_cmds/profile_spec.lua index f185db192a..2b92f8d0de 100644 --- a/test/functional/ex_cmds/profile_spec.lua +++ b/test/functional/ex_cmds/profile_spec.lua @@ -6,6 +6,9 @@ local eval = helpers.eval local command = helpers.command local eq, neq = helpers.eq, helpers.neq 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. -- We just need the name, ignoring any race conditions. @@ -32,20 +35,67 @@ describe(':profile', function() 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) + describe('dump', function() + it('works', 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('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) - it('stop', function() - command('profile start ' .. tempfile) - assert_file_exists_not(tempfile) - command('profile stop') - assert_file_exists(tempfile) - eq(0, eval('v:profiling')) + describe('stop', function() + it('works', function() + command('profile start ' .. tempfile) + assert_file_exists_not(tempfile) + command('profile stop') + 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) |