From a7bbda121d035d050b449b4dc63bd6ae027e248d Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 25 Mar 2024 19:06:28 +0000 Subject: fix(test): typing --- test/functional/plugin/editorconfig_spec.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/functional/plugin/editorconfig_spec.lua') diff --git a/test/functional/plugin/editorconfig_spec.lua b/test/functional/plugin/editorconfig_spec.lua index 115c28fbf6..c8151d2005 100644 --- a/test/functional/plugin/editorconfig_spec.lua +++ b/test/functional/plugin/editorconfig_spec.lua @@ -9,6 +9,8 @@ local exec_lua = helpers.exec_lua local testdir = 'Xtest-editorconfig' +--- @param name string +--- @param expected table local function test_case(name, expected) local filename = testdir .. pathsep .. name command('edit ' .. filename) -- 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/plugin/editorconfig_spec.lua | 30 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'test/functional/plugin/editorconfig_spec.lua') diff --git a/test/functional/plugin/editorconfig_spec.lua b/test/functional/plugin/editorconfig_spec.lua index c8151d2005..cd524373da 100644 --- a/test/functional/plugin/editorconfig_spec.lua +++ b/test/functional/plugin/editorconfig_spec.lua @@ -1,11 +1,11 @@ -local helpers = require('test.functional.helpers')(after_each) -local clear = helpers.clear -local command = helpers.command -local eq = helpers.eq -local pathsep = helpers.get_pathsep() -local fn = helpers.fn -local api = helpers.api -local exec_lua = helpers.exec_lua +local t = require('test.functional.testutil')(after_each) +local clear = t.clear +local command = t.command +local eq = t.eq +local pathsep = t.get_pathsep() +local fn = t.fn +local api = t.api +local exec_lua = t.exec_lua local testdir = 'Xtest-editorconfig' @@ -20,8 +20,8 @@ local function test_case(name, expected) end setup(function() - helpers.mkdir_p(testdir) - helpers.write_file( + t.mkdir_p(testdir) + t.write_file( testdir .. pathsep .. '.editorconfig', [[ root = true @@ -96,7 +96,7 @@ setup(function() end) teardown(function() - helpers.rmdir(testdir) + t.rmdir(testdir) end) describe('editorconfig', function() @@ -178,18 +178,18 @@ But not this one -- luacheck: pop local trimmed = untrimmed:gsub('%s+\n', '\n') - helpers.write_file(filename, untrimmed) + t.write_file(filename, untrimmed) command('edit ' .. filename) command('write') command('bdelete') - eq(trimmed, helpers.read_file(filename)) + eq(trimmed, t.read_file(filename)) filename = testdir .. pathsep .. 'no_trim.txt' - helpers.write_file(filename, untrimmed) + t.write_file(filename, untrimmed) command('edit ' .. filename) command('write') command('bdelete') - eq(untrimmed, helpers.read_file(filename)) + eq(untrimmed, t.read_file(filename)) end) it('sets textwidth', function() -- 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/plugin/editorconfig_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/plugin/editorconfig_spec.lua') diff --git a/test/functional/plugin/editorconfig_spec.lua b/test/functional/plugin/editorconfig_spec.lua index cd524373da..d108f325e1 100644 --- a/test/functional/plugin/editorconfig_spec.lua +++ b/test/functional/plugin/editorconfig_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 command = t.command local eq = t.eq -- 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/plugin/editorconfig_spec.lua | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'test/functional/plugin/editorconfig_spec.lua') diff --git a/test/functional/plugin/editorconfig_spec.lua b/test/functional/plugin/editorconfig_spec.lua index d108f325e1..839a723405 100644 --- a/test/functional/plugin/editorconfig_spec.lua +++ b/test/functional/plugin/editorconfig_spec.lua @@ -1,11 +1,13 @@ -local t = require('test.functional.testutil')() -local clear = t.clear -local command = t.command +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local clear = n.clear +local command = n.command local eq = t.eq -local pathsep = t.get_pathsep() -local fn = t.fn -local api = t.api -local exec_lua = t.exec_lua +local pathsep = n.get_pathsep() +local fn = n.fn +local api = n.api +local exec_lua = n.exec_lua local testdir = 'Xtest-editorconfig' @@ -20,7 +22,7 @@ local function test_case(name, expected) end setup(function() - t.mkdir_p(testdir) + n.mkdir_p(testdir) t.write_file( testdir .. pathsep .. '.editorconfig', [[ @@ -96,7 +98,7 @@ setup(function() end) teardown(function() - t.rmdir(testdir) + n.rmdir(testdir) end) describe('editorconfig', function() -- cgit