2016-04-23 16:53:11 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
2017-04-08 15:55:19 -07:00
|
|
|
|
|
|
|
local nvim_dir = helpers.nvim_dir
|
2017-04-08 14:12:26 -07:00
|
|
|
local eq, call, clear, eval, feed_command, feed, nvim =
|
|
|
|
helpers.eq, helpers.call, helpers.clear, helpers.eval, helpers.feed_command,
|
2016-08-25 09:28:54 -07:00
|
|
|
helpers.feed, helpers.nvim
|
2014-10-01 05:32:56 -07:00
|
|
|
|
2015-01-17 08:26:42 -07:00
|
|
|
local Screen = require('test.functional.ui.screen')
|
|
|
|
|
2014-10-01 05:32:56 -07:00
|
|
|
local function create_file_with_nuls(name)
|
|
|
|
return function()
|
|
|
|
feed('ipart1<C-V>000part2<C-V>000part3<ESC>:w '..name..'<CR>')
|
2014-11-21 09:06:03 -07:00
|
|
|
eval('1') -- wait for the file to be created
|
2014-10-01 05:32:56 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function delete_file(name)
|
|
|
|
return function()
|
|
|
|
eval("delete('"..name.."')")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-10-23 06:30:27 -07:00
|
|
|
-- Some tests require the xclip program and a x server.
|
|
|
|
local xclip = nil
|
2014-11-25 18:03:17 -07:00
|
|
|
do
|
2014-10-23 06:30:27 -07:00
|
|
|
if os.getenv('DISPLAY') then
|
2014-11-25 18:03:17 -07:00
|
|
|
xclip = (os.execute('command -v xclip > /dev/null 2>&1') == 0)
|
2014-10-23 06:30:27 -07:00
|
|
|
end
|
|
|
|
end
|
2014-10-01 05:32:56 -07:00
|
|
|
|
|
|
|
describe('system()', function()
|
|
|
|
before_each(clear)
|
|
|
|
|
2016-08-25 09:28:54 -07:00
|
|
|
describe('command passed as a List', function()
|
2017-02-02 17:52:59 -07:00
|
|
|
local function printargs_path()
|
2017-04-08 15:55:19 -07:00
|
|
|
return nvim_dir..'/printargs-test'
|
2017-02-02 17:52:59 -07:00
|
|
|
.. (helpers.os_name() == 'windows' and '.exe' or '')
|
|
|
|
end
|
2016-08-25 09:28:54 -07:00
|
|
|
|
2016-09-30 07:29:50 -07:00
|
|
|
it('sets v:shell_error if cmd[0] is not executable', function()
|
|
|
|
call('system', { 'this-should-not-exist' })
|
|
|
|
eq(-1, eval('v:shell_error'))
|
|
|
|
end)
|
|
|
|
|
2017-01-10 10:06:34 -07:00
|
|
|
it('parameter validation does NOT modify v:shell_error', function()
|
|
|
|
-- 1. Call system() with invalid parameters.
|
|
|
|
-- 2. Assert that v:shell_error was NOT set.
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('call system({})')
|
2017-01-10 10:06:34 -07:00
|
|
|
eq('E475: Invalid argument: expected String or List', eval('v:errmsg'))
|
|
|
|
eq(0, eval('v:shell_error'))
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('call system([])')
|
2017-01-10 10:06:34 -07:00
|
|
|
eq('E474: Invalid argument', eval('v:errmsg'))
|
|
|
|
eq(0, eval('v:shell_error'))
|
|
|
|
|
|
|
|
-- Provoke a non-zero v:shell_error.
|
|
|
|
call('system', { 'this-should-not-exist' })
|
|
|
|
local old_val = eval('v:shell_error')
|
|
|
|
eq(-1, old_val)
|
|
|
|
|
|
|
|
-- 1. Call system() with invalid parameters.
|
|
|
|
-- 2. Assert that v:shell_error was NOT modified.
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('call system({})')
|
2017-01-10 10:06:34 -07:00
|
|
|
eq(old_val, eval('v:shell_error'))
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('call system([])')
|
2017-01-10 10:06:34 -07:00
|
|
|
eq(old_val, eval('v:shell_error'))
|
|
|
|
end)
|
|
|
|
|
2016-08-25 09:28:54 -07:00
|
|
|
it('quotes arguments correctly #5280', function()
|
|
|
|
local out = call('system',
|
2017-02-02 17:52:59 -07:00
|
|
|
{ printargs_path(), [[1]], [[2 "3]], [[4 ' 5]], [[6 ' 7']] })
|
2016-09-30 07:29:50 -07:00
|
|
|
|
2016-08-25 09:28:54 -07:00
|
|
|
eq(0, eval('v:shell_error'))
|
|
|
|
eq([[arg1=1;arg2=2 "3;arg3=4 ' 5;arg4=6 ' 7';]], out)
|
|
|
|
|
2017-02-02 17:52:59 -07:00
|
|
|
out = call('system', { printargs_path(), [['1]], [[2 "3]] })
|
2016-08-25 09:28:54 -07:00
|
|
|
eq(0, eval('v:shell_error'))
|
|
|
|
eq([[arg1='1;arg2=2 "3;]], out)
|
|
|
|
|
2017-02-02 17:52:59 -07:00
|
|
|
out = call('system', { printargs_path(), "A\nB" })
|
2016-08-25 09:28:54 -07:00
|
|
|
eq(0, eval('v:shell_error'))
|
|
|
|
eq("arg1=A\nB;", out)
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('calls executable in $PATH', function()
|
|
|
|
if 0 == eval("executable('python')") then pending("missing `python`") end
|
|
|
|
eq("foo\n", eval([[system(['python', '-c', 'print("foo")'])]]))
|
|
|
|
eq(0, eval('v:shell_error'))
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('does NOT run in shell', function()
|
|
|
|
if helpers.os_name() ~= 'windows' then
|
|
|
|
eq("* $PATH %PATH%\n", eval("system(['echo', '*', '$PATH', '%PATH%'])"))
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
if helpers.pending_win32(pending) then return end
|
|
|
|
|
|
|
|
it('sets v:shell_error', function()
|
2014-10-22 03:15:55 -07:00
|
|
|
eval([[system("sh -c 'exit'")]])
|
|
|
|
eq(0, eval('v:shell_error'))
|
|
|
|
eval([[system("sh -c 'exit 1'")]])
|
|
|
|
eq(1, eval('v:shell_error'))
|
|
|
|
eval([[system("sh -c 'exit 5'")]])
|
|
|
|
eq(5, eval('v:shell_error'))
|
2014-10-27 12:11:44 -07:00
|
|
|
eval([[system('this-should-not-exist')]])
|
|
|
|
eq(127, eval('v:shell_error'))
|
2014-10-22 03:15:55 -07:00
|
|
|
end)
|
|
|
|
|
2015-04-15 10:05:30 -07:00
|
|
|
describe('executes shell function if passed a string', function()
|
2015-01-17 08:26:42 -07:00
|
|
|
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([[
|
2015-03-05 02:07:55 -07:00
|
|
|
^ |
|
2015-01-17 08:26:42 -07:00
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
:call system("echo") |
|
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
2015-02-12 10:26:08 -07:00
|
|
|
it('`yes` and is interrupted with CTRL-C', function()
|
2015-01-17 08:26:42 -07:00
|
|
|
feed(':call system("yes")<cr>')
|
2015-02-20 16:41:03 -07:00
|
|
|
screen:expect([[
|
|
|
|
|
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
2015-03-16 04:29:57 -07:00
|
|
|
:call system("yes") |
|
2015-02-20 16:41:03 -07:00
|
|
|
]])
|
2015-01-17 08:26:42 -07:00
|
|
|
feed('<c-c>')
|
|
|
|
screen:expect([[
|
2015-03-05 02:07:55 -07:00
|
|
|
^ |
|
2015-01-17 08:26:42 -07:00
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
2015-02-20 14:54:21 -07:00
|
|
|
Type :quit<Enter> to exit Nvim |
|
2015-01-17 08:26:42 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
2014-10-01 05:32:56 -07:00
|
|
|
describe('passing no input', function()
|
|
|
|
it('returns the program output', function()
|
|
|
|
eq("echoed", eval('system("echo -n echoed")'))
|
|
|
|
end)
|
2016-10-17 14:56:39 -07:00
|
|
|
it('to backgrounded command does not crash', function()
|
2016-10-22 11:40:06 -07:00
|
|
|
-- This is indeterminate, just exercise the codepath. May get E5677.
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('call system("echo -n echoed &")')
|
2016-10-22 11:40:06 -07:00
|
|
|
local v_errnum = string.match(eval("v:errmsg"), "^E%d*:")
|
|
|
|
if v_errnum then
|
|
|
|
eq("E5677:", v_errnum)
|
|
|
|
end
|
2016-10-17 14:56:39 -07:00
|
|
|
eq(2, eval("1+1")) -- Still alive?
|
|
|
|
end)
|
2014-10-01 05:32:56 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
describe('passing input', function()
|
|
|
|
it('returns the program output', function()
|
|
|
|
eq("input", eval('system("cat -", "input")'))
|
|
|
|
end)
|
2016-10-17 14:56:39 -07:00
|
|
|
it('to backgrounded command does not crash', function()
|
2016-10-22 11:40:06 -07:00
|
|
|
-- This is indeterminate, just exercise the codepath. May get E5677.
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('call system("cat - &")')
|
2016-10-22 11:40:06 -07:00
|
|
|
local v_errnum = string.match(eval("v:errmsg"), "^E%d*:")
|
|
|
|
if v_errnum then
|
|
|
|
eq("E5677:", v_errnum)
|
|
|
|
end
|
2016-10-17 14:56:39 -07:00
|
|
|
eq(2, eval("1+1")) -- Still alive?
|
|
|
|
end)
|
2014-10-01 05:32:56 -07:00
|
|
|
end)
|
|
|
|
|
2014-11-10 05:19:27 -07:00
|
|
|
describe('passing a lot of input', function()
|
|
|
|
it('returns the program output', function()
|
|
|
|
local input = {}
|
|
|
|
-- write more than 1mb of data, which should be enough to overcome
|
|
|
|
-- the os buffer limit and force multiple event loop iterations to write
|
|
|
|
-- everything
|
2015-11-17 14:44:00 -07:00
|
|
|
for _ = 1, 0xffff do
|
2014-11-10 05:19:27 -07:00
|
|
|
input[#input + 1] = '01234567890ABCDEFabcdef'
|
|
|
|
end
|
|
|
|
input = table.concat(input, '\n')
|
|
|
|
nvim('set_var', 'input', input)
|
|
|
|
eq(input, eval('system("cat -", g:input)'))
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
2016-08-25 09:28:54 -07:00
|
|
|
describe('input passed as Number', function()
|
2014-10-01 05:32:56 -07:00
|
|
|
it('stringifies the input', function()
|
|
|
|
eq('1', eval('system("cat", 1)'))
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe('with output containing NULs', function()
|
|
|
|
local fname = 'Xtest'
|
|
|
|
|
2016-05-15 11:54:13 -07:00
|
|
|
before_each(create_file_with_nuls(fname))
|
|
|
|
after_each(delete_file(fname))
|
2014-10-01 05:32:56 -07:00
|
|
|
|
|
|
|
it('replaces NULs by SOH characters', function()
|
|
|
|
eq('part1\001part2\001part3\n', eval('system("cat '..fname..'")'))
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
2016-08-25 09:28:54 -07:00
|
|
|
describe('input passed as List', function()
|
|
|
|
it('joins List items with linefeed characters', function()
|
2014-10-01 05:32:56 -07:00
|
|
|
eq('line1\nline2\nline3',
|
|
|
|
eval("system('cat -', ['line1', 'line2', 'line3'])"))
|
|
|
|
end)
|
|
|
|
|
|
|
|
-- Notice that NULs are converted to SOH when the data is read back. This
|
|
|
|
-- is inconsistent and is a good reason for the existence of the
|
|
|
|
-- `systemlist()` function, where input and output map to the same
|
|
|
|
-- characters(see the following tests with `systemlist()` below)
|
2016-08-25 09:28:54 -07:00
|
|
|
describe('with linefeed characters inside List items', function()
|
2014-10-01 05:32:56 -07:00
|
|
|
it('converts linefeed characters to NULs', function()
|
|
|
|
eq('l1\001p2\nline2\001a\001b\nl3',
|
|
|
|
eval([[system('cat -', ["l1\np2", "line2\na\nb", 'l3'])]]))
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe('with leading/trailing whitespace characters on items', function()
|
|
|
|
it('preserves whitespace, replacing linefeeds by NULs', function()
|
|
|
|
eq('line \nline2\001\n\001line3',
|
|
|
|
eval([[system('cat -', ['line ', "line2\n", "\nline3"])]]))
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
2014-10-23 06:30:27 -07:00
|
|
|
|
2015-05-24 23:45:17 -07:00
|
|
|
describe("with a program that doesn't close stdout", function()
|
|
|
|
if not xclip then
|
2016-08-25 09:28:54 -07:00
|
|
|
pending('missing `xclip`', function() end)
|
2015-05-24 23:45:17 -07:00
|
|
|
else
|
2014-10-23 06:30:27 -07:00
|
|
|
it('will exit properly after passing input', function()
|
2017-02-02 17:45:34 -07:00
|
|
|
eq('', eval([[system('xclip -i -loops 1 -selection clipboard', 'clip-data')]]))
|
2014-10-23 06:30:27 -07:00
|
|
|
eq('clip-data', eval([[system('xclip -o -selection clipboard')]]))
|
|
|
|
end)
|
2015-05-24 23:45:17 -07:00
|
|
|
end
|
|
|
|
end)
|
2014-10-01 05:32:56 -07:00
|
|
|
end)
|
|
|
|
|
2016-08-25 09:28:54 -07:00
|
|
|
if helpers.pending_win32(pending) then return end
|
|
|
|
|
2014-10-01 05:32:56 -07:00
|
|
|
describe('systemlist()', function()
|
2016-08-25 09:28:54 -07:00
|
|
|
-- Similar to `system()`, but returns List instead of String.
|
2014-10-01 05:32:56 -07:00
|
|
|
before_each(clear)
|
|
|
|
|
2014-10-22 03:15:55 -07:00
|
|
|
it('sets the v:shell_error variable', function()
|
|
|
|
eval([[systemlist("sh -c 'exit'")]])
|
|
|
|
eq(0, eval('v:shell_error'))
|
|
|
|
eval([[systemlist("sh -c 'exit 1'")]])
|
|
|
|
eq(1, eval('v:shell_error'))
|
|
|
|
eval([[systemlist("sh -c 'exit 5'")]])
|
|
|
|
eq(5, eval('v:shell_error'))
|
2014-10-27 12:11:44 -07:00
|
|
|
eval([[systemlist('this-should-not-exist')]])
|
|
|
|
eq(127, eval('v:shell_error'))
|
2014-10-22 03:15:55 -07:00
|
|
|
end)
|
|
|
|
|
2015-01-17 08:26:42 -07:00
|
|
|
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([[
|
2015-03-05 02:07:55 -07:00
|
|
|
^ |
|
2015-01-17 08:26:42 -07:00
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
:call systemlist("echo") |
|
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
2015-02-20 16:41:03 -07:00
|
|
|
it('`yes` and is interrupted with CTRL-C', function()
|
2015-02-06 11:11:04 -07:00
|
|
|
feed(':call systemlist("yes | xargs")<cr>')
|
2015-02-20 16:41:03 -07:00
|
|
|
screen:expect([[
|
|
|
|
|
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
2015-03-16 04:29:57 -07:00
|
|
|
:call systemlist("yes | xargs") |
|
2015-02-20 16:41:03 -07:00
|
|
|
]])
|
2015-01-17 08:26:42 -07:00
|
|
|
feed('<c-c>')
|
|
|
|
screen:expect([[
|
2015-03-05 02:07:55 -07:00
|
|
|
^ |
|
2015-01-17 08:26:42 -07:00
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
2015-02-20 14:54:21 -07:00
|
|
|
Type :quit<Enter> to exit Nvim |
|
2015-01-17 08:26:42 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
2014-10-01 05:32:56 -07:00
|
|
|
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")]]))
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
2014-11-10 05:19:27 -07:00
|
|
|
describe('passing a lot of input', function()
|
|
|
|
it('returns the program output', function()
|
|
|
|
local input = {}
|
2015-11-17 14:44:00 -07:00
|
|
|
for _ = 1, 0xffff do
|
2014-11-10 05:19:27 -07:00
|
|
|
input[#input + 1] = '01234567890ABCDEFabcdef'
|
|
|
|
end
|
|
|
|
nvim('set_var', 'input', input)
|
|
|
|
eq(input, eval('systemlist("cat -", g:input)'))
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
2014-10-01 05:32:56 -07:00
|
|
|
describe('with output containing NULs', function()
|
|
|
|
local fname = 'Xtest'
|
|
|
|
|
2016-05-15 11:54:13 -07:00
|
|
|
before_each(create_file_with_nuls(fname))
|
|
|
|
after_each(delete_file(fname))
|
2014-10-01 05:32:56 -07:00
|
|
|
|
|
|
|
it('replaces NULs by newline characters', function()
|
|
|
|
eq({'part1\npart2\npart3'}, eval('systemlist("cat '..fname..'")'))
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
2016-08-25 09:28:54 -07:00
|
|
|
describe('input passed as List', function()
|
2014-10-01 05:32:56 -07:00
|
|
|
it('joins list items with linefeed characters', function()
|
|
|
|
eq({'line1', 'line2', 'line3'},
|
|
|
|
eval("systemlist('cat -', ['line1', 'line2', 'line3'])"))
|
|
|
|
end)
|
|
|
|
|
|
|
|
-- Unlike `system()` which uses SOH to represent NULs, with `systemlist()`
|
2016-08-25 09:28:54 -07:00
|
|
|
-- input and ouput are the same.
|
2014-10-01 05:32:56 -07:00
|
|
|
describe('with linefeed characters inside list items', function()
|
|
|
|
it('converts linefeed characters to NULs', function()
|
|
|
|
eq({'l1\np2', 'line2\na\nb', 'l3'},
|
|
|
|
eval([[systemlist('cat -', ["l1\np2", "line2\na\nb", 'l3'])]]))
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe('with leading/trailing whitespace characters on items', function()
|
|
|
|
it('preserves whitespace, replacing linefeeds by NULs', function()
|
|
|
|
eq({'line ', 'line2\n', '\nline3'},
|
|
|
|
eval([[systemlist('cat -', ['line ', "line2\n", "\nline3"])]]))
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
2014-10-23 06:30:27 -07:00
|
|
|
|
2014-12-02 08:50:58 -07:00
|
|
|
describe('handles empty lines', function()
|
|
|
|
it('in the middle', function()
|
|
|
|
eq({'line one','','line two'}, eval("systemlist('cat',['line one','','line two'])"))
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('in the beginning', function()
|
|
|
|
eq({'','line one','line two'}, eval("systemlist('cat',['','line one','line two'])"))
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
2014-11-27 13:30:17 -07:00
|
|
|
describe('when keepempty option is', function()
|
|
|
|
it('0, ignores trailing newline', function()
|
|
|
|
eq({'aa','bb'}, eval("systemlist('cat',['aa','bb'],0)"))
|
|
|
|
eq({'aa','bb'}, eval("systemlist('cat',['aa','bb',''],0)"))
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('1, preserves trailing newline', function()
|
|
|
|
eq({'aa','bb'}, eval("systemlist('cat',['aa','bb'],1)"))
|
|
|
|
eq({'aa','bb',''}, eval("systemlist('cat',['aa','bb',''],2)"))
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
2015-05-24 23:45:17 -07:00
|
|
|
describe("with a program that doesn't close stdout", function()
|
|
|
|
if not xclip then
|
2016-08-25 09:28:54 -07:00
|
|
|
pending('missing `xclip`', function() end)
|
2015-05-24 23:45:17 -07:00
|
|
|
else
|
2014-10-23 06:30:27 -07:00
|
|
|
it('will exit properly after passing input', function()
|
2014-11-10 04:07:16 -07:00
|
|
|
eq({}, eval(
|
2017-02-02 17:45:34 -07:00
|
|
|
"systemlist('xclip -i -loops 1 -selection clipboard', ['clip', 'data'])"))
|
2014-10-23 06:30:27 -07:00
|
|
|
eq({'clip', 'data'}, eval(
|
|
|
|
"systemlist('xclip -o -selection clipboard')"))
|
|
|
|
end)
|
2015-05-24 23:45:17 -07:00
|
|
|
end
|
|
|
|
end)
|
2014-10-01 05:32:56 -07:00
|
|
|
end)
|