test: skip noisy "terminal mode unavailable" logs #36794

Problem:
Every CI log has a lot of noise at the end, which makes it harder to
find relevant test failures:

    Running tests from test/functional/terminal/tui_spec.lua
    ...
    T5831 TUI bg color queries the terminal for background color:
    T5832 TUI bg color triggers OptionSet from automatic background processing:
    T5833 TUI bg color sends theme update notifications when background changes #31652:
    ...
    Running tests from test/functional/ui/output_spec.lua
    ...
    WRN 2025-12-02T03:36:47.304 ui/c/T5831.28003.0 tui_handle_term_mode:223: TUI: terminal mode 2026 unavailable, state 0
    WRN 2025-12-02T03:36:47.359 ui/c/T5832.28006.0 tui_handle_term_mode:223: TUI: terminal mode 2048 unavailable, state 0
    WRN 2025-12-02T03:36:47.414 ui/c/T5833.28009.0 tui_handle_term_mode:223: TUI: terminal mode 2048 unavailable, state 0

Solution:
- Skip logging in test-mode.
    - This can be reverted later, when these logs are changed to "INFO"
      level, per this TODO comment:
      ```
      // TODO(bfredl): This is really ILOG but we want it in all builds.
      // add to show_verbose_terminfo() without being too racy ????
      WLOG("TUI: terminal mode %d unavailable, state %d", mode, state);
      ```
This commit is contained in:
Justin M. Keyes
2025-12-05 16:04:24 -05:00
committed by GitHub
parent 6aa80b1ab2
commit d6bee7e407
6 changed files with 28 additions and 18 deletions

View File

@@ -1,3 +1,4 @@
set(ENV{NVIM_TEST} "1")
# Set LC_ALL to meet expectations of some locale-sensitive tests.
set(ENV{LC_ALL} "en_US.UTF-8")
set(ENV{VIMRUNTIME} ${WORKING_DIR}/runtime)

View File

@@ -438,6 +438,8 @@ Number; !must be defined to function properly):
- `TEST_TIMEOUT` (FU) (I): specifies maximum time, in seconds, before the test
suite run is killed
- `NVIM_TEST` (FU) (D): lets Nvim process detect that it is running in a test.
- `NVIM_LUA_NOTRACK` (F) (D): disable reference counting of Lua objects
- `NVIM_PRG` (F) (S): path to Nvim executable (default: `build/bin/nvim`).

View File

@@ -41,6 +41,7 @@
#include "nvim/ugrid.h"
#include "nvim/ui_client.h"
#include "nvim/ui_defs.h"
#include "nvim/vim_defs.h"
#ifdef MSWIN
# include "nvim/os/os_win_console.h"
@@ -214,13 +215,20 @@ static void tui_set_term_mode(TUIData *tui, TermMode mode, bool set)
void tui_handle_term_mode(TUIData *tui, TermMode mode, TermModeState state)
FUNC_ATTR_NONNULL_ALL
{
static TriState is_test = kNone;
if (is_test == kNone) {
// XXX: Skip some logs which are noisy in CI. #33599
is_test = os_env_exists("NVIM_TEST", false);
}
bool is_set = false;
switch (state) {
case kTermModeNotRecognized:
case kTermModePermanentlyReset:
// TODO(bfredl): This is really ILOG but we want it in all builds.
// add to show_verbose_terminfo() without being too racy ????
WLOG("TUI: terminal mode %d unavailable, state %d", mode, state);
if (is_test == kFalse) {
WLOG("TUI: terminal mode %d unavailable, state %d", mode, state);
}
// If the mode is not recognized, or if the terminal emulator does not allow it to be changed,
// then there is nothing to do
break;
@@ -230,7 +238,9 @@ void tui_handle_term_mode(TUIData *tui, TermMode mode, TermModeState state)
FALLTHROUGH;
case kTermModeReset:
// The terminal supports changing the given mode
WLOG("TUI: terminal mode %d detected, state %d", mode, state);
if (is_test == kFalse) {
WLOG("TUI: terminal mode %d detected, state %d", mode, state);
}
switch (mode) {
case kTermModeSynchronizedOutput:
// Ref: https://gist.github.com/christianparpart/d8a62cc1ab659194337d73e399004036

View File

@@ -3159,8 +3159,7 @@ describe('TUI FocusGained/FocusLost', function()
end)
end)
-- These tests require `tt` because --headless/--embed
-- does not initialize the TUI.
-- These tests require `tt` because --headless/--embed does not initialize the TUI.
describe("TUI 't_Co' (terminal colors)", function()
local screen
@@ -3439,8 +3438,7 @@ describe("TUI 't_Co' (terminal colors)", function()
end)
end)
-- These tests require `tt` because --headless/--embed
-- does not initialize the TUI.
-- These tests require `tt` because --headless/--embed does not initialize the TUI.
describe("TUI 'term' option", function()
local screen
@@ -3491,8 +3489,7 @@ describe("TUI 'term' option", function()
end)
end)
-- These tests require `tt` because --headless/--embed
-- does not initialize the TUI.
-- These tests require `tt` because --headless/--embed does not initialize the TUI.
describe('TUI', function()
local screen

View File

@@ -610,21 +610,22 @@ function M._new_argv(...)
assert(type(v) == 'string')
env_opt[k] = v
end
-- Set these from the environment unless the caller defined them.
for _, k in ipairs({
'HOME',
'ASAN_OPTIONS',
'TSAN_OPTIONS',
'MSAN_OPTIONS',
'GCOV_ERROR_FILE',
'HOME',
'LD_LIBRARY_PATH',
'PATH',
'MSAN_OPTIONS',
'NVIM_TEST',
'NVIM_LOG_FILE',
'NVIM_RPLUGIN_MANIFEST',
'GCOV_ERROR_FILE',
'XDG_DATA_DIRS',
'PATH',
'TMPDIR',
'TSAN_OPTIONS',
'VIMRUNTIME',
'XDG_DATA_DIRS',
}) do
-- Set these from the environment unless the caller defined them.
if not env_opt[k] then
env_opt[k] = os.getenv(k)
end

View File

@@ -200,9 +200,8 @@ function M.setup_child_nvim(args, opts)
local argv = { nvim_prog, unpack(args or {}) }
local env = opts.env or {}
if not env.VIMRUNTIME then
env.VIMRUNTIME = os.getenv('VIMRUNTIME')
end
env.VIMRUNTIME = env.VIMRUNTIME or os.getenv('VIMRUNTIME')
env.NVIM_TEST = env.NVIM_TEST or os.getenv('NVIM_TEST')
return M.setup_screen(opts.extra_rows, argv, opts.cols, env)
end