2015-04-14 17:14:40 -07:00
|
|
|
require('os')
|
2015-11-17 15:31:22 -07:00
|
|
|
local lfs = require('lfs')
|
2015-04-14 17:14:40 -07:00
|
|
|
|
2016-04-23 16:53:11 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
2015-04-14 17:14:40 -07:00
|
|
|
local eval = helpers.eval
|
|
|
|
local command = helpers.command
|
|
|
|
local eq, neq = helpers.eq, helpers.neq
|
2015-12-29 12:18:16 -07:00
|
|
|
local tempfile = helpers.tmpname()
|
2015-04-14 17:14:40 -07:00
|
|
|
|
2015-12-29 12:18:16 -07:00
|
|
|
-- tmpname() also creates the file on POSIX systems. Remove it again.
|
2015-04-14 17:14:40 -07:00
|
|
|
-- 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)
|