1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
local Screen = require('test.functional.ui.screen')
local session = require('test.functional.helpers')(after_each)
local child_session = require('test.functional.terminal.helpers')
local eq = session.eq
local eval = session.eval
local feed = session.feed
local iswin = session.iswin
describe("shell command :!", function()
if session.pending_win32(pending) then return end
local screen
before_each(function()
session.clear()
screen = child_session.screen_setup(0, '["'..session.nvim_prog..
'", "-u", "NONE", "-i", "NONE", "--cmd", "'..session.nvim_set..'"]')
screen:expect([[
{1: } |
{4:~ }|
{4:~ }|
{4:~ }|
{4:~ }|
|
{3:-- TERMINAL --} |
]])
end)
after_each(function()
child_session.feed_data("\3") -- Ctrl-C
screen:detach()
end)
it("displays output without LF/EOF. #4646 #4569 #3772", function()
-- 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([[
{4:~ }|
{4:~ }|
{4:~ }|
{4:~ }|
:!printf foo; sleep 200 |
foo |
{3:-- TERMINAL --} |
]])
end)
it("throttles shell-command output greater than ~10KB", function()
if os.getenv("TRAVIS") and session.os_name() == "osx" then
pending("[Unreliable on Travis macOS.]", function() end)
return
end
screen.timeout = 20000 -- Avoid false failure on slow systems.
child_session.feed_data(
":!for i in $(seq 2 3000); do echo XXXXXXXXXX $i; done\n")
-- If we observe any line starting with a dot, then throttling occurred.
screen:expect("\n.", nil, nil, nil, true)
-- 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 |
|
{10:Press ENTER or type command to continue}{1: } |
{3:-- TERMINAL --} |
]])
end)
end)
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
feed([[:!printf '\x07\x07\x07\x07text'<CR>]])
screen:expect([[
~ |
:!printf '\x07\x07\x07\x07text' |
^G^G^G^Gtext |
Press ENTER or type command to continue^ |
]])
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)
|