mirror of
https://github.com/neovim/neovim.git
synced 2025-12-18 12:25:34 +00:00
test: Improve functional test debuggability and efficiency
- Read TEST_TAG/TEST_FILTER env vars from cmake/RunTests.cmake. Setting these environment variables will pass --tags/--filter to busted, which can used to filter which tests are executed. - Remove calls to nvim msgpack-rpc API outside tests. This removes the requirement of having a static `clear` call in test/functional/helpers.lua - Use the new busted command-line option "--lazy" to ensure the setup/teardown hooks are only executed when a suite runs at least one test. Now its possible to run/debug a single test like this: ```sh TEST_FILTER='some test string' make test ``` Which will only run tests containing "some test string" in the title. Another option is: ```sh TEST_TAG=some-tag make test ``` After putting #some-tag into the test title. This also improves debugging experience because there will be no unnecessary gdbserver instances whe GDB=1 is passed.
This commit is contained in:
@@ -17,9 +17,17 @@ if(BUSTED_OUTPUT_TYPE STREQUAL junit)
|
|||||||
set(EXTRA_ARGS OUTPUT_FILE ${BUILD_DIR}/${TEST_TYPE}test-junit.xml)
|
set(EXTRA_ARGS OUTPUT_FILE ${BUILD_DIR}/${TEST_TYPE}test-junit.xml)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(DEFINED ENV{TEST_TAG})
|
||||||
|
set(TEST_TAG "--tags=$ENV{TEST_TAG}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(DEFINED ENV{TEST_FILTER})
|
||||||
|
set(TEST_TAG "--filter=$ENV{TEST_FILTER}")
|
||||||
|
endif()
|
||||||
|
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND ${BUSTED_PRG} -v -o ${BUSTED_OUTPUT_TYPE}
|
COMMAND ${BUSTED_PRG} ${TEST_TAG} ${TEST_FILTER} -v -o ${BUSTED_OUTPUT_TYPE}
|
||||||
--helper=${TEST_DIR}/${TEST_TYPE}/preload.lua
|
--lazy --helper=${TEST_DIR}/${TEST_TYPE}/preload.lua
|
||||||
--lpath=${BUILD_DIR}/?.lua ${TEST_PATH}
|
--lpath=${BUILD_DIR}/?.lua ${TEST_PATH}
|
||||||
WORKING_DIRECTORY ${WORKING_DIR}
|
WORKING_DIRECTORY ${WORKING_DIR}
|
||||||
ERROR_VARIABLE err
|
ERROR_VARIABLE err
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ local clear, nvim, buffer, curbuf, curwin, eq, neq, ok =
|
|||||||
helpers.eq, helpers.neq, helpers.ok
|
helpers.eq, helpers.neq, helpers.ok
|
||||||
|
|
||||||
describe('TabNew', function()
|
describe('TabNew', function()
|
||||||
|
setup(clear)
|
||||||
describe('au TabNew', function()
|
describe('au TabNew', function()
|
||||||
clear()
|
|
||||||
describe('with * as <afile>', function()
|
describe('with * as <afile>', function()
|
||||||
it('matches when opening any new tab', function()
|
it('matches when opening any new tab', function()
|
||||||
nvim('command', 'au! TabNew * echom "tabnew:".tabpagenr().":".bufnr("")')
|
nvim('command', 'au! TabNew * echom "tabnew:".tabpagenr().":".bufnr("")')
|
||||||
|
|||||||
@@ -276,8 +276,6 @@ local function expect(contents)
|
|||||||
return eq(dedent(contents), curbuf_contents())
|
return eq(dedent(contents), curbuf_contents())
|
||||||
end
|
end
|
||||||
|
|
||||||
clear()
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
clear = clear,
|
clear = clear,
|
||||||
spawn = spawn,
|
spawn = spawn,
|
||||||
|
|||||||
@@ -6,10 +6,14 @@ local clear, nvim, eq, neq, ok, expect, eval, next_message, run, stop, session
|
|||||||
helpers.stop, helpers.session
|
helpers.stop, helpers.session
|
||||||
local nvim_dir, insert = helpers.nvim_dir, helpers.insert
|
local nvim_dir, insert = helpers.nvim_dir, helpers.insert
|
||||||
|
|
||||||
local channel = nvim('get_api_info')[1]
|
|
||||||
|
|
||||||
describe('jobs', function()
|
describe('jobs', function()
|
||||||
before_each(clear)
|
local channel
|
||||||
|
|
||||||
|
before_each(function()
|
||||||
|
clear()
|
||||||
|
channel = nvim('get_api_info')[1]
|
||||||
|
end)
|
||||||
|
|
||||||
-- Creates the string to make an autocmd to notify us.
|
-- Creates the string to make an autocmd to notify us.
|
||||||
local notify_str = function(expr1, expr2)
|
local notify_str = function(expr1, expr2)
|
||||||
|
|||||||
Reference in New Issue
Block a user