aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/functional/api/vim_spec.lua4
-rw-r--r--test/functional/eval/execute_spec.lua5
-rw-r--r--test/functional/ui/output_spec.lua70
3 files changed, 72 insertions, 7 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 0a0cb2e91c..1faed4e9b1 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -11,11 +11,11 @@ local funcs = helpers.funcs
local request = helpers.request
local meth_pcall = helpers.meth_pcall
local command = helpers.command
+local iswin = helpers.iswin
local intchar2lua = global_helpers.intchar2lua
local format_string = global_helpers.format_string
local mergedicts_copy = global_helpers.mergedicts_copy
-local uname = global_helpers.uname
describe('api', function()
before_each(clear)
@@ -101,7 +101,7 @@ describe('api', function()
end)
it('returns shell |:!| output', function()
- local win_lf = (uname() == 'Windows' and '\r') or ''
+ local win_lf = iswin() and '\r' or ''
eq(':!echo foo\r\n\nfoo'..win_lf..'\n', nvim('command_output', [[!echo foo]]))
end)
diff --git a/test/functional/eval/execute_spec.lua b/test/functional/eval/execute_spec.lua
index c866359520..183884a51e 100644
--- a/test/functional/eval/execute_spec.lua
+++ b/test/functional/eval/execute_spec.lua
@@ -1,5 +1,4 @@
local helpers = require('test.functional.helpers')(after_each)
-local global_helpers = require('test.helpers')
local eq = helpers.eq
local eval = helpers.eval
local clear = helpers.clear
@@ -10,7 +9,7 @@ local funcs = helpers.funcs
local Screen = require('test.functional.ui.screen')
local command = helpers.command
local feed = helpers.feed
-local uname = global_helpers.uname
+local iswin = helpers.iswin
describe('execute()', function()
before_each(clear)
@@ -123,7 +122,7 @@ describe('execute()', function()
-- This deviates from vim behavior, but is consistent
-- with how nvim currently displays the output.
it('does capture shell-command output', function()
- local win_lf = (uname() == 'Windows' and '\13') or ''
+ local win_lf = iswin() and '\13' or ''
eq('\n:!echo foo\r\n\nfoo'..win_lf..'\n', funcs.execute('!echo foo'))
end)
diff --git a/test/functional/ui/output_spec.lua b/test/functional/ui/output_spec.lua
index da3f474e08..c42c0b26c6 100644
--- a/test/functional/ui/output_spec.lua
+++ b/test/functional/ui/output_spec.lua
@@ -1,9 +1,14 @@
+local Screen = require('test.functional.ui.screen')
local session = require('test.functional.helpers')(after_each)
local child_session = require('test.functional.terminal.helpers')
-
-if session.pending_win32(pending) then return end
+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()
@@ -66,3 +71,64 @@ describe("shell command :!", function()
]])
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)