diff options
| author | dundargoc <gocdundar@gmail.com> | 2024-04-20 17:44:13 +0200 |
|---|---|---|
| committer | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2024-04-23 18:17:04 +0200 |
| commit | 052498ed42780a76daea589d063cd8947a894673 (patch) | |
| tree | b6c85416a4d7ced5eabb0a7a3866f5e0fee886cc /test/benchmark | |
| parent | c5af5c0b9ab84c86f84e32210512923e7eb641ba (diff) | |
| download | rneovim-052498ed42780a76daea589d063cd8947a894673.tar.gz rneovim-052498ed42780a76daea589d063cd8947a894673.tar.bz2 rneovim-052498ed42780a76daea589d063cd8947a894673.zip | |
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.
Diffstat (limited to 'test/benchmark')
| -rw-r--r-- | test/benchmark/autocmd_spec.lua | 6 | ||||
| -rw-r--r-- | test/benchmark/bench_regexp_spec.lua | 7 | ||||
| -rw-r--r-- | test/benchmark/preload.lua | 2 | ||||
| -rw-r--r-- | test/benchmark/screenpos_spec.lua | 14 | ||||
| -rw-r--r-- | test/benchmark/treesitter_spec.lua | 8 |
5 files changed, 20 insertions, 17 deletions
diff --git a/test/benchmark/autocmd_spec.lua b/test/benchmark/autocmd_spec.lua index 19660723e0..af5fa1c258 100644 --- a/test/benchmark/autocmd_spec.lua +++ b/test/benchmark/autocmd_spec.lua @@ -1,7 +1,7 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() -local clear = t.clear -local exec_lua = t.exec_lua +local clear = n.clear +local exec_lua = n.exec_lua local N = 7500 diff --git a/test/benchmark/bench_regexp_spec.lua b/test/benchmark/bench_regexp_spec.lua index 4a2d01130a..2c2b8dc359 100644 --- a/test/benchmark/bench_regexp_spec.lua +++ b/test/benchmark/bench_regexp_spec.lua @@ -1,8 +1,9 @@ -- Test for benchmarking the RE engine. -local t = require('test.functional.testutil')() -local insert, source = t.insert, t.source -local clear, command = t.clear, t.command +local n = require('test.functional.testnvim')() + +local insert, source = n.insert, n.source +local clear, command = n.clear, n.command -- Temporary file for gathering benchmarking results for each regexp engine. local result_file = 'benchmark.out' diff --git a/test/benchmark/preload.lua b/test/benchmark/preload.lua index 9e24b5cdf1..a7b815ddf8 100644 --- a/test/benchmark/preload.lua +++ b/test/benchmark/preload.lua @@ -1,4 +1,4 @@ -- Modules loaded here will not be cleared and reloaded by Busted. -- Busted started doing this to help provide more isolation. See issue #62 -- for more information about this. -local t = require('test.functional.testutil') +local n = require('test.functional.testnvim') diff --git a/test/benchmark/screenpos_spec.lua b/test/benchmark/screenpos_spec.lua index a05c8909f5..d9d4a70628 100644 --- a/test/benchmark/screenpos_spec.lua +++ b/test/benchmark/screenpos_spec.lua @@ -1,7 +1,9 @@ -local t = require('test.functional.testutil')() -local api = t.api +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') +local api = n.api + local function rand_utf8(count, seed) math.randomseed(seed) local symbols = { 'i', 'À', 'Ⱡ', '𐀀' } @@ -119,7 +121,7 @@ end local function benchmarks(benchmark_results) describe('screenpos() perf', function() - before_each(t.clear) + before_each(n.clear) -- no breakindent for li, lines_type in ipairs(benchmark_lines) do @@ -134,7 +136,7 @@ local function benchmarks(benchmark_results) screen:attach() api.nvim_buf_set_lines(0, 0, 1, false, lines) -- for smaller screen expect (last line always different, first line same as others) - t.feed('G$') + n.feed('G$') screen:expect(result.screen) benchmark(lines, result.value) end) @@ -153,9 +155,9 @@ local function benchmarks(benchmark_results) local screen = Screen.new(width, height + 1) screen:attach() api.nvim_buf_set_lines(0, 0, 1, false, lines) - t.command('set breakindent') + n.command('set breakindent') -- for smaller screen expect (last line always different, first line same as others) - t.feed('G$') + n.feed('G$') screen:expect(result.screen) benchmark(lines, result.value) end) diff --git a/test/benchmark/treesitter_spec.lua b/test/benchmark/treesitter_spec.lua index 74c2e9ec8e..b13b0fd9da 100644 --- a/test/benchmark/treesitter_spec.lua +++ b/test/benchmark/treesitter_spec.lua @@ -1,7 +1,7 @@ -local t = require('test.functional.testutil')() +local n = require('test.functional.testnvim')() -local clear = t.clear -local exec_lua = t.exec_lua +local clear = n.clear +local exec_lua = n.exec_lua describe('treesitter perf', function() setup(function() @@ -9,7 +9,7 @@ describe('treesitter perf', function() end) it('can handle large folds', function() - t.command 'edit ./src/nvim/eval.c' + n.command 'edit ./src/nvim/eval.c' exec_lua [[ local parser = vim.treesitter.get_parser(0, "c", {}) vim.treesitter.highlighter.new(parser) |