From 8df682250768be9a07f855bb89ada665b7626413 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 31 Oct 2024 08:04:51 +0800 Subject: test: fix files being left behind (#31004) --- test/functional/core/log_spec.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'test/functional/core') diff --git a/test/functional/core/log_spec.lua b/test/functional/core/log_spec.lua index a952730779..57dfd6364c 100644 --- a/test/functional/core/log_spec.lua +++ b/test/functional/core/log_spec.lua @@ -15,6 +15,7 @@ describe('log', function() after_each(function() expect_exit(command, 'qa!') + vim.uv.sleep(10) -- Wait for Nvim to fully exit os.remove(testlog) end) -- cgit From 17e00d0cc63cf2a42a66b03f28bd567f11998c24 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 13 Nov 2024 13:22:40 +0800 Subject: fix(startup): report --startuptime error to stderr (#31131) Problem: Crash when initializing for --startuptime errors. Solution: Report the error to stderr, as neither logging nor messages have been initialized yet. --- test/functional/core/startup_spec.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/functional/core') diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua index f48bcb9360..7f99a4a2eb 100644 --- a/test/functional/core/startup_spec.lua +++ b/test/functional/core/startup_spec.lua @@ -74,6 +74,25 @@ describe('startup', function() assert_log("require%('vim%._editor'%)", testfile, 100) end) + it('--startuptime does not crash on error #31125', function() + eq( + "E484: Can't open file .", + fn.system({ + nvim_prog, + '-u', + 'NONE', + '-i', + 'NONE', + '--headless', + '--startuptime', + '.', + '-c', + '42cquit', + }) + ) + eq(42, api.nvim_get_vvar('shell_error')) + end) + it('-D does not hang #12647', function() clear() local screen -- cgit From e61228a214ebda9845db9462dad0a8c362d3963f Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 11 Nov 2024 22:15:19 +0100 Subject: fix(tests): needing two calls to setup a screen is cringe Before calling "attach" a screen object is just a dummy container for (row, col) values whose purpose is to be sent as part of the "attach" function call anyway. Just create the screen in an attached state directly. Keep the complete (row, col, options) config together. It is still completely valid to later detach and re-attach as needed, including to another session. --- test/functional/core/fileio_spec.lua | 2 -- test/functional/core/job_spec.lua | 4 ---- test/functional/core/main_spec.lua | 1 - test/functional/core/startup_spec.lua | 14 +------------- 4 files changed, 1 insertion(+), 20 deletions(-) (limited to 'test/functional/core') diff --git a/test/functional/core/fileio_spec.lua b/test/functional/core/fileio_spec.lua index d33710a63d..cf9715f848 100644 --- a/test/functional/core/fileio_spec.lua +++ b/test/functional/core/fileio_spec.lua @@ -59,7 +59,6 @@ describe('fileio', function() local screen_nvim = spawn(argv) set_session(screen_nvim) local screen = Screen.new(70, 10) - screen:attach() screen:set_default_attr_ids({ [1] = { foreground = Screen.colors.NvimDarkGrey4 }, [2] = { background = Screen.colors.NvimDarkGrey1, foreground = Screen.colors.NvimLightGrey3 }, @@ -276,7 +275,6 @@ describe('fileio', function() write_file('Xtest-overwrite-forced', 'foobar') command('set nofixendofline') local screen = Screen.new(40, 4) - screen:attach() command('set shortmess-=F') command('e Xtest-overwrite-forced') diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua index 68ac0a50f6..618c294566 100644 --- a/test/functional/core/job_spec.lua +++ b/test/functional/core/job_spec.lua @@ -498,7 +498,6 @@ describe('jobs', function() it('can redefine callbacks being used by a job', function() local screen = Screen.new() - screen:attach() screen:set_default_attr_ids({ [1] = { bold = true, foreground = Screen.colors.Blue }, }) @@ -524,7 +523,6 @@ describe('jobs', function() it('requires funcrefs for script-local (s:) functions', function() local screen = Screen.new(60, 5) - screen:attach() screen:set_default_attr_ids({ [1] = { bold = true, foreground = Screen.colors.Blue1 }, [2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, @@ -910,7 +908,6 @@ describe('jobs', function() it('hides cursor and flushes messages before blocking', function() local screen = Screen.new(50, 6) - screen:attach() command([[let g:id = jobstart([v:progpath, '--clean', '--headless'])]]) source([[ func PrintAndWait() @@ -1223,7 +1220,6 @@ describe('pty process teardown', function() before_each(function() clear() screen = Screen.new(30, 6) - screen:attach() screen:expect([[ ^ | {1:~ }|*4 diff --git a/test/functional/core/main_spec.lua b/test/functional/core/main_spec.lua index a6e917b4b2..a445423efc 100644 --- a/test/functional/core/main_spec.lua +++ b/test/functional/core/main_spec.lua @@ -89,7 +89,6 @@ describe('command-line option', function() it('does not crash after reading from stdin in non-headless mode', function() skip(is_os('win')) local screen = Screen.new(40, 8) - screen:attach() local args = { nvim_prog_abs(), '-u', diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua index 7f99a4a2eb..e885164c20 100644 --- a/test/functional/core/startup_spec.lua +++ b/test/functional/core/startup_spec.lua @@ -55,7 +55,6 @@ describe('startup', function() clear() local screen screen = Screen.new(84, 3) - screen:attach() fn.termopen({ nvim_prog, '-u', 'NONE', '--server', eval('v:servername'), '--remote-ui' }) screen:expect([[ ^Cannot attach UI of :terminal child to its parent. (Unset $NVIM to skip this check) | @@ -97,7 +96,6 @@ describe('startup', function() clear() local screen screen = Screen.new(60, 7) - screen:attach() -- not the same colors on windows for some reason screen._default_attr_ids = nil local id = fn.termopen({ @@ -346,7 +344,6 @@ describe('startup', function() it('with --embed: has("ttyin")==0 has("ttyout")==0', function() local screen = Screen.new(25, 3) -- Remote UI connected by --embed. - screen:attach() -- TODO: a lot of tests in this file already use the new default color scheme. -- once we do the batch update of tests to use it, remove this workarond screen._default_attr_ids = nil @@ -360,7 +357,6 @@ describe('startup', function() it('in a TTY: has("ttyin")==1 has("ttyout")==1', function() local screen = Screen.new(25, 4) - screen:attach() screen._default_attr_ids = nil if is_os('win') then command([[set shellcmdflag=/s\ /c shellxquote=\"]]) @@ -455,7 +451,6 @@ describe('startup', function() 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 if is_os('win') then command([[set shellcmdflag=/s\ /c shellxquote=\"]]) @@ -620,7 +615,6 @@ describe('startup', function() it('ENTER dismisses early message #7967', function() local screen screen = Screen.new(60, 6) - screen:attach() screen._default_attr_ids = nil local id = fn.termopen({ nvim_prog, @@ -718,7 +712,6 @@ describe('startup', function() it('-e/-E interactive #7679', function() clear('-e') local screen = Screen.new(25, 3) - screen:attach() feed("put ='from -e'") screen:expect([[ :put ='from -e' | @@ -728,7 +721,6 @@ describe('startup', function() clear('-E') screen = Screen.new(25, 3) - screen:attach() feed("put ='from -E'") screen:expect([[ :put ='from -E' | @@ -738,9 +730,8 @@ describe('startup', function() end) it('-e sets ex mode', function() - local screen = Screen.new(25, 3) clear('-e') - screen:attach() + local screen = Screen.new(25, 3) -- Verify we set the proper mode both before and after :vi. feed('put =mode(1)vi:put =mode(1)') screen:expect([[ @@ -792,7 +783,6 @@ describe('startup', function() it("sets 'shortmess' when loading other tabs", function() clear({ args = { '-p', 'a', 'b', 'c' } }) local screen = Screen.new(25, 4) - screen:attach() screen:expect({ grid = [[ {1: a }{2: b c }{3: }{2:X}| @@ -1155,7 +1145,6 @@ describe('user config init', function() eq('---', eval('g:exrc_file')) local screen = Screen.new(50, 8) - screen:attach() screen._default_attr_ids = nil fn.termopen({ nvim_prog }, { env = { @@ -1431,7 +1420,6 @@ describe('inccommand on ex mode', function() clear() local screen screen = Screen.new(60, 10) - screen:attach() local id = fn.termopen({ nvim_prog, '-u', -- cgit From e025f5a5b30a1ef92e88fed0f0c548d2240d30c0 Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Sun, 17 Nov 2024 19:21:50 +0100 Subject: fix(messages): proper multiline Lua print() messages #31205 Problem: Separate message emitted for each newline present in Lua print() arguments. Solution: Make msg_multiline() handle NUL bytes. Refactor print() to use msg_multiline(). Refactor vim.print() to use print(). --- test/functional/core/startup_spec.lua | 2 -- 1 file changed, 2 deletions(-) (limited to 'test/functional/core') diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua index e885164c20..7062211187 100644 --- a/test/functional/core/startup_spec.lua +++ b/test/functional/core/startup_spec.lua @@ -277,10 +277,8 @@ describe('startup', function() -- nvim -l foo.lua assert_l_out( - -- luacheck: ignore 611 (Line contains only whitespaces) [[ wrap - bufs: nvim args: 7 lua args: { "-c", "set wrap?", -- cgit