mirror of
https://github.com/neovim/neovim.git
synced 2026-02-19 09:58:32 +00:00
test: support running functionaltests in parallel by directory (#37918)
Define a CMake target for every subdirectory of test/functional that contains functional tests, and a functionaltest_parallel target that depends on all those targets, allowing multiple test runners to run in parallel. On CI, use at most 2 parallel test runners, as using more may increase system load and make tests unstable.
This commit is contained in:
@@ -128,8 +128,9 @@ describe('lua stdlib', function()
|
||||
|
||||
-- Check if autoload works properly
|
||||
local pathsep = n.get_pathsep()
|
||||
local xconfig = 'Xhome' .. pathsep .. 'Xconfig'
|
||||
local xdata = 'Xhome' .. pathsep .. 'Xdata'
|
||||
local xhome = 'Xhome_lua'
|
||||
local xconfig = xhome .. pathsep .. 'Xconfig'
|
||||
local xdata = xhome .. pathsep .. 'Xdata'
|
||||
local autoload_folder = table.concat({ xconfig, 'nvim', 'autoload' }, pathsep)
|
||||
local autoload_file = table.concat({ autoload_folder, 'testload.vim' }, pathsep)
|
||||
mkdir_p(autoload_folder)
|
||||
@@ -138,7 +139,7 @@ describe('lua stdlib', function()
|
||||
clear { args_rm = { '-u' }, env = { XDG_CONFIG_HOME = xconfig, XDG_DATA_HOME = xdata } }
|
||||
|
||||
eq(2, exec_lua("return vim.g['testload#value']"))
|
||||
rmdir('Xhome')
|
||||
rmdir(xhome)
|
||||
end)
|
||||
|
||||
it('vim.b', function()
|
||||
|
||||
@@ -19,7 +19,7 @@ local read_file = t.read_file
|
||||
|
||||
describe('vim.secure', function()
|
||||
describe('read()', function()
|
||||
local xstate = 'Xstate'
|
||||
local xstate = 'Xstate_lua_secure'
|
||||
local screen ---@type test.functional.ui.screen
|
||||
|
||||
before_each(function()
|
||||
@@ -272,7 +272,9 @@ describe('vim.secure', function()
|
||||
end)
|
||||
|
||||
describe('trust()', function()
|
||||
local xstate = 'Xstate'
|
||||
local xstate = 'Xstate_lua_secure'
|
||||
local test_file = 'Xtest_functional_lua_secure'
|
||||
local test_dir = 'Xtest_functional_lua_secure_dir'
|
||||
|
||||
setup(function()
|
||||
clear { env = { XDG_STATE_HOME = xstate } }
|
||||
@@ -280,20 +282,20 @@ describe('vim.secure', function()
|
||||
|
||||
before_each(function()
|
||||
n.mkdir_p(xstate .. pathsep .. (is_os('win') and 'nvim-data' or 'nvim'))
|
||||
t.write_file('test_file', 'test')
|
||||
t.mkdir('test_dir')
|
||||
t.write_file(test_file, 'test')
|
||||
t.mkdir(test_dir)
|
||||
end)
|
||||
|
||||
after_each(function()
|
||||
os.remove('test_file')
|
||||
n.rmdir('test_dir')
|
||||
os.remove(test_file)
|
||||
n.rmdir(test_dir)
|
||||
n.rmdir(xstate)
|
||||
end)
|
||||
|
||||
it('returns error when passing both path and bufnr', function()
|
||||
matches(
|
||||
'"path" and "bufnr" are mutually exclusive',
|
||||
pcall_err(exec_lua, [[vim.secure.trust({action='deny', bufnr=0, path='test_file'})]])
|
||||
pcall_err(exec_lua, [[vim.secure.trust({action='deny', bufnr=0, path=...})]], test_file)
|
||||
)
|
||||
end)
|
||||
|
||||
@@ -306,10 +308,10 @@ describe('vim.secure', function()
|
||||
|
||||
it('trust then deny then remove a file using bufnr', function()
|
||||
local cwd = fn.getcwd()
|
||||
local hash = fn.sha256(assert(read_file('test_file')))
|
||||
local full_path = cwd .. pathsep .. 'test_file'
|
||||
local hash = fn.sha256(assert(read_file(test_file)))
|
||||
local full_path = cwd .. pathsep .. test_file
|
||||
|
||||
command('edit test_file')
|
||||
command('edit ' .. test_file)
|
||||
eq({ true, full_path }, exec_lua([[return {vim.secure.trust({action='allow', bufnr=0})}]]))
|
||||
local trust = assert(read_file(stdpath('state') .. pathsep .. 'trust'))
|
||||
eq(string.format('%s %s', hash, full_path), vim.trim(trust))
|
||||
@@ -325,10 +327,10 @@ describe('vim.secure', function()
|
||||
|
||||
it('deny then trust then remove a file using bufnr', function()
|
||||
local cwd = fn.getcwd()
|
||||
local hash = fn.sha256(assert(read_file('test_file')))
|
||||
local full_path = cwd .. pathsep .. 'test_file'
|
||||
local hash = fn.sha256(assert(read_file(test_file)))
|
||||
local full_path = cwd .. pathsep .. test_file
|
||||
|
||||
command('edit test_file')
|
||||
command('edit ' .. test_file)
|
||||
eq({ true, full_path }, exec_lua([[return {vim.secure.trust({action='deny', bufnr=0})}]]))
|
||||
local trust = assert(read_file(stdpath('state') .. pathsep .. 'trust'))
|
||||
eq(string.format('! %s', full_path), vim.trim(trust))
|
||||
@@ -344,24 +346,24 @@ describe('vim.secure', function()
|
||||
|
||||
it('trust using bufnr then deny then remove a file using path', function()
|
||||
local cwd = fn.getcwd()
|
||||
local hash = fn.sha256(assert(read_file('test_file')))
|
||||
local full_path = cwd .. pathsep .. 'test_file'
|
||||
local hash = fn.sha256(assert(read_file(test_file)))
|
||||
local full_path = cwd .. pathsep .. test_file
|
||||
|
||||
command('edit test_file')
|
||||
command('edit ' .. test_file)
|
||||
eq({ true, full_path }, exec_lua([[return {vim.secure.trust({action='allow', bufnr=0})}]]))
|
||||
local trust = assert(read_file(stdpath('state') .. pathsep .. 'trust'))
|
||||
eq(string.format('%s %s', hash, full_path), vim.trim(trust))
|
||||
|
||||
eq(
|
||||
{ true, full_path },
|
||||
exec_lua([[return {vim.secure.trust({action='deny', path='test_file'})}]])
|
||||
exec_lua([[return {vim.secure.trust({action='deny', path=...})}]], test_file)
|
||||
)
|
||||
trust = assert(read_file(stdpath('state') .. pathsep .. 'trust'))
|
||||
eq(string.format('! %s', full_path), vim.trim(trust))
|
||||
|
||||
eq(
|
||||
{ true, full_path },
|
||||
exec_lua([[return {vim.secure.trust({action='remove', path='test_file'})}]])
|
||||
exec_lua([[return {vim.secure.trust({action='remove', path=...})}]], test_file)
|
||||
)
|
||||
trust = assert(read_file(stdpath('state') .. pathsep .. 'trust'))
|
||||
eq('', vim.trim(trust))
|
||||
@@ -369,13 +371,13 @@ describe('vim.secure', function()
|
||||
|
||||
it('deny then trust then remove a file using bufnr', function()
|
||||
local cwd = fn.getcwd()
|
||||
local hash = fn.sha256(assert(read_file('test_file')))
|
||||
local full_path = cwd .. pathsep .. 'test_file'
|
||||
local hash = fn.sha256(assert(read_file(test_file)))
|
||||
local full_path = cwd .. pathsep .. test_file
|
||||
|
||||
command('edit test_file')
|
||||
command('edit ' .. test_file)
|
||||
eq(
|
||||
{ true, full_path },
|
||||
exec_lua([[return {vim.secure.trust({action='deny', path='test_file'})}]])
|
||||
exec_lua([[return {vim.secure.trust({action='deny', path=...})}]], test_file)
|
||||
)
|
||||
local trust = assert(read_file(stdpath('state') .. pathsep .. 'trust'))
|
||||
eq(string.format('! %s', full_path), vim.trim(trust))
|
||||
@@ -386,7 +388,7 @@ describe('vim.secure', function()
|
||||
|
||||
eq(
|
||||
{ true, full_path },
|
||||
exec_lua([[return {vim.secure.trust({action='remove', path='test_file'})}]])
|
||||
exec_lua([[return {vim.secure.trust({action='remove', path=...})}]], test_file)
|
||||
)
|
||||
trust = assert(read_file(stdpath('state') .. pathsep .. 'trust'))
|
||||
eq('', vim.trim(trust))
|
||||
@@ -402,8 +404,8 @@ describe('vim.secure', function()
|
||||
|
||||
it('trust then deny then remove a directory using bufnr', function()
|
||||
local cwd = fn.getcwd()
|
||||
local full_path = cwd .. pathsep .. 'test_dir'
|
||||
command('edit test_dir')
|
||||
local full_path = cwd .. pathsep .. test_dir
|
||||
command('edit ' .. test_dir)
|
||||
|
||||
eq({ true, full_path }, exec_lua([[return {vim.secure.trust({action='allow', bufnr=0})}]]))
|
||||
local trust = assert(read_file(stdpath('state') .. pathsep .. 'trust'))
|
||||
|
||||
Reference in New Issue
Block a user