From bc272cc36f1ee65d8aa6cc9f98e3fb8f2d75ff0a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 31 Mar 2026 08:54:53 +0800 Subject: [PATCH] test(tui_spec): unskip a few more tests on Windows (#38618) --- test/functional/terminal/tui_spec.lua | 55 ++++++++++----------------- test/functional/testterm.lua | 17 ++++++--- 2 files changed, 31 insertions(+), 41 deletions(-) diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index 6189b1c88d..e442bced27 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -136,18 +136,16 @@ describe('TUI :detach', function() '--cmd', nvim_set .. ' laststatus=2 background=dark', }, job_opts) + tt.override_screen_expect_for_conpty(screen) tt.feed_data('iHello, World') - tt.screen_expect( - screen, - [[ + screen:expect([[ Hello, World^ | {100:~ }|*3 {3:[No Name] [+] }| {5:-- INSERT --} | {5:-- TERMINAL --} | - ]] - ) + ]]) local child_session = n.connect(child_server) finally(function() @@ -196,16 +194,13 @@ describe('TUI :detach', function() child_server, }, job_opts) - tt.screen_expect( - screen_reattached, - [[ + screen_reattached:expect([[ We did it, pooky^. | {100:~ }|*3 {3:[No Name] [+] }| | {5:-- TERMINAL --} | - ]] - ) + ]]) end) end) @@ -236,10 +231,6 @@ describe('TUI :restart', function() -- 'echo getpid()', }, { env = env_notermguicolors }) - local function screen_expect(s) - tt.screen_expect(screen, s) - end - -- The value of has("gui_running") should be 0 before and after :restart. local function assert_no_gui_running() tt.feed_data(':echo "GUI Running: " .. has("gui_running")\013') @@ -288,13 +279,13 @@ describe('TUI :restart', function() tt.feed_data(':set nomodified\013') -- Command is run on new server. tt.feed_data(":restart put ='Hello1'\013") - screen_expect(s1) + screen:expect(s1) assert_new_pid() assert_no_gui_running() -- Complex command following +cmd. tt.feed_data(":restart +qall! put ='Hello2' | put ='World2'\013") - screen_expect([[ + screen:expect([[ | Hello2 | ^World2 | @@ -309,13 +300,13 @@ describe('TUI :restart', function() -- Check ":restart" on an unmodified buffer. tt.feed_data(':set nomodified\013') tt.feed_data(':restart\013') - screen_expect(s0) + screen:expect(s0) assert_new_pid() assert_no_gui_running() -- Check ":restart +qall!" on an unmodified buffer. tt.feed_data(':restart +qall!\013') - screen_expect(s0) + screen:expect(s0) assert_new_pid() assert_no_gui_running() @@ -324,13 +315,7 @@ describe('TUI :restart', function() screen:expect({ any = vim.pesc('+cmd did not quit the server') }) tt.feed_data('ithis will be removed\027') - screen_expect([[ - this will be remove^d | - {100:~ }|*3 - {3:[No Name] [+] }| - | - {5:-- TERMINAL --} | - ]]) + screen:expect({ any = vim.pesc('this will be remove^d') }) -- Check ":confirm restart" on a modified buffer. tt.feed_data(':confirm restart\013') @@ -368,18 +353,18 @@ describe('TUI :restart', function() -- Check ":restart +qall!" on a modified buffer. tt.feed_data('ithis will be removed\027') tt.feed_data(':restart +qall!\013') - screen_expect(s0) + screen:expect(s0) assert_new_pid() assert_no_gui_running() -- No --listen conflict when server exit is delayed. feed_data(':lua vim.schedule(function() vim.wait(100) end); vim.cmd.restart()\n') - screen_expect(s0) + screen:expect(s0) assert_new_pid() assert_no_gui_running() screen:try_resize(60, 6) - screen_expect([[ + screen:expect([[ ^ | {100:~ }|*2 {3:[No Name] }| @@ -389,7 +374,7 @@ describe('TUI :restart', function() --- Check that ":restart" uses the updated size after terminal resize. tt.feed_data(':restart echo "restarted"\013') - screen_expect([[ + screen:expect([[ ^ | {100:~ }|*2 {3:[No Name] }| @@ -750,7 +735,7 @@ describe('TUI', function() end) it('accepts resize while pager is active', function() - t.skip(is_os('win'), 'FIXME: some spaces have wrong attrs on Windows') + tt.override_screen_expect_for_conpty(screen) child_session:request( 'nvim_exec2', [[ @@ -2035,7 +2020,7 @@ describe('TUI', function() end) it("paste: 'nomodifiable' buffer", function() - t.skip(is_os('win'), 'FIXME: some spaces have wrong attrs on Windows') + tt.override_screen_expect_for_conpty(screen) child_exec_lua([[ vim.bo.modifiable = false -- Truncate the error message to hide the line number @@ -2246,7 +2231,7 @@ describe('TUI', function() end) it('allows termguicolors to be set at runtime', function() - t.skip(is_os('win'), 'FIXME: some spaces have wrong attrs on Windows') + tt.override_screen_expect_for_conpty(screen) screen:set_option('rgb', true) feed_data(':hi SpecialKey ctermfg=3 guifg=SeaGreen\n') feed_data('i') @@ -2436,7 +2421,7 @@ describe('TUI', function() end) it('allows grid to assume wider ambiwidth chars than host terminal', function() - t.skip(is_os('win'), 'FIXME: some spaces have wrong attrs on Windows') + tt.override_screen_expect_for_conpty(screen) child_session:request( 'nvim_buf_set_lines', 0, @@ -2481,7 +2466,7 @@ describe('TUI', function() end) it('allows grid to assume wider non-ambiwidth chars than host terminal', function() - t.skip(is_os('win'), 'FIXME: some spaces have wrong attrs on Windows') + tt.override_screen_expect_for_conpty(screen) child_session:request( 'nvim_buf_set_lines', 0, @@ -3418,7 +3403,7 @@ describe('TUI FocusGained/FocusLost', function() end) it('in hit-enter prompt', function() - t.skip(is_os('win'), 'FIXME: some spaces have wrong attrs on Windows') + tt.override_screen_expect_for_conpty(screen) feed_data(":echom 'msg1'|echom 'msg2'|echom 'msg3'|echom 'msg4'|echom 'msg5'\n") screen:expect([[ msg1 | diff --git a/test/functional/testterm.lua b/test/functional/testterm.lua index f7e7df6080..e73e1feb71 100644 --- a/test/functional/testterm.lua +++ b/test/functional/testterm.lua @@ -214,13 +214,18 @@ end --- Remove this function when that's fixed. --- --- @param screen test.functional.ui.screen ---- @param s string -function M.screen_expect(screen, s) - if t.is_os('win') then - s = s:gsub(' *%} +%|\n', '{MATCH: *}}{MATCH: *}|\n') - s = s:gsub('%}%^ +%|\n', '{MATCH:[ ^]*}}{MATCH:[ ^]*}|\n') +function M.override_screen_expect_for_conpty(screen) + if not t.is_os('win') then + return + end + local orig_screen_expect = screen.expect + function screen.expect(self, expected, attr_ids, ...) + if type(expected) == 'string' then + expected = expected:gsub(' *%} +%|\n', '{MATCH: *}}{MATCH: *}|\n') + expected = expected:gsub('%}%^ +%|\n', '{MATCH:[ ^]*}}{MATCH:[ ^]*}|\n') + end + orig_screen_expect(self, expected, attr_ids, ...) end - screen:expect(s) end --- Asserts that the exit code of chan eventually matches the expected exit code