diff options
Diffstat (limited to 'test/functional/core/startup_spec.lua')
-rw-r--r-- | test/functional/core/startup_spec.lua | 94 |
1 files changed, 80 insertions, 14 deletions
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua index ae7f949e52..f1f96ba626 100644 --- a/test/functional/core/startup_spec.lua +++ b/test/functional/core/startup_spec.lua @@ -4,16 +4,19 @@ local Screen = require('test.functional.ui.screen') local clear = helpers.clear local command = helpers.command local eq = helpers.eq +local feed = helpers.feed local funcs = helpers.funcs local nvim_prog = helpers.nvim_prog local nvim_set = helpers.nvim_set local read_file = helpers.read_file local retry = helpers.retry +local sleep = helpers.sleep local iswin = helpers.iswin describe('startup', function() before_each(function() clear() + os.remove('Xtest_startup_ttyout') end) after_each(function() os.remove('Xtest_startup_ttyout') @@ -46,8 +49,8 @@ describe('startup', function() end -- Running in :terminal command([[exe printf("terminal %s -u NONE -i NONE --cmd \"]] - ..nvim_set..[[\" ]] - ..[[-c \"echo has('ttyin') has('ttyout')\""]] + ..nvim_set..[[\"]] + ..[[ -c \"echo has('ttyin') has('ttyout')\""]] ..[[, shellescape(v:progpath))]]) screen:expect([[ ^ | @@ -56,41 +59,104 @@ describe('startup', function() ]]) end) it('output to pipe: has("ttyin")==1 has("ttyout")==0', function() - local screen = Screen.new(25, 5) - screen:attach() if iswin() then command([[set shellcmdflag=/s\ /c shellxquote=\"]]) end -- Running in :terminal command([[exe printf("terminal %s -u NONE -i NONE --cmd \"]] - ..nvim_set..[[\" ]] - ..[[-c \"call writefile([has('ttyin'), has('ttyout')], 'Xtest_startup_ttyout')\"]] - ..[[-c q | cat -v"]] -- Output to a pipe. + ..nvim_set..[[\"]] + ..[[ -c \"call writefile([has('ttyin'), has('ttyout')], 'Xtest_startup_ttyout')\"]] + ..[[ -c q | cat -v"]] -- Output to a pipe. ..[[, shellescape(v:progpath))]]) retry(nil, 3000, function() - screen:sleep(1) + sleep(1) eq('1\n0\n', -- stdin is a TTY, stdout is a pipe read_file('Xtest_startup_ttyout')) end) end) it('input from pipe: has("ttyin")==0 has("ttyout")==1', function() - local screen = Screen.new(25, 5) - screen:attach() if iswin() then command([[set shellcmdflag=/s\ /c shellxquote=\"]]) end -- Running in :terminal command([[exe printf("terminal echo foo | ]] -- Input from a pipe. ..[[%s -u NONE -i NONE --cmd \"]] - ..nvim_set..[[\" ]] - ..[[-c \"call writefile([has('ttyin'), has('ttyout')], 'Xtest_startup_ttyout')\"]] - ..[[-c q -- -"]] + ..nvim_set..[[\"]] + ..[[ -c \"call writefile([has('ttyin'), has('ttyout')], 'Xtest_startup_ttyout')\"]] + ..[[ -c q -- -"]] ..[[, shellescape(v:progpath))]]) retry(nil, 3000, function() - screen:sleep(1) + sleep(1) eq('0\n1\n', -- stdin is a pipe, stdout is a TTY read_file('Xtest_startup_ttyout')) end) end) + it('input from pipe (implicit) #7679', function() + local screen = Screen.new(25, 3) + screen:attach() + if iswin() then + command([[set shellcmdflag=/s\ /c shellxquote=\"]]) + end + -- Running in :terminal + command([[exe printf("terminal echo foo | ]] -- Input from a pipe. + ..[[%s -u NONE -i NONE --cmd \"]] + ..nvim_set..[[\"]] + ..[[ -c \"echo has('ttyin') has('ttyout')\""]] + ..[[, shellescape(v:progpath))]]) + screen:expect([[ + ^foo | + 0 1 | + | + ]]) + end) + it('input from pipe + file args #7679', function() + eq('ohyeah\r\n0 0 bufs=3', + funcs.system({nvim_prog, '-n', '-u', 'NONE', '-i', 'NONE', '--headless', + '+.print', + "+echo has('ttyin') has('ttyout') 'bufs='.bufnr('$')", + '+qall!', + '-', + 'test/functional/fixtures/tty-test.c', + 'test/functional/fixtures/shell-test.c', + }, + { 'ohyeah', '' })) + end) + + it('-e/-E interactive #7679', function() + clear('-E') + local screen = Screen.new(25, 3) + screen:attach() + feed("put ='from -E'<CR>") + screen:expect([[ + | + from -E | + :^ | + ]]) + end) + + it('stdin with -es/-Es #7679', function() + local input = { 'append', 'line1', 'line2', '.', '%print', '' } + local inputstr = table.concat(input, '\n') + + -- + -- -Es: read stdin as text + -- + eq('partylikeits1999\n', + funcs.system({nvim_prog, '-n', '-u', 'NONE', '-i', 'NONE', '-Es', '+.print', 'test/functional/fixtures/tty-test.c' }, + { 'partylikeits1999', '' })) + eq(inputstr, + funcs.system({nvim_prog, '-i', 'NONE', '-Es', '+%print', '-' }, + input)) + + -- + -- -es: read stdin as ex-commands + -- + eq(' encoding=utf-8\n', + funcs.system({nvim_prog, '-n', '-u', 'NONE', '-i', 'NONE', '-es', 'test/functional/fixtures/tty-test.c' }, + { 'set encoding', '' })) + eq('line1\nline2\n', + funcs.system({nvim_prog, '-i', 'NONE', '-es', '-' }, + input)) + end) end) |