mirror of
https://github.com/neovim/neovim.git
synced 2026-02-09 05:18:45 +00:00
fix(tui): log chdir failure properly #37591
This commit is contained in:
@@ -1755,7 +1755,7 @@ void tui_chdir(TUIData *tui, String path)
|
||||
{
|
||||
int err = uv_chdir(path.data);
|
||||
if (err != 0) {
|
||||
ELOG("Failed to chdir to %s: %s", path.data, strerror(err));
|
||||
ELOG("Failed to chdir to %s: %s", path.data, uv_strerror(err));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -106,6 +106,19 @@ return function(options)
|
||||
local failureCount = 0
|
||||
local errorCount = 0
|
||||
|
||||
local naCheck = function(pending)
|
||||
if pending.name:find(' N/A[: ]') or pending.name:find(' N/A$') then
|
||||
return true
|
||||
end
|
||||
if type(pending.message) ~= 'string' then
|
||||
return false
|
||||
end
|
||||
if pending.message:find(' N/A[: ]') or pending.message:find(' N/A$') then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local pendingDescription = function(pending)
|
||||
local string = ''
|
||||
|
||||
@@ -156,10 +169,21 @@ return function(options)
|
||||
|
||||
local testString = summaryStrings[status].test
|
||||
if testString then
|
||||
local naCount = 0
|
||||
for _, t in ipairs(list) do
|
||||
local fullname = getFileLine(t.element) .. colors.bright(t.name)
|
||||
string = string .. testString:format(fullname)
|
||||
string = string .. getDescription(t)
|
||||
if status == 'skipped' and naCheck(t) then
|
||||
naCount = naCount + 1
|
||||
else
|
||||
local fullname = getFileLine(t.element) .. colors.bright(t.name)
|
||||
string = string .. testString:format(fullname)
|
||||
string = string .. getDescription(t)
|
||||
end
|
||||
end
|
||||
if naCount > 0 then
|
||||
string = string
|
||||
.. colors.bright(
|
||||
('%d N/A %s not shown\n'):format(naCount, naCount == 1 and 'test' or 'tests')
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,7 +12,7 @@ local read_file = t.read_file
|
||||
local feed = n.feed
|
||||
local retry = t.retry
|
||||
|
||||
if skip(is_os('win'), 'Only applies to POSIX systems') then
|
||||
if skip(is_os('win'), 'N/A: Only applies to POSIX systems') then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
@@ -749,7 +749,7 @@ describe('jobs', function()
|
||||
|
||||
it('lists passed to callbacks are freed if not stored #25891', function()
|
||||
if not exec_lua('return pcall(require, "ffi")') then
|
||||
pending('missing LuaJIT FFI')
|
||||
pending('N/A: missing LuaJIT FFI')
|
||||
end
|
||||
|
||||
source([[
|
||||
|
||||
@@ -220,12 +220,10 @@ describe('server', function()
|
||||
end)
|
||||
|
||||
it('removes stale socket files automatically #26053', function()
|
||||
if is_os('win') then
|
||||
-- Windows named pipes are ephemeral kernel objects that are automatically
|
||||
-- cleaned up when the process terminates. Unix domain sockets persist as
|
||||
-- files on the filesystem and can become stale after crashes.
|
||||
return
|
||||
end
|
||||
-- Windows named pipes are ephemeral kernel objects that are automatically
|
||||
-- cleaned up when the process terminates. Unix domain sockets persist as
|
||||
-- files on the filesystem and can become stale after crashes.
|
||||
t.skip(is_os('win'), 'N/A on Windows')
|
||||
|
||||
clear()
|
||||
clear_serverlist()
|
||||
@@ -246,9 +244,7 @@ describe('server', function()
|
||||
end)
|
||||
|
||||
it('does not remove live sockets #26053', function()
|
||||
if is_os('win') then
|
||||
return
|
||||
end
|
||||
t.skip(is_os('win'), 'N/A on Windows')
|
||||
|
||||
clear()
|
||||
local socket_path = './Xtest-live-socket'
|
||||
|
||||
@@ -31,9 +31,7 @@ describe('completion', function()
|
||||
end)
|
||||
|
||||
it('ctrl-x_ctrl-f completes Windows drive letter', function()
|
||||
if not t.is_os('win') then
|
||||
return
|
||||
end
|
||||
t.skip(not t.is_os('win'), 'N/A for non-Windows')
|
||||
feed('iblablaC:/W<C-x><C-f>')
|
||||
screen:expect {
|
||||
any = [[C:\Windows\]],
|
||||
|
||||
@@ -48,10 +48,8 @@ describe(':source', function()
|
||||
end)
|
||||
|
||||
it("changing 'shellslash' changes the result of expand()", function()
|
||||
if not is_os('win') then
|
||||
pending("'shellslash' only works on Windows")
|
||||
return
|
||||
end
|
||||
t.skip(not is_os('win'), "N/A: 'shellslash' only works on Windows")
|
||||
|
||||
api.nvim_set_option_value('shellslash', false, {})
|
||||
mkdir('Xshellslash')
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ before_each(clear)
|
||||
describe('ffi.cdef', function()
|
||||
it('can use Neovim core functions', function()
|
||||
if not exec_lua("return pcall(require, 'ffi')") then
|
||||
pending('missing LuaJIT FFI')
|
||||
pending('N/A: missing LuaJIT FFI')
|
||||
end
|
||||
|
||||
eq(
|
||||
|
||||
@@ -206,7 +206,7 @@ describe('URI methods', function()
|
||||
|
||||
describe('uri from bufnr', function()
|
||||
it('Windows paths should not be treated as uris', function()
|
||||
skip(not is_os('win'), 'Not applicable on non-Windows')
|
||||
skip(not is_os('win'), 'N/A on non-Windows')
|
||||
|
||||
local file = t.tmpname()
|
||||
write_file(file, 'Test content')
|
||||
|
||||
@@ -2744,7 +2744,7 @@ describe('TUI', function()
|
||||
|
||||
it('argv[0] can be overridden #23953', function()
|
||||
if not exec_lua('return pcall(require, "ffi")') then
|
||||
pending('missing LuaJIT FFI')
|
||||
pending('N/A: missing LuaJIT FFI')
|
||||
end
|
||||
local script_file = 'Xargv0.lua'
|
||||
write_file(
|
||||
@@ -3674,7 +3674,7 @@ describe('TUI', function()
|
||||
it('queries the terminal for OSC 52 support with XTGETTCAP', function()
|
||||
clear()
|
||||
if not exec_lua('return pcall(require, "ffi")') then
|
||||
pending('missing LuaJIT FFI')
|
||||
pending('N/A: missing LuaJIT FFI')
|
||||
end
|
||||
|
||||
-- Change vterm's DA1 response so that it doesn't include 52
|
||||
@@ -4122,33 +4122,29 @@ describe('TUI client', function()
|
||||
screen_client:expect({ any = vim.pesc('[Process exited 0]') })
|
||||
end)
|
||||
|
||||
local ffi_str_defs = [[
|
||||
local ffi = require('ffi')
|
||||
local cstr = ffi.typeof('char[?]')
|
||||
ffi.cdef('typedef struct { char *data; size_t size; } String;')
|
||||
local function to_api_string(str)
|
||||
return ffi.new('String', { data = cstr(#str + 1, str), size = #str })
|
||||
end
|
||||
]]
|
||||
|
||||
it('does not crash or hang with a very long title', function()
|
||||
local server, _, screen_client = start_headless_server_and_client(true)
|
||||
|
||||
local server_exec_lua = tt.make_lua_executor(server)
|
||||
if not server_exec_lua('return pcall(require, "ffi")') then
|
||||
pending('missing LuaJIT FFI')
|
||||
pending('N/A: missing LuaJIT FFI')
|
||||
end
|
||||
|
||||
local bufname = api.nvim_buf_get_name(0)
|
||||
-- Normally a title cannot be longer than the 65535-byte buffer as maketitle()
|
||||
-- limits it length. Use FFI to send a very long title directly.
|
||||
server_exec_lua([=[
|
||||
local ffi = require('ffi')
|
||||
local cstr = ffi.typeof('char[?]')
|
||||
local function to_cstr(string)
|
||||
return cstr(#string + 1, string)
|
||||
end
|
||||
|
||||
ffi.cdef([[
|
||||
typedef struct { char *data; size_t size; } String;
|
||||
void ui_call_set_title(String title);
|
||||
]])
|
||||
|
||||
local len = 65536
|
||||
local title = ffi.new('String', { data = to_cstr(('a'):rep(len)), size = len })
|
||||
ffi.C.ui_call_set_title(title)
|
||||
]=])
|
||||
server_exec_lua(ffi_str_defs .. [[
|
||||
ffi.cdef('void ui_call_set_title(String title);')
|
||||
ffi.C.ui_call_set_title(to_api_string(('a'):rep(65536)))
|
||||
]])
|
||||
screen_client:expect_unchanged()
|
||||
assert_log('set_title: title string too long!', testlog)
|
||||
eq(bufname, api.nvim_buf_get_var(0, 'term_title'))
|
||||
@@ -4160,6 +4156,22 @@ describe('TUI client', function()
|
||||
end)
|
||||
end)
|
||||
|
||||
it('logs chdir failure properly', function()
|
||||
local server, _, screen_client = start_headless_server_and_client(true)
|
||||
local server_exec_lua = tt.make_lua_executor(server)
|
||||
if not server_exec_lua('return pcall(require, "ffi")') then
|
||||
pending('N/A: missing LuaJIT FFI')
|
||||
end
|
||||
|
||||
-- Use FFI to send a chdir event to a non-directory path.
|
||||
server_exec_lua(ffi_str_defs .. [[
|
||||
ffi.cdef('void ui_call_chdir(String path);')
|
||||
ffi.C.ui_call_chdir(to_api_string('README.md'))
|
||||
]])
|
||||
screen_client:expect_unchanged()
|
||||
assert_log('Failed to chdir to README.md: not a directory', testlog)
|
||||
end)
|
||||
|
||||
it('nvim_ui_send works with remote client #36317', function()
|
||||
local server, _, _ = start_headless_server_and_client(false)
|
||||
server:request('nvim_ui_send', '\027]2;TEST_TITLE\027\\')
|
||||
|
||||
Reference in New Issue
Block a user