aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt91
-rw-r--r--test/functional/api/server_requests_spec.lua15
-rw-r--r--test/functional/core/exit_spec.lua32
-rw-r--r--test/functional/terminal/tui_spec.lua5
4 files changed, 129 insertions, 14 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644
index 0000000000..7e5fb07382
--- /dev/null
+++ b/test/CMakeLists.txt
@@ -0,0 +1,91 @@
+add_subdirectory(functional/fixtures) # compile test programs
+get_directory_property(GENERATED_HELP_TAGS DIRECTORY ${PROJECT_SOURCE_DIR}/runtime DEFINITION GENERATED_HELP_TAGS)
+
+if(NOT BUSTED_OUTPUT_TYPE)
+ set(BUSTED_OUTPUT_TYPE "nvim")
+endif()
+
+find_program(BUSTED_PRG NAMES busted busted.bat)
+if(BUSTED_PRG)
+ get_target_property(TEST_INCLUDE_DIRS main_lib INTERFACE_INCLUDE_DIRECTORIES)
+
+ set(UNITTEST_PREREQS nvim)
+ set(FUNCTIONALTEST_PREREQS nvim printenv-test printargs-test shell-test pwsh-test streams-test tty-test ${GENERATED_HELP_TAGS})
+ set(BENCHMARK_PREREQS nvim tty-test)
+
+ check_lua_module(${LUA_PRG} "ffi" LUA_HAS_FFI)
+ if(LUA_HAS_FFI)
+ add_custom_target(unittest
+ COMMAND ${CMAKE_COMMAND}
+ -D BUSTED_PRG=${BUSTED_PRG}
+ -D LUA_PRG=${LUA_PRG}
+ -D NVIM_PRG=$<TARGET_FILE:nvim>
+ -D WORKING_DIR=${PROJECT_SOURCE_DIR}
+ -D BUSTED_OUTPUT_TYPE=${BUSTED_OUTPUT_TYPE}
+ -D TEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}
+ -D BUILD_DIR=${CMAKE_BINARY_DIR}
+ -D TEST_TYPE=unit
+ -D CIRRUS_CI=$ENV{CIRRUS_CI}
+ -P ${PROJECT_SOURCE_DIR}/cmake/RunTests.cmake
+ DEPENDS ${UNITTEST_PREREQS}
+ USES_TERMINAL)
+ set_target_properties(unittest PROPERTIES FOLDER test)
+ else()
+ message(WARNING "disabling unit tests: no Luajit FFI in ${LUA_PRG}")
+ endif()
+
+ configure_file(
+ ${CMAKE_SOURCE_DIR}/test/cmakeconfig/paths.lua.in
+ ${CMAKE_BINARY_DIR}/test/cmakeconfig/paths.lua)
+
+ add_custom_target(functionaltest
+ COMMAND ${CMAKE_COMMAND}
+ -D BUSTED_PRG=${BUSTED_PRG}
+ -D LUA_PRG=${LUA_PRG}
+ -D NVIM_PRG=$<TARGET_FILE:nvim>
+ -D WORKING_DIR=${PROJECT_SOURCE_DIR}
+ -D BUSTED_OUTPUT_TYPE=${BUSTED_OUTPUT_TYPE}
+ -D TEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}
+ -D BUILD_DIR=${CMAKE_BINARY_DIR}
+ -D TEST_TYPE=functional
+ -D CIRRUS_CI=$ENV{CIRRUS_CI}
+ -P ${PROJECT_SOURCE_DIR}/cmake/RunTests.cmake
+ DEPENDS ${FUNCTIONALTEST_PREREQS}
+ USES_TERMINAL)
+ set_target_properties(functionaltest PROPERTIES FOLDER test)
+
+ add_custom_target(benchmark
+ COMMAND ${CMAKE_COMMAND}
+ -D BUSTED_PRG=${BUSTED_PRG}
+ -D LUA_PRG=${LUA_PRG}
+ -D NVIM_PRG=$<TARGET_FILE:nvim>
+ -D WORKING_DIR=${PROJECT_SOURCE_DIR}
+ -D BUSTED_OUTPUT_TYPE=${BUSTED_OUTPUT_TYPE}
+ -D TEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}
+ -D BUILD_DIR=${CMAKE_BINARY_DIR}
+ -D TEST_TYPE=benchmark
+ -D CIRRUS_CI=$ENV{CIRRUS_CI}
+ -P ${PROJECT_SOURCE_DIR}/cmake/RunTests.cmake
+ DEPENDS ${BENCHMARK_PREREQS}
+ USES_TERMINAL)
+ set_target_properties(benchmark PROPERTIES FOLDER test)
+endif()
+
+find_program(BUSTED_LUA_PRG busted-lua)
+if(BUSTED_LUA_PRG)
+ add_custom_target(functionaltest-lua
+ COMMAND ${CMAKE_COMMAND}
+ -D BUSTED_PRG=${BUSTED_LUA_PRG}
+ -D LUA_PRG=${LUA_PRG}
+ -D NVIM_PRG=$<TARGET_FILE:nvim>
+ -D WORKING_DIR=${PROJECT_SOURCE_DIR}
+ -D BUSTED_OUTPUT_TYPE=${BUSTED_OUTPUT_TYPE}
+ -D TEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}
+ -D BUILD_DIR=${CMAKE_BINARY_DIR}
+ -D TEST_TYPE=functional
+ -D CIRRUS_CI=$ENV{CIRRUS_CI}
+ -P ${PROJECT_SOURCE_DIR}/cmake/RunTests.cmake
+ DEPENDS ${FUNCTIONALTEST_PREREQS}
+ USES_TERMINAL)
+ set_target_properties(functionaltest-lua PROPERTIES FOLDER test)
+endif()
diff --git a/test/functional/api/server_requests_spec.lua b/test/functional/api/server_requests_spec.lua
index ceff390dc5..e6bfc6b64f 100644
--- a/test/functional/api/server_requests_spec.lua
+++ b/test/functional/api/server_requests_spec.lua
@@ -337,6 +337,21 @@ describe('server -> client', function()
eq('localhost:', string.sub(address,1,10))
connect_test(server, 'tcp', address)
end)
+
+ it('does not crash on receiving UI events', function()
+ local server = spawn(nvim_argv)
+ set_session(server)
+ local address = funcs.serverlist()[1]
+ local client = spawn(nvim_argv, false, nil, true)
+ set_session(client)
+
+ local id = funcs.sockconnect('pipe', address, {rpc=true})
+ funcs.rpcrequest(id, 'nvim_ui_attach', 80, 24, {})
+ assert_alive()
+
+ server:close()
+ client:close()
+ end)
end)
describe('connecting to its own pipe address', function()
diff --git a/test/functional/core/exit_spec.lua b/test/functional/core/exit_spec.lua
index 05a69e1992..dc4b45b4d9 100644
--- a/test/functional/core/exit_spec.lua
+++ b/test/functional/core/exit_spec.lua
@@ -25,30 +25,34 @@ describe('v:exiting', function()
eq(1, eval('v:exiting is v:null'))
end)
- it('is 0 on normal exit', function()
+ local function test_exiting(setup_fn)
local function on_setup()
- command('autocmd VimLeavePre * call rpcrequest('..cid..', "")')
- command('autocmd VimLeave * call rpcrequest('..cid..', "")')
- command('quit')
+ command('autocmd VimLeavePre * call rpcrequest('..cid..', "exit", "VimLeavePre")')
+ command('autocmd VimLeave * call rpcrequest('..cid..', "exit", "VimLeave")')
+ setup_fn()
end
- local function on_request()
+ local requests_args = {}
+ local function on_request(name, args)
+ eq('exit', name)
+ table.insert(requests_args, args)
eq(0, eval('v:exiting'))
return ''
end
run(on_request, nil, on_setup)
+ eq({{'VimLeavePre'}, {'VimLeave'}}, requests_args)
+ end
+
+ it('is 0 on normal exit', function()
+ test_exiting(function()
+ command('quit')
+ end)
end)
+
it('is 0 on exit from Ex mode involving try-catch vim-patch:8.0.0184', function()
- local function on_setup()
- command('autocmd VimLeavePre * call rpcrequest('..cid..', "")')
- command('autocmd VimLeave * call rpcrequest('..cid..', "")')
+ test_exiting(function()
feed('gQ')
feed_command('try', 'call NoFunction()', 'catch', 'echo "bye"', 'endtry', 'quit')
- end
- local function on_request()
- eq(0, eval('v:exiting'))
- return ''
- end
- run(on_request, nil, on_setup)
+ end)
end)
end)
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index 1d9e7b8e11..7294969ac8 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -2407,6 +2407,11 @@ describe("TUI as a client", function()
{3:-- TERMINAL --} |
]]}
+ -- No heap-use-after-free when receiving UI events after deadly signal #22184
+ server:request('nvim_input', ('a'):rep(1000))
+ exec_lua([[vim.loop.kill(vim.fn.jobpid(vim.bo.channel), 'sigterm')]])
+ screen:expect({any = '%[Process exited 1%]'})
+
client_super:close()
server:close()
end)