mirror of
https://github.com/neovim/neovim.git
synced 2026-01-04 10:26:42 +10:00
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.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user