mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
test: helpers.execute() => helpers.feed_command()
This commit is contained in:
parent
dab3f86d09
commit
119f0ca854
@ -1,8 +1,8 @@
|
|||||||
-- Test for benchmarking RE engine.
|
-- Test for benchmarking RE engine.
|
||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local insert, source = helpers.insert, helpers.source
|
local insert, source = helpers.insert, helpers.source
|
||||||
local clear, execute, wait = helpers.clear, helpers.execute, helpers.wait
|
local clear, command = helpers.clear, helpers.command
|
||||||
|
|
||||||
-- Temporary file for gathering benchmarking results for each regexp engine.
|
-- Temporary file for gathering benchmarking results for each regexp engine.
|
||||||
local result_file = 'benchmark.out'
|
local result_file = 'benchmark.out'
|
||||||
@ -31,7 +31,7 @@ describe('regexp search', function()
|
|||||||
clear()
|
clear()
|
||||||
source(measure_script)
|
source(measure_script)
|
||||||
insert('" Benchmark_results:')
|
insert('" Benchmark_results:')
|
||||||
execute('write! ' .. result_file)
|
command('write! ' .. result_file)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- At the end of the test run we just print the contents of the result file
|
-- At the end of the test run we just print the contents of the result file
|
||||||
@ -46,22 +46,19 @@ describe('regexp search', function()
|
|||||||
|
|
||||||
it('is working with regexpengine=0', function()
|
it('is working with regexpengine=0', function()
|
||||||
local regexpengine = 0
|
local regexpengine = 0
|
||||||
execute(string.format(measure_cmd, regexpengine))
|
command(string.format(measure_cmd, regexpengine))
|
||||||
execute('write')
|
command('write')
|
||||||
wait()
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('is working with regexpengine=1', function()
|
it('is working with regexpengine=1', function()
|
||||||
local regexpengine = 1
|
local regexpengine = 1
|
||||||
execute(string.format(measure_cmd, regexpengine))
|
command(string.format(measure_cmd, regexpengine))
|
||||||
execute('write')
|
command('write')
|
||||||
wait()
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('is working with regexpengine=2', function()
|
it('is working with regexpengine=2', function()
|
||||||
local regexpengine = 2
|
local regexpengine = 2
|
||||||
execute(string.format(measure_cmd, regexpengine))
|
command(string.format(measure_cmd, regexpengine))
|
||||||
execute('write')
|
command('write')
|
||||||
wait()
|
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local clear, insert, eq = helpers.clear, helpers.insert, helpers.eq
|
local clear, insert, eq = helpers.clear, helpers.insert, helpers.eq
|
||||||
local execute, expect = helpers.execute, helpers.expect
|
local command, expect = helpers.command, helpers.expect
|
||||||
local feed, eval = helpers.feed, helpers.eval
|
local feed, eval = helpers.feed, helpers.eval
|
||||||
local exc_exec = helpers.exc_exec
|
local exc_exec = helpers.exc_exec
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ describe('gu and gU', function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
execute('lang ctype tr_TR.UTF-8')
|
command('lang ctype tr_TR.UTF-8')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('with default casemap', function()
|
it('with default casemap', function()
|
||||||
@ -46,7 +46,7 @@ describe('gu and gU', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('with casemap=""', function()
|
it('with casemap=""', function()
|
||||||
execute('set casemap=')
|
command('set casemap=')
|
||||||
-- expect Turkish locale behavior
|
-- expect Turkish locale behavior
|
||||||
insert("iI")
|
insert("iI")
|
||||||
feed("VgU")
|
feed("VgU")
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local Screen = require('test.functional.ui.screen')
|
local Screen = require('test.functional.ui.screen')
|
||||||
local clear = helpers.clear
|
local clear = helpers.clear
|
||||||
|
local command = helpers.command
|
||||||
local curbufmeths = helpers.curbufmeths
|
local curbufmeths = helpers.curbufmeths
|
||||||
local eq = helpers.eq
|
local eq = helpers.eq
|
||||||
local eval = helpers.eval
|
local eval = helpers.eval
|
||||||
@ -21,9 +22,9 @@ local default_text = [[
|
|||||||
|
|
||||||
local function common_setup(screen, inccommand, text)
|
local function common_setup(screen, inccommand, text)
|
||||||
if screen then
|
if screen then
|
||||||
feed_command("syntax on")
|
command("syntax on")
|
||||||
feed_command("set nohlsearch")
|
command("set nohlsearch")
|
||||||
feed_command("hi Substitute guifg=red guibg=yellow")
|
command("hi Substitute guifg=red guibg=yellow")
|
||||||
screen:attach()
|
screen:attach()
|
||||||
screen:set_default_attr_ids({
|
screen:set_default_attr_ids({
|
||||||
[1] = {foreground = Screen.colors.Fuchsia},
|
[1] = {foreground = Screen.colors.Fuchsia},
|
||||||
@ -46,7 +47,7 @@ local function common_setup(screen, inccommand, text)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
feed_command("set inccommand=" .. (inccommand and inccommand or ""))
|
command("set inccommand=" .. (inccommand and inccommand or ""))
|
||||||
|
|
||||||
if text then
|
if text then
|
||||||
insert(text)
|
insert(text)
|
||||||
@ -456,7 +457,7 @@ describe(":substitute, 'inccommand' preserves undo", function()
|
|||||||
insert("X")
|
insert("X")
|
||||||
feed("IY<esc>")
|
feed("IY<esc>")
|
||||||
feed(":%s/tw/MO/<esc>")
|
feed(":%s/tw/MO/<esc>")
|
||||||
-- execute("undo") here would cause "Press ENTER".
|
-- feed_command("undo") here would cause "Press ENTER".
|
||||||
feed("u")
|
feed("u")
|
||||||
expect(default_text:gsub("Inc", "XInc"))
|
expect(default_text:gsub("Inc", "XInc"))
|
||||||
feed("u")
|
feed("u")
|
||||||
@ -514,7 +515,7 @@ describe(":substitute, 'inccommand' preserves undo", function()
|
|||||||
feed("Ay<esc>")
|
feed("Ay<esc>")
|
||||||
feed("Az<esc>")
|
feed("Az<esc>")
|
||||||
feed(":%s/tw/AR<esc>")
|
feed(":%s/tw/AR<esc>")
|
||||||
-- using execute("undo") here will result in a "Press ENTER" prompt
|
-- feed_command("undo") here would cause "Press ENTER".
|
||||||
feed("u")
|
feed("u")
|
||||||
expect(default_text:gsub("lines", "linesxy"))
|
expect(default_text:gsub("lines", "linesxy"))
|
||||||
feed("u")
|
feed("u")
|
||||||
@ -603,7 +604,7 @@ describe(":substitute, 'inccommand' preserves undo", function()
|
|||||||
|
|
||||||
feed_command("set undolevels=-1")
|
feed_command("set undolevels=-1")
|
||||||
feed(":%s/tw/MO/g<enter>")
|
feed(":%s/tw/MO/g<enter>")
|
||||||
-- using execute("undo") here will result in a "Press ENTER" prompt
|
-- feed_command("undo") here will result in a "Press ENTER" prompt
|
||||||
feed("u")
|
feed("u")
|
||||||
if case == "split" then
|
if case == "split" then
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
@ -804,7 +805,6 @@ describe(":substitute, inccommand=split", function()
|
|||||||
it('does not show split window for :s/', function()
|
it('does not show split window for :s/', function()
|
||||||
feed("2gg")
|
feed("2gg")
|
||||||
feed(":s/tw")
|
feed(":s/tw")
|
||||||
wait()
|
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
Inc substitution on |
|
Inc substitution on |
|
||||||
two lines |
|
two lines |
|
||||||
@ -1291,14 +1291,14 @@ describe("'inccommand' and :cnoremap", function()
|
|||||||
it('work with remapped characters', function()
|
it('work with remapped characters', function()
|
||||||
for _, case in pairs(cases) do
|
for _, case in pairs(cases) do
|
||||||
refresh(case)
|
refresh(case)
|
||||||
local command = "%s/lines/LINES/g"
|
local cmd = "%s/lines/LINES/g"
|
||||||
|
|
||||||
for i = 1, string.len(command) do
|
for i = 1, string.len(cmd) do
|
||||||
local c = string.sub(command, i, i)
|
local c = string.sub(cmd, i, i)
|
||||||
feed_command("cnoremap ".. c .. " " .. c)
|
feed_command("cnoremap ".. c .. " " .. c)
|
||||||
end
|
end
|
||||||
|
|
||||||
feed_command(command)
|
feed_command(cmd)
|
||||||
expect([[
|
expect([[
|
||||||
Inc substitution on
|
Inc substitution on
|
||||||
two LINES
|
two LINES
|
||||||
|
@ -284,18 +284,13 @@ function Screen:wait(check, timeout)
|
|||||||
|
|
||||||
if failure_after_success then
|
if failure_after_success then
|
||||||
print([[
|
print([[
|
||||||
Warning: Screen changes have been received after the expected state was seen.
|
|
||||||
This is probably due to an indeterminism in the test. Try adding
|
|
||||||
`wait()` (or even a separate `screen:expect(...)`) at a point of possible
|
|
||||||
indeterminism, typically in between a `feed()` or `execute()` which is non-
|
|
||||||
synchronous, and a synchronous api call.
|
|
||||||
|
|
||||||
Note that sometimes a `wait` can trigger redraws and consequently generate more
|
Warning: Screen changes were received after the expected state. This indicates
|
||||||
indeterminism. If adding `wait` calls seems to increase the frequency of these
|
indeterminism in the test. Try adding wait() (or screen:expect(...)) between
|
||||||
messages, try removing every `wait` call in the test.
|
asynchronous (feed(), nvim_input()) and synchronous API calls.
|
||||||
|
- Use Screen:redraw_debug() to investigate the problem.
|
||||||
If everything else fails, use Screen:redraw_debug to help investigate what is
|
- wait() can trigger redraws and consequently generate more indeterminism.
|
||||||
causing the problem.
|
In that case try removing every wait().
|
||||||
]])
|
]])
|
||||||
local tb = debug.traceback()
|
local tb = debug.traceback()
|
||||||
local index = string.find(tb, '\n%s*%[C]')
|
local index = string.find(tb, '\n%s*%[C]')
|
||||||
|
Loading…
Reference in New Issue
Block a user