Skip to content

Commit

Permalink
test: silence expected errors
Browse files Browse the repository at this point in the history
This will remove unrelated errors in .nvimlog at the end of test output.
  • Loading branch information
dundargoc committed Apr 2, 2024
1 parent 6cfca21 commit ffe3002
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/nvim/decoration_provider.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/nvim/event/libuv_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ int libuv_process_spawn(LibuvProcess *uvproc)

int status;
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) {
os_free_fullenv(uvproc->uvopts.env);
}
Expand Down
2 changes: 1 addition & 1 deletion src/nvim/msgpack_rpc/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ static void parse_msgpack(Channel *channel)
}

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);
}
}
Expand Down
13 changes: 13 additions & 0 deletions test/functional/autocmd/autocmd_oldtest_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@ local api = helpers.api
local fn = helpers.fn
local exec = helpers.exec
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()
before_each(clear)

after_each(function()
os.remove(testlog)
end)

local exec_lines = function(str)
return fn.split(fn.execute(str), '\n')
end
Expand Down Expand Up @@ -49,6 +57,7 @@ describe('oldtests', function()
end)

it('should fire on unload buf', function()
clear({ env = { NVIM_LOG_FILE = testlog } })
fn.writefile({ 'Test file Xxx1' }, 'Xxx1')
fn.writefile({ 'Test file Xxx2' }, 'Xxx2')
local fname = 'Xtest_functional_autocmd_unload'
Expand Down Expand Up @@ -81,6 +90,10 @@ describe('oldtests', function()
fn.delete('Xxx2')
fn.delete(fname)
fn.delete('Xout')

if is_os('win') then
assert_log('stream write failed. RPC canceled; closing channel', testlog)
end
end)

-- oldtest: Test_delete_ml_get_errors()
Expand Down
18 changes: 18 additions & 0 deletions test/functional/core/startup_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ local tbl_map = vim.tbl_map
local tbl_filter = vim.tbl_filter
local endswith = vim.endswith

local testlog = 'Xtest-startupspec-log'

describe('startup', function()
it('--clean', function()
clear()
Expand Down Expand Up @@ -121,6 +123,10 @@ end)
describe('startup', function()
before_each(clear)

after_each(function()
os.remove(testlog)
end)

describe('-l Lua', function()
local function assert_l_out(expected, nvim_args, lua_args, script, input)
local args = { nvim_prog }
Expand Down Expand Up @@ -371,6 +377,7 @@ describe('startup', function()
end)

it('output to pipe: has("ttyin")==1 has("ttyout")==0', function()
clear({ env = { NVIM_LOG_FILE = testlog } })
if is_os('win') then
command([[set shellcmdflag=/s\ /c shellxquote=\"]])
end
Expand Down Expand Up @@ -398,9 +405,13 @@ describe('startup', function()
read_file('Xtest_startup_ttyout')
)
end)
if is_os('win') then
assert_log('stream write failed. RPC canceled; closing channel', testlog)
end
end)

it('input from pipe: has("ttyin")==0 has("ttyout")==1', function()
clear({ env = { NVIM_LOG_FILE = testlog } })
if is_os('win') then
command([[set shellcmdflag=/s\ /c shellxquote=\"]])
end
Expand Down Expand Up @@ -429,9 +440,13 @@ describe('startup', function()
read_file('Xtest_startup_ttyout')
)
end)
if is_os('win') then
assert_log('stream write failed. RPC canceled; closing channel', testlog)
end
end)

it('input from pipe (implicit) #7679', function()
clear({ env = { NVIM_LOG_FILE = testlog } })
local screen = Screen.new(25, 4)
screen:attach()
screen._default_attr_ids = nil
Expand All @@ -457,6 +472,9 @@ describe('startup', function()
0 1 |
|
]])
if not is_os('win') then
assert_log('Failed to get flags on descriptor 3: Bad file descriptor', testlog)
end
end)

it('input from pipe + file args #7679', function()
Expand Down
9 changes: 8 additions & 1 deletion test/functional/options/defaults_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,10 @@ describe('XDG defaults', function()
end)

describe('stdpath()', function()
after_each(function()
os.remove(testlog)
end)

-- 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.
local function maybe_data(name)
Expand All @@ -890,7 +894,7 @@ describe('stdpath()', function()

it('reacts to $NVIM_APPNAME', function()
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('cache'), ':t'))
eq(maybe_data(appname), fn.fnamemodify(fn.stdpath('log'), ':t'))
Expand Down Expand Up @@ -928,6 +932,9 @@ describe('stdpath()', function()
-- Valid appnames:
test_appname('a/b', 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)

describe('returns a String', function()
Expand Down
12 changes: 11 additions & 1 deletion test/functional/terminal/tui_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ local spawn_argv = helpers.spawn_argv
local set_session = helpers.set_session
local write_file = helpers.write_file
local eval = helpers.eval
local assert_log = helpers.assert_log

local testlog = 'Xtest-tui-log'

if helpers.skip(is_os('win')) then
return
Expand Down Expand Up @@ -3000,6 +3003,10 @@ end)
-- These tests require `thelpers` because --headless/--embed
-- does not initialize the TUI.
describe('TUI as a client', function()
after_each(function()
os.remove(testlog)
end)

it('connects to remote instance (with its own TUI)', function()
local server_super = spawn_argv(false) -- equivalent to clear()
local client_super = spawn_argv(true)
Expand Down Expand Up @@ -3077,7 +3084,7 @@ describe('TUI as a client', function()

it('connects to remote instance (--headless)', function()
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)
local server_pipe = api.nvim_get_vvar('servername')
Expand Down Expand Up @@ -3120,6 +3127,9 @@ describe('TUI as a client', function()

client_super:close()
server:close()
if is_os('mac') then
assert_log('uv_tty_set_mode failed: Unknown system error %-102', testlog)
end
end)

it('throws error when no server exists', function()
Expand Down
14 changes: 13 additions & 1 deletion test/functional/ui/embed_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ local fn = helpers.fn
local nvim_prog = helpers.nvim_prog
local retry = helpers.retry
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 screen
Expand Down Expand Up @@ -93,13 +97,17 @@ describe('--embed UI on startup (ext_linegrid=false)', function()
end)

describe('--embed UI', function()
after_each(function()
os.remove(testlog)
end)

it('can pass stdin', function()
local pipe = assert(uv.pipe())

local writer = assert(uv.new_pipe(false))
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
local screen = Screen.new(40, 8)
Expand Down Expand Up @@ -131,6 +139,10 @@ describe('--embed UI', function()
{1:~ }|*4
{2:-- INSERT --} |
]]

if not is_os('win') then
assert_log('Failed to get flags on descriptor 3: Bad file descriptor', testlog)
end
end)

it('can pass stdin to -q - #17523', function()
Expand Down

0 comments on commit ffe3002

Please sign in to comment.