aboutsummaryrefslogtreecommitdiff
path: root/test/functional/shell/viml_system_spec.lua
diff options
context:
space:
mode:
authoroni-link <knil.ino@gmail.com>2015-01-17 16:26:42 +0100
committeroni-link <knil.ino@gmail.com>2015-01-17 16:34:58 +0100
commitd7d1b1133277e96c3929082c96ec2fad374a0827 (patch)
tree12e7df25afe560a69c785e147211672c451b9cb1 /test/functional/shell/viml_system_spec.lua
parent5c22f07c4f2b8ae9f7d756373ae8541051d7bd81 (diff)
downloadrneovim-d7d1b1133277e96c3929082c96ec2fad374a0827.tar.gz
rneovim-d7d1b1133277e96c3929082c96ec2fad374a0827.tar.bz2
rneovim-d7d1b1133277e96c3929082c96ec2fad374a0827.zip
Tests for system()/systemlist() when interrupted with CTRL-C.
Diffstat (limited to 'test/functional/shell/viml_system_spec.lua')
-rw-r--r--test/functional/shell/viml_system_spec.lua152
1 files changed, 152 insertions, 0 deletions
diff --git a/test/functional/shell/viml_system_spec.lua b/test/functional/shell/viml_system_spec.lua
index 48dc518d7b..25d2b5bc2c 100644
--- a/test/functional/shell/viml_system_spec.lua
+++ b/test/functional/shell/viml_system_spec.lua
@@ -6,6 +6,8 @@ local helpers = require('test.functional.helpers')
local eq, clear, eval, feed, nvim =
helpers.eq, helpers.clear, helpers.eval, helpers.feed, helpers.nvim
+local Screen = require('test.functional.ui.screen')
+
local function create_file_with_nuls(name)
return function()
@@ -42,6 +44,81 @@ describe('system()', function()
eq(127, eval('v:shell_error'))
end)
+ describe('executes shell function', function()
+ local screen
+
+ before_each(function()
+ clear()
+ screen = Screen.new()
+ screen:attach()
+ end)
+
+ after_each(function()
+ screen:detach()
+ end)
+
+ it('`echo` and waits for its return', function()
+ feed(':call system("echo")<cr>')
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ :call system("echo") |
+ ]])
+ end)
+
+ it('`yes` and is directly interrupted with CTRL-C', function()
+ feed(':call system("yes")<cr><c-c>')
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ Type :quit<Enter> to exit Vim |
+ ]])
+ end)
+
+ it('`yes` and is a little bit later interrupted with CTRL-C', function()
+ feed(':call system("yes")<cr>')
+ feed('<c-c>')
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ Type :quit<Enter> to exit Vim |
+ ]])
+ end)
+ end)
+
describe('passing no input', function()
it('returns the program output', function()
eq("echoed", eval('system("echo -n echoed")'))
@@ -137,6 +214,81 @@ describe('systemlist()', function()
eq(127, eval('v:shell_error'))
end)
+ describe('exectues shell function', function()
+ local screen
+
+ before_each(function()
+ clear()
+ screen = Screen.new()
+ screen:attach()
+ end)
+
+ after_each(function()
+ screen:detach()
+ end)
+
+ it('`echo` and waits for its return', function()
+ feed(':call systemlist("echo")<cr>')
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ :call systemlist("echo") |
+ ]])
+ end)
+
+ it('`yes` and is directly interrupted with CTRL-C', function()
+ feed(':call systemlist("echo")<cr><c-c>')
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ Type :quit<Enter> to exit Vim |
+ ]])
+ end)
+
+ it('`yes` and is a little bit later interrupted with CTRL-C', function()
+ feed(':call systemlist("echo")<cr>')
+ feed('<c-c>')
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ Type :quit<Enter> to exit Vim |
+ ]])
+ end)
+ end)
+
describe('passing string with linefeed characters as input', function()
it('splits the output on linefeed characters', function()
eq({'abc', 'def', 'ghi'}, eval([[systemlist("cat -", "abc\ndef\nghi")]]))