mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge #5749 from justinmk/test-ctrl-c
This commit is contained in:
commit
0ce77a744a
62
test/functional/ex_cmds/ctrl_c_spec.lua
Normal file
62
test/functional/ex_cmds/ctrl_c_spec.lua
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
|
local Screen = require('test.functional.ui.screen')
|
||||||
|
local clear, feed, source = helpers.clear, helpers.feed, helpers.source
|
||||||
|
local execute = helpers.execute
|
||||||
|
|
||||||
|
if helpers.pending_win32(pending) then return end
|
||||||
|
|
||||||
|
describe("CTRL-C (mapped)", function()
|
||||||
|
before_each(function()
|
||||||
|
clear()
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("interrupts :global", function()
|
||||||
|
if helpers.skip_fragile(pending,
|
||||||
|
(os.getenv("TRAVIS") and os.getenv("CLANG_SANITIZER") == "ASAN_UBSAN"))
|
||||||
|
then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
source([[
|
||||||
|
set nomore nohlsearch undolevels=-1
|
||||||
|
nnoremap <C-C> <NOP>
|
||||||
|
]])
|
||||||
|
|
||||||
|
execute("silent edit! test/functional/fixtures/bigfile.txt")
|
||||||
|
local screen = Screen.new(52, 6)
|
||||||
|
screen:attach()
|
||||||
|
screen:set_default_attr_ids({
|
||||||
|
[0] = {foreground = Screen.colors.White,
|
||||||
|
background = Screen.colors.Red},
|
||||||
|
[1] = {bold = true,
|
||||||
|
foreground = Screen.colors.SeaGreen}
|
||||||
|
})
|
||||||
|
|
||||||
|
screen:expect([[
|
||||||
|
^0000;<control>;Cc;0;BN;;;;;N;NULL;;;; |
|
||||||
|
0001;<control>;Cc;0;BN;;;;;N;START OF HEADING;;;; |
|
||||||
|
0002;<control>;Cc;0;BN;;;;;N;START OF TEXT;;;; |
|
||||||
|
0003;<control>;Cc;0;BN;;;;;N;END OF TEXT;;;; |
|
||||||
|
0004;<control>;Cc;0;BN;;;;;N;END OF TRANSMISSION;;;;|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
|
||||||
|
local function test_ctrl_c(ms)
|
||||||
|
feed(":global/^/p<CR>")
|
||||||
|
helpers.sleep(ms)
|
||||||
|
feed("<C-C>")
|
||||||
|
screen:expect([[Interrupt]], nil, nil, nil, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- The test is time-sensitive. Try different sleep values.
|
||||||
|
local ms_values = {1, 10, 100}
|
||||||
|
for i, ms in ipairs(ms_values) do
|
||||||
|
if i < #ms_values then
|
||||||
|
local status, _ = pcall(test_ctrl_c, ms)
|
||||||
|
if status then break end
|
||||||
|
else -- Call the last attempt directly.
|
||||||
|
test_ctrl_c(ms)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
@ -1,74 +0,0 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
|
||||||
local Screen = require('test.functional.ui.screen')
|
|
||||||
local clear, feed, source = helpers.clear, helpers.feed, helpers.source
|
|
||||||
|
|
||||||
if helpers.pending_win32(pending) then return end
|
|
||||||
|
|
||||||
describe(':global', function()
|
|
||||||
before_each(function()
|
|
||||||
clear()
|
|
||||||
end)
|
|
||||||
|
|
||||||
it('is interrupted by mapped CTRL-C', function()
|
|
||||||
if os.getenv("TRAVIS") and os.getenv("CLANG_SANITIZER") == "ASAN_UBSAN" then
|
|
||||||
-- XXX: ASAN_UBSAN is too slow to react to the CTRL-C.
|
|
||||||
pending("", function() end)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
source([[
|
|
||||||
set nomore
|
|
||||||
set undolevels=-1
|
|
||||||
nnoremap <C-C> <NOP>
|
|
||||||
for i in range(0, 99999)
|
|
||||||
put ='XXX'
|
|
||||||
endfor
|
|
||||||
put ='ZZZ'
|
|
||||||
1
|
|
||||||
.delete
|
|
||||||
]])
|
|
||||||
|
|
||||||
local screen = Screen.new(52, 6)
|
|
||||||
screen:attach()
|
|
||||||
screen:set_default_attr_ids({
|
|
||||||
[0] = {foreground = Screen.colors.White,
|
|
||||||
background = Screen.colors.Red},
|
|
||||||
[1] = {bold = true,
|
|
||||||
foreground = Screen.colors.SeaGreen}
|
|
||||||
})
|
|
||||||
|
|
||||||
screen:expect([[
|
|
||||||
^XXX |
|
|
||||||
XXX |
|
|
||||||
XXX |
|
|
||||||
XXX |
|
|
||||||
XXX |
|
|
||||||
|
|
|
||||||
]])
|
|
||||||
|
|
||||||
local function test_ctrl_c(ms)
|
|
||||||
feed(":global/^/p<CR>")
|
|
||||||
helpers.sleep(ms)
|
|
||||||
feed("<C-C>")
|
|
||||||
screen:expect([[
|
|
||||||
XXX |
|
|
||||||
XXX |
|
|
||||||
XXX |
|
|
||||||
XXX |
|
|
||||||
{0:Interrupted} |
|
|
||||||
Interrupt: {1:Press ENTER or type command to continue}^ |
|
|
||||||
]])
|
|
||||||
end
|
|
||||||
|
|
||||||
-- The test is time-sensitive. Try with different sleep values.
|
|
||||||
local ms_values = {10, 50, 100}
|
|
||||||
for i, ms in ipairs(ms_values) do
|
|
||||||
if i < #ms_values then
|
|
||||||
local status, _ = pcall(test_ctrl_c, ms)
|
|
||||||
if status then break end
|
|
||||||
else -- Call the last attempt directly.
|
|
||||||
test_ctrl_c(ms)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end)
|
|
@ -492,12 +492,12 @@ local function create_callindex(func)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Helper to skip tests. Returns true in Windows systems.
|
-- Helper to skip tests. Returns true in Windows systems.
|
||||||
-- pending_func is pending() from busted
|
-- pending_fn is pending() from busted
|
||||||
local function pending_win32(pending_func)
|
local function pending_win32(pending_fn)
|
||||||
clear()
|
clear()
|
||||||
if uname() == 'Windows' then
|
if uname() == 'Windows' then
|
||||||
if pending_func ~= nil then
|
if pending_fn ~= nil then
|
||||||
pending_func('FIXME: Windows', function() end)
|
pending_fn('FIXME: Windows', function() end)
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
@ -505,6 +505,22 @@ local function pending_win32(pending_func)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Calls pending() and returns `true` if the system is too slow to
|
||||||
|
-- run fragile or expensive tests. Else returns `false`.
|
||||||
|
local function skip_fragile(pending_fn, cond)
|
||||||
|
if pending_fn == nil or type(pending_fn) ~= type(function()end) then
|
||||||
|
error("invalid pending_fn")
|
||||||
|
end
|
||||||
|
if cond then
|
||||||
|
pending_fn("skipped (test is fragile on this system)", function() end)
|
||||||
|
return true
|
||||||
|
elseif os.getenv("TEST_SKIP_FRAGILE") then
|
||||||
|
pending_fn("skipped (TEST_SKIP_FRAGILE)", function() end)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
local funcs = create_callindex(nvim_call)
|
local funcs = create_callindex(nvim_call)
|
||||||
local meths = create_callindex(nvim)
|
local meths = create_callindex(nvim)
|
||||||
local uimeths = create_callindex(ui)
|
local uimeths = create_callindex(ui)
|
||||||
@ -573,6 +589,7 @@ return function(after_each)
|
|||||||
curwinmeths = curwinmeths,
|
curwinmeths = curwinmeths,
|
||||||
curtabmeths = curtabmeths,
|
curtabmeths = curtabmeths,
|
||||||
pending_win32 = pending_win32,
|
pending_win32 = pending_win32,
|
||||||
|
skip_fragile = skip_fragile,
|
||||||
tmpname = tmpname,
|
tmpname = tmpname,
|
||||||
NIL = mpack.NIL,
|
NIL = mpack.NIL,
|
||||||
}
|
}
|
||||||
|
@ -153,9 +153,10 @@ describe('Mouse input', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('in tabline to the left moves tab left', function()
|
it('in tabline to the left moves tab left', function()
|
||||||
if os.getenv("TRAVIS") and (helpers.os_name() == "osx"
|
if helpers.skip_fragile(pending,
|
||||||
or os.getenv("CLANG_SANITIZER") == "ASAN_UBSAN") then
|
os.getenv("TRAVIS") and (helpers.os_name() == "osx"
|
||||||
pending("[Fails on Travis macOS, ASAN_UBSAN. #4874]", function() end)
|
or os.getenv("CLANG_SANITIZER") == "ASAN_UBSAN")) -- #4874
|
||||||
|
then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -257,9 +258,10 @@ describe('Mouse input', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('out of tabline to the left moves tab left', function()
|
it('out of tabline to the left moves tab left', function()
|
||||||
if os.getenv("TRAVIS") and (helpers.os_name() == "osx"
|
if helpers.skip_fragile(pending,
|
||||||
or os.getenv("CLANG_SANITIZER") == "ASAN_UBSAN") then
|
os.getenv("TRAVIS") and (helpers.os_name() == "osx"
|
||||||
pending("[Fails on Travis macOS, ASAN_UBSAN. #4874]", function() end)
|
or os.getenv("CLANG_SANITIZER") == "ASAN_UBSAN")) -- #4874
|
||||||
|
then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user