mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
commit
337299c808
@ -7,7 +7,7 @@ build_script:
|
||||
- call ci\build.bat
|
||||
cache:
|
||||
- C:\msys64\var\cache\pacman\pkg -> ci\build.bat
|
||||
- .deps -> third-party/**
|
||||
- .deps -> third-party\**
|
||||
artifacts:
|
||||
- path: build/Neovim.zip
|
||||
- path: build/bin/nvim.exe
|
||||
|
@ -120,8 +120,10 @@
|
||||
/* mch_open_rw(): invoke os_open() with third argument for user R/W. */
|
||||
#if defined(UNIX) /* open in rw------- mode */
|
||||
# define mch_open_rw(n, f) os_open((n), (f), (mode_t)0600)
|
||||
#elif defined(WIN32)
|
||||
# define mch_open_rw(n, f) os_open((n), (f), S_IREAD | S_IWRITE)
|
||||
#else
|
||||
# define mch_open_rw(n, f) os_open((n), (f), 0)
|
||||
# define mch_open_rw(n, f) os_open((n), (f), 0)
|
||||
#endif
|
||||
|
||||
# define REPLACE_NORMAL(s) (((s) & REPLACE_FLAG) && !((s) & VREPLACE_FLAG))
|
||||
|
@ -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)
|
||||
|
35
test/functional/ex_cmds/file_spec.lua
Normal file
35
test/functional/ex_cmds/file_spec.lua
Normal file
@ -0,0 +1,35 @@
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local lfs = require('lfs')
|
||||
local clear = helpers.clear
|
||||
local command = helpers.command
|
||||
local eq = helpers.eq
|
||||
local funcs = helpers.funcs
|
||||
local rmdir = helpers.rmdir
|
||||
|
||||
describe(':file', function()
|
||||
local swapdir = lfs.currentdir()..'/Xtest-file_spec'
|
||||
before_each(function()
|
||||
clear()
|
||||
rmdir(swapdir)
|
||||
lfs.mkdir(swapdir)
|
||||
end)
|
||||
after_each(function()
|
||||
command('%bwipeout!')
|
||||
rmdir(swapdir)
|
||||
end)
|
||||
|
||||
it("rename does not lose swapfile #6487", function()
|
||||
local testfile = 'test-file_spec'
|
||||
local testfile_renamed = testfile..'-renamed'
|
||||
-- Note: `set swapfile` *must* go after `set directory`: otherwise it may
|
||||
-- attempt to create a swapfile in different directory.
|
||||
command('set directory^='..swapdir..'//')
|
||||
command('set swapfile fileformat=unix undolevels=-1')
|
||||
|
||||
command('edit! '..testfile)
|
||||
-- Before #6487 this gave "E301: Oops, lost the swap file !!!" on Windows.
|
||||
command('file '..testfile_renamed)
|
||||
eq(testfile_renamed..'.swp',
|
||||
string.match(funcs.execute('swapname'), '[^%%]+$'))
|
||||
end)
|
||||
end)
|
@ -1,12 +1,11 @@
|
||||
-- Tests for :recover
|
||||
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local lfs = require('lfs')
|
||||
local feed_command, eq, clear, eval, feed, expect, source =
|
||||
helpers.feed_command, helpers.eq, helpers.clear, helpers.eval, helpers.feed,
|
||||
helpers.expect, helpers.source
|
||||
|
||||
if helpers.pending_win32(pending) then return end
|
||||
local command = helpers.command
|
||||
local ok = helpers.ok
|
||||
local rmdir = helpers.rmdir
|
||||
|
||||
describe(':recover', function()
|
||||
before_each(clear)
|
||||
@ -23,30 +22,29 @@ describe(':preserve', function()
|
||||
local swapdir = lfs.currentdir()..'/testdir_recover_spec'
|
||||
before_each(function()
|
||||
clear()
|
||||
helpers.rmdir(swapdir)
|
||||
rmdir(swapdir)
|
||||
lfs.mkdir(swapdir)
|
||||
end)
|
||||
after_each(function()
|
||||
helpers.rmdir(swapdir)
|
||||
command('%bwipeout!')
|
||||
rmdir(swapdir)
|
||||
end)
|
||||
|
||||
it("saves to custom 'directory' and (R)ecovers (issue #1836)", function()
|
||||
local testfile = 'testfile_recover_spec'
|
||||
-- Put swapdir at the start of the 'directory' list. #1836
|
||||
-- Note: `set swapfile` *must* go after `set directory`: otherwise it may
|
||||
-- attempt to create a swapfile in different directory.
|
||||
local init = [[
|
||||
set directory^=]]..swapdir..[[//
|
||||
set directory^=]]..swapdir:gsub([[\]], [[\\]])..[[//
|
||||
set swapfile fileformat=unix undolevels=-1
|
||||
]]
|
||||
|
||||
source(init)
|
||||
feed_command('set swapfile fileformat=unix undolevels=-1')
|
||||
-- Put swapdir at the start of the 'directory' list. #1836
|
||||
feed_command('set directory^='..swapdir..'//')
|
||||
feed_command('edit '..testfile)
|
||||
command('edit! '..testfile)
|
||||
feed('isometext<esc>')
|
||||
feed_command('preserve')
|
||||
source('redir => g:swapname | swapname | redir END')
|
||||
command('preserve')
|
||||
source('redir => g:swapname | silent swapname | redir END')
|
||||
|
||||
local swappath1 = eval('g:swapname')
|
||||
|
||||
@ -59,19 +57,20 @@ describe(':preserve', function()
|
||||
source(init)
|
||||
|
||||
-- Use the "SwapExists" event to choose the (R)ecover choice at the dialog.
|
||||
feed_command('autocmd SwapExists * let v:swapchoice = "r"')
|
||||
feed_command('silent edit '..testfile)
|
||||
source('redir => g:swapname | swapname | redir END')
|
||||
command('autocmd SwapExists * let v:swapchoice = "r"')
|
||||
command('silent edit! '..testfile)
|
||||
source('redir => g:swapname | silent swapname | redir END')
|
||||
|
||||
local swappath2 = eval('g:swapname')
|
||||
|
||||
-- swapfile from session 1 should end in .swp
|
||||
assert(testfile..'.swp' == string.match(swappath1, '[^%%]+$'))
|
||||
|
||||
-- swapfile from session 2 should end in .swo
|
||||
assert(testfile..'.swo' == string.match(swappath2, '[^%%]+$'))
|
||||
|
||||
expect('sometext')
|
||||
-- swapfile from session 1 should end in .swp
|
||||
eq(testfile..'.swp', string.match(swappath1, '[^%%]+$'))
|
||||
-- swapfile from session 2 should end in .swo
|
||||
eq(testfile..'.swo', string.match(swappath2, '[^%%]+$'))
|
||||
-- Verify that :swapname was not truncated (:help 'shortmess').
|
||||
ok(nil == string.find(swappath1, '%.%.%.'))
|
||||
ok(nil == string.find(swappath2, '%.%.%.'))
|
||||
end)
|
||||
|
||||
end)
|
||||
|
@ -32,20 +32,15 @@ local nvim_set = 'set shortmess+=I background=light noswapfile noautoindent'
|
||||
..' belloff= noshowcmd noruler nomore'
|
||||
local nvim_argv = {nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N',
|
||||
'--cmd', nvim_set, '--embed'}
|
||||
|
||||
local mpack = require('mpack')
|
||||
|
||||
local tmpname = global_helpers.tmpname
|
||||
local uname = global_helpers.uname
|
||||
|
||||
-- Formulate a path to the directory containing nvim. We use this to
|
||||
-- help run test executables. It helps to keep the tests working, even
|
||||
-- when the build is not in the default location.
|
||||
-- Directory containing nvim.
|
||||
local nvim_dir = nvim_prog:gsub("[/\\][^/\\]+$", "")
|
||||
if nvim_dir == nvim_prog then
|
||||
nvim_dir = "."
|
||||
end
|
||||
|
||||
local mpack = require('mpack')
|
||||
local tmpname = global_helpers.tmpname
|
||||
local uname = global_helpers.uname
|
||||
local prepend_argv
|
||||
|
||||
if os.getenv('VALGRIND') then
|
||||
@ -430,21 +425,27 @@ end
|
||||
|
||||
local function do_rmdir(path)
|
||||
if lfs.attributes(path, 'mode') ~= 'directory' then
|
||||
return nil
|
||||
return -- Don't complain.
|
||||
end
|
||||
for file in lfs.dir(path) do
|
||||
if file ~= '.' and file ~= '..' then
|
||||
local abspath = path..'/'..file
|
||||
if lfs.attributes(abspath, 'mode') == 'directory' then
|
||||
local ret = do_rmdir(abspath) -- recurse
|
||||
if not ret then
|
||||
return nil
|
||||
end
|
||||
do_rmdir(abspath) -- recurse
|
||||
else
|
||||
local ret, err = os.remove(abspath)
|
||||
if not ret then
|
||||
error('os.remove: '..err)
|
||||
return nil
|
||||
if not session then
|
||||
error('os.remove: '..err)
|
||||
else
|
||||
-- Try Nvim delete(): it handles `readonly` attribute on Windows,
|
||||
-- and avoids Lua cross-version/platform incompatibilities.
|
||||
if -1 == nvim_call('delete', abspath) then
|
||||
local hint = (os_name() == 'windows'
|
||||
and ' (hint: try :%bwipeout! before rmdir())' or '')
|
||||
error('delete() failed'..hint..': '..abspath)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -453,7 +454,6 @@ local function do_rmdir(path)
|
||||
if not ret then
|
||||
error('lfs.rmdir('..path..'): '..err)
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
local function rmdir(path)
|
||||
|
@ -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")
|
||||
|
@ -5,6 +5,7 @@ local eq = helpers.eq
|
||||
local clear = helpers.clear
|
||||
local meths = helpers.meths
|
||||
local exc_exec = helpers.exc_exec
|
||||
local rmdir = helpers.rmdir
|
||||
local write_file = helpers.write_file
|
||||
|
||||
local testdir = 'Xtest-functional-spell-spellfile.d'
|
||||
@ -12,11 +13,12 @@ local testdir = 'Xtest-functional-spell-spellfile.d'
|
||||
describe('spellfile', function()
|
||||
before_each(function()
|
||||
clear()
|
||||
rmdir(testdir)
|
||||
lfs.mkdir(testdir)
|
||||
lfs.mkdir(testdir .. '/spell')
|
||||
end)
|
||||
after_each(function()
|
||||
lfs.rmdir(testdir)
|
||||
rmdir(testdir)
|
||||
end)
|
||||
-- ┌ Magic string (#VIMSPELLMAGIC)
|
||||
-- │ ┌ Spell file version (#VIMSPELLVERSION)
|
||||
|
@ -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
|
||||
|
@ -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]')
|
||||
|
Loading…
Reference in New Issue
Block a user