test: helpers.execute() => helpers.feed_command()

This commit is contained in:
Justin M. Keyes 2017-04-10 21:54:19 +02:00
parent dab3f86d09
commit 119f0ca854
4 changed files with 30 additions and 38 deletions

View File

@ -1,8 +1,8 @@
-- 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 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.
local result_file = 'benchmark.out'
@ -31,7 +31,7 @@ describe('regexp search', function()
clear()
source(measure_script)
insert('" Benchmark_results:')
execute('write! ' .. result_file)
command('write! ' .. result_file)
end)
-- 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()
local regexpengine = 0
execute(string.format(measure_cmd, regexpengine))
execute('write')
wait()
command(string.format(measure_cmd, regexpengine))
command('write')
end)
it('is working with regexpengine=1', function()
local regexpengine = 1
execute(string.format(measure_cmd, regexpengine))
execute('write')
wait()
command(string.format(measure_cmd, regexpengine))
command('write')
end)
it('is working with regexpengine=2', function()
local regexpengine = 2
execute(string.format(measure_cmd, regexpengine))
execute('write')
wait()
command(string.format(measure_cmd, regexpengine))
command('write')
end)
end)

View File

@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
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 exc_exec = helpers.exc_exec
@ -32,7 +32,7 @@ describe('gu and gU', function()
end
before_each(function()
execute('lang ctype tr_TR.UTF-8')
command('lang ctype tr_TR.UTF-8')
end)
it('with default casemap', function()
@ -46,7 +46,7 @@ describe('gu and gU', function()
end)
it('with casemap=""', function()
execute('set casemap=')
command('set casemap=')
-- expect Turkish locale behavior
insert("iI")
feed("VgU")

View File

@ -1,6 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
local command = helpers.command
local curbufmeths = helpers.curbufmeths
local eq = helpers.eq
local eval = helpers.eval
@ -21,9 +22,9 @@ local default_text = [[
local function common_setup(screen, inccommand, text)
if screen then
feed_command("syntax on")
feed_command("set nohlsearch")
feed_command("hi Substitute guifg=red guibg=yellow")
command("syntax on")
command("set nohlsearch")
command("hi Substitute guifg=red guibg=yellow")
screen:attach()
screen:set_default_attr_ids({
[1] = {foreground = Screen.colors.Fuchsia},
@ -46,7 +47,7 @@ local function common_setup(screen, inccommand, text)
})
end
feed_command("set inccommand=" .. (inccommand and inccommand or ""))
command("set inccommand=" .. (inccommand and inccommand or ""))
if text then
insert(text)
@ -456,7 +457,7 @@ describe(":substitute, 'inccommand' preserves undo", function()
insert("X")
feed("IY<esc>")
feed(":%s/tw/MO/<esc>")
-- execute("undo") here would cause "Press ENTER".
-- feed_command("undo") here would cause "Press ENTER".
feed("u")
expect(default_text:gsub("Inc", "XInc"))
feed("u")
@ -514,7 +515,7 @@ describe(":substitute, 'inccommand' preserves undo", function()
feed("Ay<esc>")
feed("Az<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")
expect(default_text:gsub("lines", "linesxy"))
feed("u")
@ -603,7 +604,7 @@ describe(":substitute, 'inccommand' preserves undo", function()
feed_command("set undolevels=-1")
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")
if case == "split" then
screen:expect([[
@ -804,7 +805,6 @@ describe(":substitute, inccommand=split", function()
it('does not show split window for :s/', function()
feed("2gg")
feed(":s/tw")
wait()
screen:expect([[
Inc substitution on |
two lines |
@ -1291,14 +1291,14 @@ describe("'inccommand' and :cnoremap", function()
it('work with remapped characters', function()
for _, case in pairs(cases) do
refresh(case)
local command = "%s/lines/LINES/g"
local cmd = "%s/lines/LINES/g"
for i = 1, string.len(command) do
local c = string.sub(command, i, i)
for i = 1, string.len(cmd) do
local c = string.sub(cmd, i, i)
feed_command("cnoremap ".. c .. " " .. c)
end
feed_command(command)
feed_command(cmd)
expect([[
Inc substitution on
two LINES

View File

@ -284,18 +284,13 @@ function Screen:wait(check, timeout)
if failure_after_success then
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
indeterminism. If adding `wait` calls seems to increase the frequency of these
messages, try removing every `wait` call in the test.
If everything else fails, use Screen:redraw_debug to help investigate what is
causing the problem.
Warning: Screen changes were received after the expected state. This indicates
indeterminism in the test. Try adding wait() (or screen:expect(...)) between
asynchronous (feed(), nvim_input()) and synchronous API calls.
- Use Screen:redraw_debug() to investigate the problem.
- wait() can trigger redraws and consequently generate more indeterminism.
In that case try removing every wait().
]])
local tb = debug.traceback()
local index = string.find(tb, '\n%s*%[C]')