From e016f5bee6293d126fde9e8d75a3f02f882e2c81 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Tue, 2 Apr 2024 15:45:19 +0200 Subject: test: reduce `exec_lua` calls `exec_lua` makes code slighly harder to read, so it's beneficial to remove it in cases where it's possible or convenient. Not all `exec_lua` calls should be removed even if the test passes as it changes the semantics of the test even if it happens to pass. From https://github.com/neovim/neovim/pull/28155#discussion_r1548185779: "Note for tests like this, which fundamentally are about conversion, you end up changing what conversion you are testing. Even if the result happens to be same (as they often are, as we like the rules to be consistent if possible), you are now testing the RPC conversion rules instead of the vim script to in-process lua conversion rules." From https://github.com/neovim/neovim/pull/28155#discussion_r1548190152: "A test like this specifies that the cursor is valid immediately and not after a separate cycle of normal (or an other input-processing) mode." --- test/functional/lua/version_spec.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test/functional/lua/version_spec.lua') diff --git a/test/functional/lua/version_spec.lua b/test/functional/lua/version_spec.lua index 3bc9e26d41..9f953daa9e 100644 --- a/test/functional/lua/version_spec.lua +++ b/test/functional/lua/version_spec.lua @@ -5,6 +5,7 @@ local ok = helpers.ok local exec_lua = helpers.exec_lua local matches = helpers.matches local pcall_err = helpers.pcall_err +local fn = helpers.fn local function v(ver) return vim.version._version(ver) @@ -17,7 +18,7 @@ describe('version', function() end) it('version() returns Nvim version', function() - local expected = exec_lua('return vim.fn.api_info().version') + local expected = fn.api_info().version local actual = exec_lua('return vim.version()') eq(expected.major, actual.major) eq(expected.minor, actual.minor) -- 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/lua/version_spec.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'test/functional/lua/version_spec.lua') diff --git a/test/functional/lua/version_spec.lua b/test/functional/lua/version_spec.lua index 9f953daa9e..6f25aa3711 100644 --- a/test/functional/lua/version_spec.lua +++ b/test/functional/lua/version_spec.lua @@ -1,11 +1,11 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local eq = helpers.eq -local ok = helpers.ok -local exec_lua = helpers.exec_lua -local matches = helpers.matches -local pcall_err = helpers.pcall_err -local fn = helpers.fn +local t = require('test.functional.testutil')(after_each) +local clear = t.clear +local eq = t.eq +local ok = t.ok +local exec_lua = t.exec_lua +local matches = t.matches +local pcall_err = t.pcall_err +local fn = t.fn local function v(ver) return vim.version._version(ver) -- 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/lua/version_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/lua/version_spec.lua') diff --git a/test/functional/lua/version_spec.lua b/test/functional/lua/version_spec.lua index 6f25aa3711..ca275f6738 100644 --- a/test/functional/lua/version_spec.lua +++ b/test/functional/lua/version_spec.lua @@ -1,4 +1,4 @@ -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local clear = t.clear local eq = t.eq local ok = t.ok -- 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/lua/version_spec.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'test/functional/lua/version_spec.lua') diff --git a/test/functional/lua/version_spec.lua b/test/functional/lua/version_spec.lua index ca275f6738..4ce8fb8dfe 100644 --- a/test/functional/lua/version_spec.lua +++ b/test/functional/lua/version_spec.lua @@ -1,11 +1,13 @@ -local t = require('test.functional.testutil')() -local clear = t.clear +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear local eq = t.eq local ok = t.ok -local exec_lua = t.exec_lua +local exec_lua = n.exec_lua local matches = t.matches local pcall_err = t.pcall_err -local fn = t.fn +local fn = n.fn local function v(ver) return vim.version._version(ver) -- cgit