aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMarco Hinz <mh.codebro@gmail.com>2015-11-10 03:09:38 +0100
committerMarco Hinz <mh.codebro@gmail.com>2015-11-10 03:09:38 +0100
commit971e5c22bfc51102d670549d3df1181adfc75c77 (patch)
tree3e65c5fa9849f391cfa0227a25874a0d3798e968 /test
parent94015cd13a7d17787042bd003950fc152fa129bb (diff)
parent1902ee52ef60d96f2ad043687a1e86bcf7be8aed (diff)
downloadrneovim-971e5c22bfc51102d670549d3df1181adfc75c77.tar.gz
rneovim-971e5c22bfc51102d670549d3df1181adfc75c77.tar.bz2
rneovim-971e5c22bfc51102d670549d3df1181adfc75c77.zip
Merge PR #2427 'Add ":profile dump" and ":profile stop"'
Diffstat (limited to 'test')
-rw-r--r--test/functional/ex_cmds/profile_spec.lua51
1 files changed, 51 insertions, 0 deletions
diff --git a/test/functional/ex_cmds/profile_spec.lua b/test/functional/ex_cmds/profile_spec.lua
new file mode 100644
index 0000000000..721669e73b
--- /dev/null
+++ b/test/functional/ex_cmds/profile_spec.lua
@@ -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)