From 7c091348af0ea3e0f6e05b5f387a972b418bfd9b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 16 Jul 2026 19:36:13 +0800 Subject: [PATCH] test(api/ui_spec): fix flaky test (#40767) The poke_eventloop() and screen:expect() sometimes don't run the test runner's event loop long enough for the data to arrive at the reading end of the pipe. Use a screen:expect_unchanged() so that the event loop can run a bit longer. FAILED ...ovim/build/Xtest_xdg_api/test/functional/api/ui_spec.lua @ 105: nvim_ui_send works with stdout_tty Expected values to be equal. Expected: "\27]11;?\7Hello world" Actual: "\27]11;?\7" stack traceback: ...ovim/build/Xtest_xdg_api/test/functional/api/ui_spec.lua:138: in function <...ovim/build/Xtest_xdg_api/test/functional/api/ui_spec.lua:105> --- test/functional/api/ui_spec.lua | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/test/functional/api/ui_spec.lua b/test/functional/api/ui_spec.lua index 6ecddaffa1..40403aa2e6 100644 --- a/test/functional/api/ui_spec.lua +++ b/test/functional/api/ui_spec.lua @@ -11,7 +11,6 @@ local exec_lua = n.exec_lua local feed = n.feed local api = n.api local request = n.request -local poke_eventloop = n.poke_eventloop local pcall_err = t.pcall_err local uv = vim.uv @@ -123,16 +122,16 @@ describe('nvim_ui_send', function() close_pipe(read_pipe) end) - api.nvim_ui_send('Hello world') - - poke_eventloop() - screen:expect([[ ^ | {1:~ }|*8 | ]]) + api.nvim_ui_send('Hello world') + + screen:expect_unchanged() + -- The TUI client queries OSC 11 on connect, so that precedes the payload. local bg_request = '\027]11;?\007' eq(bg_request .. 'Hello world', table.concat(read_data)) @@ -159,16 +158,16 @@ describe('nvim_ui_send', function() close_pipe(read_pipe) end) - api.nvim_ui_send('Hello world') - - poke_eventloop() - screen:expect([[ ^ | {1:~ }|*8 | ]]) + api.nvim_ui_send('Hello world') + + screen:expect_unchanged() + eq('', table.concat(read_data)) end) end)