2017-05-10 06:04:49 -07:00
|
|
|
local Screen = require('test.functional.ui.screen')
|
2016-07-14 19:11:49 -07:00
|
|
|
local session = require('test.functional.helpers')(after_each)
|
|
|
|
local child_session = require('test.functional.terminal.helpers')
|
2017-05-10 06:04:49 -07:00
|
|
|
local eq = session.eq
|
|
|
|
local eval = session.eval
|
|
|
|
local feed = session.feed
|
|
|
|
local iswin = session.iswin
|
2016-08-15 16:42:12 -07:00
|
|
|
|
2016-07-14 19:11:49 -07:00
|
|
|
describe("shell command :!", function()
|
2017-05-10 06:04:49 -07:00
|
|
|
if session.pending_win32(pending) then return end
|
|
|
|
|
2016-07-14 19:11:49 -07:00
|
|
|
local screen
|
|
|
|
before_each(function()
|
|
|
|
session.clear()
|
|
|
|
screen = child_session.screen_setup(0, '["'..session.nvim_prog..
|
2017-02-09 19:39:00 -07:00
|
|
|
'", "-u", "NONE", "-i", "NONE", "--cmd", "'..session.nvim_set..'"]')
|
2016-07-14 19:11:49 -07:00
|
|
|
screen:expect([[
|
|
|
|
{1: } |
|
2016-08-09 08:01:56 -07:00
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
2017-02-09 19:39:00 -07:00
|
|
|
{4:~ }|
|
2016-07-14 19:11:49 -07:00
|
|
|
|
|
2016-08-09 08:01:56 -07:00
|
|
|
{3:-- TERMINAL --} |
|
2016-07-14 19:11:49 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
after_each(function()
|
2016-09-14 07:19:07 -07:00
|
|
|
child_session.feed_data("\3") -- Ctrl-C
|
2016-07-14 19:11:49 -07:00
|
|
|
screen:detach()
|
|
|
|
end)
|
|
|
|
|
2017-01-19 06:19:59 -07:00
|
|
|
it("displays output without LF/EOF. #4646 #4569 #3772", function()
|
2016-07-14 19:11:49 -07:00
|
|
|
-- NOTE: We use a child nvim (within a :term buffer)
|
|
|
|
-- to avoid triggering a UI flush.
|
|
|
|
child_session.feed_data(":!printf foo; sleep 200\n")
|
|
|
|
screen:expect([[
|
2016-08-09 08:01:56 -07:00
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
2017-02-09 19:39:00 -07:00
|
|
|
{4:~ }|
|
2018-01-13 02:14:41 -07:00
|
|
|
{4:~ }|
|
2016-09-14 17:59:09 -07:00
|
|
|
:!printf foo; sleep 200 |
|
|
|
|
foo |
|
2016-08-09 08:01:56 -07:00
|
|
|
{3:-- TERMINAL --} |
|
2016-07-14 19:11:49 -07:00
|
|
|
]])
|
|
|
|
end)
|
2016-09-29 17:33:50 -07:00
|
|
|
|
2016-10-07 04:18:24 -07:00
|
|
|
it("throttles shell-command output greater than ~10KB", function()
|
2017-01-24 06:25:50 -07:00
|
|
|
if os.getenv("TRAVIS") and session.os_name() == "osx" then
|
2017-01-23 14:15:49 -07:00
|
|
|
pending("[Unreliable on Travis macOS.]", function() end)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2016-10-07 04:18:24 -07:00
|
|
|
screen.timeout = 20000 -- Avoid false failure on slow systems.
|
2016-09-29 17:33:50 -07:00
|
|
|
child_session.feed_data(
|
2016-10-07 04:18:24 -07:00
|
|
|
":!for i in $(seq 2 3000); do echo XXXXXXXXXX $i; done\n")
|
|
|
|
|
|
|
|
-- If we observe any line starting with a dot, then throttling occurred.
|
2016-09-29 17:33:50 -07:00
|
|
|
screen:expect("\n.", nil, nil, nil, true)
|
2016-10-07 04:18:24 -07:00
|
|
|
|
|
|
|
-- Final chunk of output should always be displayed, never skipped.
|
|
|
|
-- (Throttling is non-deterministic, this test is merely a sanity check.)
|
|
|
|
screen:expect([[
|
|
|
|
XXXXXXXXXX 2997 |
|
|
|
|
XXXXXXXXXX 2998 |
|
|
|
|
XXXXXXXXXX 2999 |
|
|
|
|
XXXXXXXXXX 3000 |
|
2018-01-13 02:14:41 -07:00
|
|
|
|
|
2016-10-07 04:18:24 -07:00
|
|
|
{10:Press ENTER or type command to continue}{1: } |
|
|
|
|
{3:-- TERMINAL --} |
|
|
|
|
]])
|
2016-09-29 17:33:50 -07:00
|
|
|
end)
|
2016-07-14 19:11:49 -07:00
|
|
|
end)
|
2017-05-10 06:04:49 -07:00
|
|
|
|
|
|
|
describe("shell command :!", function()
|
|
|
|
before_each(function()
|
|
|
|
session.clear()
|
|
|
|
end)
|
|
|
|
|
|
|
|
it("cat a binary file #4142", function()
|
|
|
|
feed(":exe 'silent !cat '.shellescape(v:progpath)<CR>")
|
|
|
|
eq(2, eval('1+1')) -- Still alive?
|
|
|
|
end)
|
|
|
|
|
|
|
|
it([[display \x08 char #4142]], function()
|
|
|
|
feed(":silent !echo \08<CR>")
|
|
|
|
eq(2, eval('1+1')) -- Still alive?
|
|
|
|
end)
|
|
|
|
|
|
|
|
it([[handles control codes]], function()
|
|
|
|
if iswin() then
|
|
|
|
pending('missing printf', function() end)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
local screen = Screen.new(50, 4)
|
|
|
|
screen:attach()
|
|
|
|
-- Print TAB chars. #2958
|
|
|
|
feed([[:!printf '1\t2\t3'<CR>]])
|
|
|
|
screen:expect([[
|
|
|
|
~ |
|
|
|
|
:!printf '1\t2\t3' |
|
|
|
|
1 2 3 |
|
|
|
|
Press ENTER or type command to continue^ |
|
|
|
|
]])
|
|
|
|
feed([[<CR>]])
|
|
|
|
-- Print BELL control code. #4338
|
2018-02-07 02:23:19 -07:00
|
|
|
screen.bell = false
|
2017-05-10 06:04:49 -07:00
|
|
|
feed([[:!printf '\x07\x07\x07\x07text'<CR>]])
|
|
|
|
screen:expect([[
|
|
|
|
~ |
|
|
|
|
:!printf '\x07\x07\x07\x07text' |
|
2018-02-07 02:23:19 -07:00
|
|
|
text |
|
2017-05-10 06:04:49 -07:00
|
|
|
Press ENTER or type command to continue^ |
|
2018-02-07 02:23:19 -07:00
|
|
|
]], nil, nil, function()
|
|
|
|
eq(true, screen.bell)
|
|
|
|
end)
|
2017-05-10 06:04:49 -07:00
|
|
|
feed([[<CR>]])
|
|
|
|
-- Print BS control code.
|
|
|
|
feed([[:echo system('printf ''\x08\n''')<CR>]])
|
|
|
|
screen:expect([[
|
|
|
|
~ |
|
|
|
|
^H |
|
|
|
|
|
|
|
|
|
Press ENTER or type command to continue^ |
|
|
|
|
]])
|
|
|
|
feed([[<CR>]])
|
|
|
|
-- Print LF control code.
|
|
|
|
feed([[:!printf '\n'<CR>]])
|
|
|
|
screen:expect([[
|
|
|
|
:!printf '\n' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Press ENTER or type command to continue^ |
|
|
|
|
]])
|
|
|
|
feed([[<CR>]])
|
|
|
|
end)
|
|
|
|
end)
|