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/vimscript/eval_spec.lua | 50 ++++++++++++++++----------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'test/functional/vimscript/eval_spec.lua') diff --git a/test/functional/vimscript/eval_spec.lua b/test/functional/vimscript/eval_spec.lua index e337959810..0918c5957a 100644 --- a/test/functional/vimscript/eval_spec.lua +++ b/test/functional/vimscript/eval_spec.lua @@ -9,37 +9,37 @@ -- test/functional/vimscript/_spec.lua -- test/functional/vimscript/functions_spec.lua -local helpers = require('test.functional.helpers')(after_each) +local t = require('test.functional.testutil')(after_each) local Screen = require('test.functional.ui.screen') -local mkdir = helpers.mkdir -local clear = helpers.clear -local eq = helpers.eq -local exec = helpers.exec -local exc_exec = helpers.exc_exec -local exec_lua = helpers.exec_lua -local exec_capture = helpers.exec_capture -local eval = helpers.eval -local command = helpers.command -local write_file = helpers.write_file -local api = helpers.api +local mkdir = t.mkdir +local clear = t.clear +local eq = t.eq +local exec = t.exec +local exc_exec = t.exc_exec +local exec_lua = t.exec_lua +local exec_capture = t.exec_capture +local eval = t.eval +local command = t.command +local write_file = t.write_file +local api = t.api local sleep = vim.uv.sleep -local matches = helpers.matches -local pcall_err = helpers.pcall_err -local assert_alive = helpers.assert_alive -local poke_eventloop = helpers.poke_eventloop -local feed = helpers.feed -local expect_exit = helpers.expect_exit +local matches = t.matches +local pcall_err = t.pcall_err +local assert_alive = t.assert_alive +local poke_eventloop = t.poke_eventloop +local feed = t.feed +local expect_exit = t.expect_exit describe('Up to MAX_FUNC_ARGS arguments are handled by', function() local max_func_args = 20 -- from eval.h - local range = helpers.fn.range + local range = t.fn.range before_each(clear) it('printf()', function() - local printf = helpers.fn.printf - local rep = helpers.fn['repeat'] + local printf = t.fn.printf + local rep = t.fn['repeat'] local expected = '2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,' eq(expected, printf(rep('%d,', max_func_args - 1), unpack(range(2, max_func_args)))) local ret = exc_exec('call printf("", 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21)') @@ -47,7 +47,7 @@ describe('Up to MAX_FUNC_ARGS arguments are handled by', function() end) it('rpcnotify()', function() - local rpcnotify = helpers.fn.rpcnotify + local rpcnotify = t.fn.rpcnotify local ret = rpcnotify(0, 'foo', unpack(range(3, max_func_args))) eq(1, ret) ret = exc_exec('call rpcnotify(0, "foo", 3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21)') @@ -69,17 +69,17 @@ describe('backtick expansion', function() end) teardown(function() - helpers.rmdir('test-backticks') + t.rmdir('test-backticks') end) it("with default 'shell'", function() - if helpers.is_os('win') then + if t.is_os('win') then command(':silent args `dir /b *2`') else command(':silent args `echo ***2`') end eq({ 'file2' }, eval('argv()')) - if helpers.is_os('win') then + if t.is_os('win') then command(':silent args `dir /s/b *4`') eq({ 'subdir\\file4' }, eval('map(argv(), \'fnamemodify(v:val, ":.")\')')) else -- 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/vimscript/eval_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/vimscript/eval_spec.lua') diff --git a/test/functional/vimscript/eval_spec.lua b/test/functional/vimscript/eval_spec.lua index 0918c5957a..b7c0803ef7 100644 --- a/test/functional/vimscript/eval_spec.lua +++ b/test/functional/vimscript/eval_spec.lua @@ -9,7 +9,7 @@ -- test/functional/vimscript/_spec.lua -- test/functional/vimscript/functions_spec.lua -local t = require('test.functional.testutil')(after_each) +local t = require('test.functional.testutil')() local Screen = require('test.functional.ui.screen') local mkdir = t.mkdir -- 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/vimscript/eval_spec.lua | 37 +++++++++++++++++---------------- 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'test/functional/vimscript/eval_spec.lua') diff --git a/test/functional/vimscript/eval_spec.lua b/test/functional/vimscript/eval_spec.lua index b7c0803ef7..0c812d968e 100644 --- a/test/functional/vimscript/eval_spec.lua +++ b/test/functional/vimscript/eval_spec.lua @@ -9,37 +9,38 @@ -- test/functional/vimscript/_spec.lua -- test/functional/vimscript/functions_spec.lua -local t = require('test.functional.testutil')() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') local mkdir = t.mkdir -local clear = t.clear +local clear = n.clear local eq = t.eq -local exec = t.exec -local exc_exec = t.exc_exec -local exec_lua = t.exec_lua -local exec_capture = t.exec_capture -local eval = t.eval -local command = t.command +local exec = n.exec +local exc_exec = n.exc_exec +local exec_lua = n.exec_lua +local exec_capture = n.exec_capture +local eval = n.eval +local command = n.command local write_file = t.write_file -local api = t.api +local api = n.api local sleep = vim.uv.sleep local matches = t.matches local pcall_err = t.pcall_err -local assert_alive = t.assert_alive -local poke_eventloop = t.poke_eventloop -local feed = t.feed -local expect_exit = t.expect_exit +local assert_alive = n.assert_alive +local poke_eventloop = n.poke_eventloop +local feed = n.feed +local expect_exit = n.expect_exit describe('Up to MAX_FUNC_ARGS arguments are handled by', function() local max_func_args = 20 -- from eval.h - local range = t.fn.range + local range = n.fn.range before_each(clear) it('printf()', function() - local printf = t.fn.printf - local rep = t.fn['repeat'] + local printf = n.fn.printf + local rep = n.fn['repeat'] local expected = '2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,' eq(expected, printf(rep('%d,', max_func_args - 1), unpack(range(2, max_func_args)))) local ret = exc_exec('call printf("", 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21)') @@ -47,7 +48,7 @@ describe('Up to MAX_FUNC_ARGS arguments are handled by', function() end) it('rpcnotify()', function() - local rpcnotify = t.fn.rpcnotify + local rpcnotify = n.fn.rpcnotify local ret = rpcnotify(0, 'foo', unpack(range(3, max_func_args))) eq(1, ret) ret = exc_exec('call rpcnotify(0, "foo", 3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21)') @@ -69,7 +70,7 @@ describe('backtick expansion', function() end) teardown(function() - t.rmdir('test-backticks') + n.rmdir('test-backticks') end) it("with default 'shell'", function() -- cgit