mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00

Note some bugs were judged to have too ugly a fix to solve, tests to demonstrate these problems, and the explanation behind not fixing them are below. describe('register . problems', function() before_each(reset) -- The difficulty here is: The basic requirement is that the text -- inserted is treated as if it were typed in insert mode. This is why -- the paste method is to enter insert mode and enter the ". register -- into readbuf1. -- We can't add a count into the readbuf here because the insert mode -- count is implemented with readbuf2 which is checked for characters -- after readbuf1. -- Hence, the ".gp command (which adds extra characters into readbuf1 -- to emulate leaving the cursor after the text by moving the cursor -- after inserting the text) would insert the motion characters into -- the buffer instead of using them to move after the insert has been -- done. -- I could probably get this working properly with a special flag put -- into start_redo_ins() and set in do_put(), but I think this adds -- much more complexity than fixing this bug justifies. pending('should not change the ". register with ".2p', function() local orig_register = funcs.getreg('.') feed('2".p') eq(orig_register, funcs.getreg('.')) end) describe("cursor positioning after undo and redo with '.'", function() before_each(reset) local function make_cursor_test(macro_string) return function() feed(macro_string) local afterpos = funcs.getcurpos() local orig_string = curbuf_contents() feed('u.') eq(afterpos, funcs.getcurpos()) expect(orig_string) end end -- The difficulty here is: setting the cursor after the end of the -- pasted text is done by adding a motion command to the -- stuffbuffer after the insert. -- Modifying 'redobuff' is done in the code that handles inserting -- text and moving around. -- I could add a special case in ins_esc() that checks for a flag -- set in do_put() to add the motion character to the redo buffer, -- but I think that is starting to get way too convoluted for the -- benefit. pending('should be the same after ".gp and ".gpu.', make_cursor_test('".gp')) -- The difficulty here is: putting forwards is implemented by using -- 'a' instead of 'i' to start insert. -- Undoing with 'u' an insert that began with 'a' leaves the cursor -- where the first character was inserted, not where the cursor was -- when the 'a' was pressed. -- We account for this the first time by saving the cursor position -- in do_put(), but this isn't stored in redobuff for a second time -- around. -- We can't change how such a fundamental action as undo after -- inserting with 'a' behaves, we could add in a special case -- whereby we set a flag in do_put() and read it when entering -- insert mode but this seems like way too much to fix such a minor -- bug. pending('should be the same after ".pu. and ".pu.u.', make_cursor_test('".pu.')) end) end)
121 lines
3.0 KiB
Lua
121 lines
3.0 KiB
Lua
local assert = require('luassert')
|
|
local lfs = require('lfs')
|
|
|
|
local check_logs_useless_lines = {
|
|
['Warning: noted but unhandled ioctl']=1,
|
|
['could cause spurious value errors to appear']=2,
|
|
['See README_MISSING_SYSCALL_OR_IOCTL for guidance']=3,
|
|
}
|
|
|
|
local eq = function(exp, act)
|
|
return assert.are.same(exp, act)
|
|
end
|
|
local neq = function(exp, act)
|
|
return assert.are_not.same(exp, act)
|
|
end
|
|
local ok = function(res)
|
|
return assert.is_true(res)
|
|
end
|
|
|
|
local function check_logs()
|
|
local log_dir = os.getenv('LOG_DIR')
|
|
local runtime_errors = 0
|
|
if log_dir and lfs.attributes(log_dir, 'mode') == 'directory' then
|
|
for tail in lfs.dir(log_dir) do
|
|
if tail:sub(1, 30) == 'valgrind-' or tail:find('san%.') then
|
|
local file = log_dir .. '/' .. tail
|
|
local fd = io.open(file)
|
|
local start_msg = ('='):rep(20) .. ' File ' .. file .. ' ' .. ('='):rep(20)
|
|
local lines = {}
|
|
local warning_line = 0
|
|
for line in fd:lines() do
|
|
local cur_warning_line = check_logs_useless_lines[line]
|
|
if cur_warning_line == warning_line + 1 then
|
|
warning_line = cur_warning_line
|
|
else
|
|
lines[#lines + 1] = line
|
|
end
|
|
end
|
|
fd:close()
|
|
os.remove(file)
|
|
if #lines > 0 then
|
|
-- local out = os.getenv('TRAVIS_CI_BUILD') and io.stdout or io.stderr
|
|
local out = io.stdout
|
|
out:write(start_msg .. '\n')
|
|
out:write('= ' .. table.concat(lines, '\n= ') .. '\n')
|
|
out:write(select(1, start_msg:gsub('.', '=')) .. '\n')
|
|
runtime_errors = runtime_errors + 1
|
|
end
|
|
end
|
|
end
|
|
end
|
|
assert(0 == runtime_errors)
|
|
end
|
|
|
|
-- Tries to get platform name from $SYSTEM_NAME, uname; fallback is "Windows".
|
|
local uname = (function()
|
|
local platform = nil
|
|
return (function()
|
|
if platform then
|
|
return platform
|
|
end
|
|
|
|
platform = os.getenv("SYSTEM_NAME")
|
|
if platform then
|
|
return platform
|
|
end
|
|
|
|
local status, f = pcall(io.popen, "uname -s")
|
|
if status then
|
|
platform = f:read("*l")
|
|
else
|
|
platform = 'Windows'
|
|
end
|
|
return platform
|
|
end)
|
|
end)()
|
|
|
|
local function tmpname()
|
|
local fname = os.tmpname()
|
|
if uname() == 'Windows' and fname:sub(1, 2) == '\\s' then
|
|
-- In Windows tmpname() returns a filename starting with
|
|
-- special sequence \s, prepend $TEMP path
|
|
local tmpdir = os.getenv('TEMP')
|
|
return tmpdir..fname
|
|
elseif fname:match('^/tmp') and uname() == 'Darwin' then
|
|
-- In OS X /tmp links to /private/tmp
|
|
return '/private'..fname
|
|
else
|
|
return fname
|
|
end
|
|
end
|
|
|
|
local function map(func, tab)
|
|
local rettab = {}
|
|
for k, v in pairs(tab) do
|
|
rettab[k] = func(v)
|
|
end
|
|
return rettab
|
|
end
|
|
|
|
local function filter(filter_func, tab)
|
|
local rettab = {}
|
|
for _, entry in pairs(tab) do
|
|
if filter_func(entry) then
|
|
table.insert(rettab, entry)
|
|
end
|
|
end
|
|
return rettab
|
|
end
|
|
|
|
return {
|
|
eq = eq,
|
|
neq = neq,
|
|
ok = ok,
|
|
check_logs = check_logs,
|
|
uname = uname,
|
|
tmpname = tmpname,
|
|
map = map,
|
|
filter = filter,
|
|
}
|