test: silence expected errors

This will remove unrelated errors in .nvimlog at the end of test output.
This commit is contained in:
dundargoc
2023-09-24 21:19:01 +02:00
committed by dundargoc
parent 6cfca21bac
commit ffe3002568
8 changed files with 66 additions and 6 deletions

View File

@@ -35,7 +35,7 @@ static kvec_t(DecorProvider) decor_providers = KV_INITIAL_VALUE;
static void decor_provider_error(DecorProvider *provider, const char *name, const char *msg) static void decor_provider_error(DecorProvider *provider, const char *name, const char *msg)
{ {
const char *ns_name = describe_ns(provider->ns_id, "(UNKNOWN PLUGIN)"); const char *ns_name = describe_ns(provider->ns_id, "(UNKNOWN PLUGIN)");
ELOG("error in provider %s.%s: %s", ns_name, name, msg); ILOG("error in provider %s.%s: %s", ns_name, name, msg);
msg_schedule_semsg_multiline("Error in decoration provider %s.%s:\n%s", ns_name, name, msg); msg_schedule_semsg_multiline("Error in decoration provider %s.%s:\n%s", ns_name, name, msg);
} }

View File

@@ -90,7 +90,7 @@ int libuv_process_spawn(LibuvProcess *uvproc)
int status; int status;
if ((status = uv_spawn(&proc->loop->uv, &uvproc->uv, &uvproc->uvopts))) { if ((status = uv_spawn(&proc->loop->uv, &uvproc->uv, &uvproc->uvopts))) {
ELOG("uv_spawn(%s) failed: %s", uvproc->uvopts.file, uv_strerror(status)); DLOG("uv_spawn(%s) failed: %s", uvproc->uvopts.file, uv_strerror(status));
if (uvproc->uvopts.env) { if (uvproc->uvopts.env) {
os_free_fullenv(uvproc->uvopts.env); os_free_fullenv(uvproc->uvopts.env);
} }

View File

@@ -339,7 +339,7 @@ static void parse_msgpack(Channel *channel)
} }
if (unpacker_closed(p)) { if (unpacker_closed(p)) {
chan_close_with_error(channel, p->unpack_error.msg, LOGLVL_ERR); chan_close_with_error(channel, p->unpack_error.msg, LOGLVL_INF);
api_clear_error(&p->unpack_error); api_clear_error(&p->unpack_error);
} }
} }

View File

@@ -7,10 +7,18 @@ local api = helpers.api
local fn = helpers.fn local fn = helpers.fn
local exec = helpers.exec local exec = helpers.exec
local feed = helpers.feed local feed = helpers.feed
local assert_log = helpers.assert_log
local is_os = helpers.is_os
local testlog = 'Xtest_autocmd_oldtest_log'
describe('oldtests', function() describe('oldtests', function()
before_each(clear) before_each(clear)
after_each(function()
os.remove(testlog)
end)
local exec_lines = function(str) local exec_lines = function(str)
return fn.split(fn.execute(str), '\n') return fn.split(fn.execute(str), '\n')
end end
@@ -49,6 +57,7 @@ describe('oldtests', function()
end) end)
it('should fire on unload buf', function() it('should fire on unload buf', function()
clear({ env = { NVIM_LOG_FILE = testlog } })
fn.writefile({ 'Test file Xxx1' }, 'Xxx1') fn.writefile({ 'Test file Xxx1' }, 'Xxx1')
fn.writefile({ 'Test file Xxx2' }, 'Xxx2') fn.writefile({ 'Test file Xxx2' }, 'Xxx2')
local fname = 'Xtest_functional_autocmd_unload' local fname = 'Xtest_functional_autocmd_unload'
@@ -81,6 +90,10 @@ describe('oldtests', function()
fn.delete('Xxx2') fn.delete('Xxx2')
fn.delete(fname) fn.delete(fname)
fn.delete('Xout') fn.delete('Xout')
if is_os('win') then
assert_log('stream write failed. RPC canceled; closing channel', testlog)
end
end) end)
-- oldtest: Test_delete_ml_get_errors() -- oldtest: Test_delete_ml_get_errors()

View File

@@ -33,6 +33,8 @@ local tbl_map = vim.tbl_map
local tbl_filter = vim.tbl_filter local tbl_filter = vim.tbl_filter
local endswith = vim.endswith local endswith = vim.endswith
local testlog = 'Xtest-startupspec-log'
describe('startup', function() describe('startup', function()
it('--clean', function() it('--clean', function()
clear() clear()
@@ -121,6 +123,10 @@ end)
describe('startup', function() describe('startup', function()
before_each(clear) before_each(clear)
after_each(function()
os.remove(testlog)
end)
describe('-l Lua', function() describe('-l Lua', function()
local function assert_l_out(expected, nvim_args, lua_args, script, input) local function assert_l_out(expected, nvim_args, lua_args, script, input)
local args = { nvim_prog } local args = { nvim_prog }
@@ -371,6 +377,7 @@ describe('startup', function()
end) end)
it('output to pipe: has("ttyin")==1 has("ttyout")==0', function() it('output to pipe: has("ttyin")==1 has("ttyout")==0', function()
clear({ env = { NVIM_LOG_FILE = testlog } })
if is_os('win') then if is_os('win') then
command([[set shellcmdflag=/s\ /c shellxquote=\"]]) command([[set shellcmdflag=/s\ /c shellxquote=\"]])
end end
@@ -398,9 +405,13 @@ describe('startup', function()
read_file('Xtest_startup_ttyout') read_file('Xtest_startup_ttyout')
) )
end) end)
if is_os('win') then
assert_log('stream write failed. RPC canceled; closing channel', testlog)
end
end) end)
it('input from pipe: has("ttyin")==0 has("ttyout")==1', function() it('input from pipe: has("ttyin")==0 has("ttyout")==1', function()
clear({ env = { NVIM_LOG_FILE = testlog } })
if is_os('win') then if is_os('win') then
command([[set shellcmdflag=/s\ /c shellxquote=\"]]) command([[set shellcmdflag=/s\ /c shellxquote=\"]])
end end
@@ -429,9 +440,13 @@ describe('startup', function()
read_file('Xtest_startup_ttyout') read_file('Xtest_startup_ttyout')
) )
end) end)
if is_os('win') then
assert_log('stream write failed. RPC canceled; closing channel', testlog)
end
end) end)
it('input from pipe (implicit) #7679', function() it('input from pipe (implicit) #7679', function()
clear({ env = { NVIM_LOG_FILE = testlog } })
local screen = Screen.new(25, 4) local screen = Screen.new(25, 4)
screen:attach() screen:attach()
screen._default_attr_ids = nil screen._default_attr_ids = nil
@@ -457,6 +472,9 @@ describe('startup', function()
0 1 | 0 1 |
| |
]]) ]])
if not is_os('win') then
assert_log('Failed to get flags on descriptor 3: Bad file descriptor', testlog)
end
end) end)
it('input from pipe + file args #7679', function() it('input from pipe + file args #7679', function()

View File

@@ -865,6 +865,10 @@ describe('XDG defaults', function()
end) end)
describe('stdpath()', function() describe('stdpath()', function()
after_each(function()
os.remove(testlog)
end)
-- Windows appends 'nvim-data' instead of just 'nvim' to prevent collisions -- Windows appends 'nvim-data' instead of just 'nvim' to prevent collisions
-- due to XDG_CONFIG_HOME, XDG_DATA_HOME and XDG_STATE_HOME being the same. -- due to XDG_CONFIG_HOME, XDG_DATA_HOME and XDG_STATE_HOME being the same.
local function maybe_data(name) local function maybe_data(name)
@@ -890,7 +894,7 @@ describe('stdpath()', function()
it('reacts to $NVIM_APPNAME', function() it('reacts to $NVIM_APPNAME', function()
local appname = 'NVIM_APPNAME_TEST' .. ('_'):rep(106) local appname = 'NVIM_APPNAME_TEST' .. ('_'):rep(106)
clear({ env = { NVIM_APPNAME = appname } }) clear({ env = { NVIM_APPNAME = appname, NVIM_LOG_FILE = testlog } })
eq(appname, fn.fnamemodify(fn.stdpath('config'), ':t')) eq(appname, fn.fnamemodify(fn.stdpath('config'), ':t'))
eq(appname, fn.fnamemodify(fn.stdpath('cache'), ':t')) eq(appname, fn.fnamemodify(fn.stdpath('cache'), ':t'))
eq(maybe_data(appname), fn.fnamemodify(fn.stdpath('log'), ':t')) eq(maybe_data(appname), fn.fnamemodify(fn.stdpath('log'), ':t'))
@@ -928,6 +932,9 @@ describe('stdpath()', function()
-- Valid appnames: -- Valid appnames:
test_appname('a/b', 0) test_appname('a/b', 0)
test_appname('a/b\\c', 0) test_appname('a/b\\c', 0)
if not is_os('win') then
assert_log('Failed to start server: no such file or directory:', testlog)
end
end) end)
describe('returns a String', function() describe('returns a String', function()

View File

@@ -29,6 +29,9 @@ local spawn_argv = helpers.spawn_argv
local set_session = helpers.set_session local set_session = helpers.set_session
local write_file = helpers.write_file local write_file = helpers.write_file
local eval = helpers.eval local eval = helpers.eval
local assert_log = helpers.assert_log
local testlog = 'Xtest-tui-log'
if helpers.skip(is_os('win')) then if helpers.skip(is_os('win')) then
return return
@@ -3000,6 +3003,10 @@ end)
-- These tests require `thelpers` because --headless/--embed -- These tests require `thelpers` because --headless/--embed
-- does not initialize the TUI. -- does not initialize the TUI.
describe('TUI as a client', function() describe('TUI as a client', function()
after_each(function()
os.remove(testlog)
end)
it('connects to remote instance (with its own TUI)', function() it('connects to remote instance (with its own TUI)', function()
local server_super = spawn_argv(false) -- equivalent to clear() local server_super = spawn_argv(false) -- equivalent to clear()
local client_super = spawn_argv(true) local client_super = spawn_argv(true)
@@ -3077,7 +3084,7 @@ describe('TUI as a client', function()
it('connects to remote instance (--headless)', function() it('connects to remote instance (--headless)', function()
local server = spawn_argv(false) -- equivalent to clear() local server = spawn_argv(false) -- equivalent to clear()
local client_super = spawn_argv(true) local client_super = spawn_argv(true, { env = { NVIM_LOG_FILE = testlog } })
set_session(server) set_session(server)
local server_pipe = api.nvim_get_vvar('servername') local server_pipe = api.nvim_get_vvar('servername')
@@ -3120,6 +3127,9 @@ describe('TUI as a client', function()
client_super:close() client_super:close()
server:close() server:close()
if is_os('mac') then
assert_log('uv_tty_set_mode failed: Unknown system error %-102', testlog)
end
end) end)
it('throws error when no server exists', function() it('throws error when no server exists', function()

View File

@@ -13,6 +13,10 @@ local fn = helpers.fn
local nvim_prog = helpers.nvim_prog local nvim_prog = helpers.nvim_prog
local retry = helpers.retry local retry = helpers.retry
local write_file = helpers.write_file local write_file = helpers.write_file
local assert_log = helpers.assert_log
local is_os = helpers.is_os
local testlog = 'Xtest-embed-log'
local function test_embed(ext_linegrid) local function test_embed(ext_linegrid)
local screen local screen
@@ -93,13 +97,17 @@ describe('--embed UI on startup (ext_linegrid=false)', function()
end) end)
describe('--embed UI', function() describe('--embed UI', function()
after_each(function()
os.remove(testlog)
end)
it('can pass stdin', function() it('can pass stdin', function()
local pipe = assert(uv.pipe()) local pipe = assert(uv.pipe())
local writer = assert(uv.new_pipe(false)) local writer = assert(uv.new_pipe(false))
writer:open(pipe.write) writer:open(pipe.write)
clear { args_rm = { '--headless' }, io_extra = pipe.read } clear { args_rm = { '--headless' }, io_extra = pipe.read, env = { NVIM_LOG_FILE = testlog } }
-- attach immediately after startup, for early UI -- attach immediately after startup, for early UI
local screen = Screen.new(40, 8) local screen = Screen.new(40, 8)
@@ -131,6 +139,10 @@ describe('--embed UI', function()
{1:~ }|*4 {1:~ }|*4
{2:-- INSERT --} | {2:-- INSERT --} |
]] ]]
if not is_os('win') then
assert_log('Failed to get flags on descriptor 3: Bad file descriptor', testlog)
end
end) end)
it('can pass stdin to -q - #17523', function() it('can pass stdin to -q - #17523', function()