diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2017-11-08 04:10:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-08 04:10:22 +0100 |
commit | e98bcf0523ce28c5159725cee1ec0662355aa65d (patch) | |
tree | d273d16a84ce67ac5c4573362047a9cfc4f7c91b /test | |
parent | c46d6f8da25a841725b874adf787b90a0b04f790 (diff) | |
parent | 54cac3033f2c6e27c677681e8ca6d21e3fd9fc0a (diff) | |
download | rneovim-e98bcf0523ce28c5159725cee1ec0662355aa65d.tar.gz rneovim-e98bcf0523ce28c5159725cee1ec0662355aa65d.tar.bz2 rneovim-e98bcf0523ce28c5159725cee1ec0662355aa65d.zip |
Merge #7465 has('ttyin'), has('ttyout')
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/core/startup_spec.lua | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua new file mode 100644 index 0000000000..ae7f949e52 --- /dev/null +++ b/test/functional/core/startup_spec.lua @@ -0,0 +1,96 @@ +local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') + +local clear = helpers.clear +local command = helpers.command +local eq = helpers.eq +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 iswin = helpers.iswin + +describe('startup', function() + before_each(function() + clear() + end) + after_each(function() + os.remove('Xtest_startup_ttyout') + end) + + it('pipe at both ends: has("ttyin")==0 has("ttyout")==0', function() + -- system() puts a pipe at both ends. + local out = funcs.system({ nvim_prog, '-u', 'NONE', '-i', 'NONE', '--headless', + '--cmd', nvim_set, + '-c', [[echo has('ttyin') has('ttyout')]], + '+q' }) + eq('0 0', out) + end) + it('with --embed: has("ttyin")==0 has("ttyout")==0', function() + local screen = Screen.new(25, 3) + -- Remote UI connected by --embed. + screen:attach() + command([[echo has('ttyin') has('ttyout')]]) + screen:expect([[ + ^ | + ~ | + 0 0 | + ]]) + end) + it('in a TTY: has("ttyin")==1 has("ttyout")==1', 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 %s -u NONE -i NONE --cmd \"]] + ..nvim_set..[[\" ]] + ..[[-c \"echo has('ttyin') has('ttyout')\""]] + ..[[, shellescape(v:progpath))]]) + screen:expect([[ + ^ | + 1 1 | + | + ]]) + 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. + ..[[, shellescape(v:progpath))]]) + retry(nil, 3000, function() + screen: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 -- -"]] + ..[[, shellescape(v:progpath))]]) + retry(nil, 3000, function() + screen:sleep(1) + eq('0\n1\n', -- stdin is a pipe, stdout is a TTY + read_file('Xtest_startup_ttyout')) + end) + end) +end) + |