From 35f2bb05a5cb84af405a094f040b92461a824e61 Mon Sep 17 00:00:00 2001 From: bfredl Date: Tue, 26 Mar 2024 21:23:36 +0100 Subject: refactor(tests): use new global defaults instead of set_default_attr_ids This will be done in batches. --- test/functional/ui/input_spec.lua | 59 +++++++++++++++------------------------ 1 file changed, 22 insertions(+), 37 deletions(-) (limited to 'test/functional/ui/input_spec.lua') diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua index b2899bf82d..348be7af6a 100644 --- a/test/functional/ui/input_spec.lua +++ b/test/functional/ui/input_spec.lua @@ -280,21 +280,16 @@ end) it('typing a simplifiable key at hit-enter prompt triggers mapping vim-patch:8.2.0839', function() local screen = Screen.new(60, 8) - screen:set_default_attr_ids({ - [1] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [2] = { bold = true, reverse = true }, -- MsgSeparator - [3] = { bold = true, foreground = Screen.colors.SeaGreen }, -- MoreMsg - }) screen:attach() command([[nnoremap echo 'hit ctrl-6']]) feed_command('ls') screen:expect([[ | {1:~ }|*3 - {2: }| + {3: }| :ls | 1 %a "[No Name]" line 1 | - {3:Press ENTER or type command to continue}^ | + {6:Press ENTER or type command to continue}^ | ]]) feed('') screen:expect([[ @@ -331,12 +326,6 @@ describe('input non-printable chars', function() it("doesn't crash when echoing them back", function() write_file('Xtest-overwrite', [[foobar]]) local screen = Screen.new(60, 8) - screen:set_default_attr_ids { - [1] = { bold = true, foreground = Screen.colors.Blue1 }, - [2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, - [3] = { bold = true, foreground = Screen.colors.SeaGreen4 }, - [4] = { bold = true, reverse = true }, - } screen:attach() command('set shortmess-=F') @@ -354,45 +343,45 @@ describe('input non-printable chars', function() screen:expect([[ foobar | {1:~ }|*3 - {4: }| + {3: }| "Xtest-overwrite" | - {2:WARNING: The file has been changed since reading it!!!} | - {3:Do you really want to write to it (y/n)?}^ | + {9:WARNING: The file has been changed since reading it!!!} | + {6:Do you really want to write to it (y/n)?}^ | ]]) feed('u') screen:expect([[ foobar | {1:~ }|*2 - {4: }| + {3: }| "Xtest-overwrite" | - {2:WARNING: The file has been changed since reading it!!!} | - {3:Do you really want to write to it (y/n)?}u | - {3:Do you really want to write to it (y/n)?}^ | + {9:WARNING: The file has been changed since reading it!!!} | + {6:Do you really want to write to it (y/n)?}u | + {6:Do you really want to write to it (y/n)?}^ | ]]) feed('\005') screen:expect([[ foobar | {1:~ }| - {4: }| + {3: }| "Xtest-overwrite" | - {2:WARNING: The file has been changed since reading it!!!} | - {3:Do you really want to write to it (y/n)?}u | - {3:Do you really want to write to it (y/n)?} | - {3:Do you really want to write to it (y/n)?}^ | + {9:WARNING: The file has been changed since reading it!!!} | + {6:Do you really want to write to it (y/n)?}u | + {6:Do you really want to write to it (y/n)?} | + {6:Do you really want to write to it (y/n)?}^ | ]]) feed('n') screen:expect([[ foobar | - {4: }| + {3: }| "Xtest-overwrite" | - {2:WARNING: The file has been changed since reading it!!!} | - {3:Do you really want to write to it (y/n)?}u | - {3:Do you really want to write to it (y/n)?} | - {3:Do you really want to write to it (y/n)?}n | - {3:Press ENTER or type command to continue}^ | + {9:WARNING: The file has been changed since reading it!!!} | + {6:Do you really want to write to it (y/n)?}u | + {6:Do you really want to write to it (y/n)?} | + {6:Do you really want to write to it (y/n)?}n | + {6:Press ENTER or type command to continue}^ | ]]) feed('') @@ -437,10 +426,6 @@ describe('display is updated', function() local screen before_each(function() screen = Screen.new(60, 8) - screen:set_default_attr_ids({ - [1] = { bold = true, foreground = Screen.colors.Blue1 }, -- NonText - [2] = { bold = true }, -- ModeMsg - }) screen:attach() end) @@ -452,7 +437,7 @@ describe('display is updated', function() abc | ^ | {1:~ }|*5 - {2:-- INSERT --} | + {5:-- INSERT --} | ]]) end) @@ -464,7 +449,7 @@ describe('display is updated', function() abc | ^ | {1:~ }|*5 - {2:-- INSERT --} | + {5:-- INSERT --} | ]]) end) end) -- cgit From 5581a90e20777a2493ca9835b11a67435287d64e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 6 Apr 2024 08:59:50 +0800 Subject: test: reduce sleep for file timestamp change (#28196) Now that Nvim always supports nanotime, sleeping for some milliseconds is enough. --- test/functional/ui/input_spec.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/functional/ui/input_spec.lua') diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua index 348be7af6a..9c18127875 100644 --- a/test/functional/ui/input_spec.lua +++ b/test/functional/ui/input_spec.lua @@ -336,8 +336,8 @@ describe('input non-printable chars', function() "Xtest-overwrite" [noeol] 1L, 6B | ]]) - -- The timestamp is in second resolution, wait two seconds to be sure. - screen:sleep(2000) + -- Wait for some time so that the timestamp changes. + vim.uv.sleep(10) write_file('Xtest-overwrite', [[smurf]]) feed_command('w') screen:expect([[ -- cgit From 7035125b2b26aa68fcfb7cda39377ac79926a0f9 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 8 Apr 2024 11:03:20 +0200 Subject: test: improve test conventions Work on https://github.com/neovim/neovim/issues/27004. --- test/functional/ui/input_spec.lua | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'test/functional/ui/input_spec.lua') diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua index 9c18127875..5d2ebb8c2e 100644 --- a/test/functional/ui/input_spec.lua +++ b/test/functional/ui/input_spec.lua @@ -1,14 +1,14 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear, feed_command = helpers.clear, helpers.feed_command -local feed, next_msg, eq = helpers.feed, helpers.next_msg, helpers.eq -local command = helpers.command -local expect = helpers.expect -local curbuf_contents = helpers.curbuf_contents -local api = helpers.api -local exec_lua = helpers.exec_lua -local write_file = helpers.write_file -local fn = helpers.fn -local eval = helpers.eval +local t = require('test.functional.testutil')(after_each) +local clear, feed_command = t.clear, t.feed_command +local feed, next_msg, eq = t.feed, t.next_msg, t.eq +local command = t.command +local expect = t.expect +local curbuf_contents = t.curbuf_contents +local api = t.api +local exec_lua = t.exec_lua +local write_file = t.write_file +local fn = t.fn +local eval = t.eval local Screen = require('test.functional.ui.screen') before_each(clear) -- cgit From 81fc27124b9e1b375e0ce9605ae69c3c2a2d9222 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Tue, 9 Apr 2024 12:26:16 +0100 Subject: refactor(test): inject after_each differently --- test/functional/ui/input_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/ui/input_spec.lua') diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua index 5d2ebb8c2e..8becaf918b 100644 --- a/test/functional/ui/input_spec.lua +++ b/test/functional/ui/input_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local clear, feed_command = t.clear, t.feed_command local feed, next_msg, eq = t.feed, t.next_msg, t.eq local command = t.command -- cgit From 052498ed42780a76daea589d063cd8947a894673 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sat, 20 Apr 2024 17:44:13 +0200 Subject: test: improve test conventions Specifically, functions that are run in the context of the test runner are put in module `test/testutil.lua` while the functions that are run in the context of the test session are put in `test/functional/testnvim.lua`. Closes https://github.com/neovim/neovim/issues/27004. --- test/functional/ui/input_spec.lua | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'test/functional/ui/input_spec.lua') diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua index 8becaf918b..f377939458 100644 --- a/test/functional/ui/input_spec.lua +++ b/test/functional/ui/input_spec.lua @@ -1,16 +1,18 @@ -local t = require('test.functional.testutil')() -local clear, feed_command = t.clear, t.feed_command -local feed, next_msg, eq = t.feed, t.next_msg, t.eq -local command = t.command -local expect = t.expect -local curbuf_contents = t.curbuf_contents -local api = t.api -local exec_lua = t.exec_lua -local write_file = t.write_file -local fn = t.fn -local eval = t.eval +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') +local clear, feed_command = n.clear, n.feed_command +local feed, next_msg, eq = n.feed, n.next_msg, t.eq +local command = n.command +local expect = n.expect +local curbuf_contents = n.curbuf_contents +local api = n.api +local exec_lua = n.exec_lua +local write_file = t.write_file +local fn = n.fn +local eval = n.eval + before_each(clear) describe('mappings', function() -- cgit