diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/functional/autocmd/termxx_spec.lua | 1 | ||||
| -rw-r--r-- | test/functional/terminal/channel_spec.lua | 83 |
2 files changed, 83 insertions, 1 deletions
diff --git a/test/functional/autocmd/termxx_spec.lua b/test/functional/autocmd/termxx_spec.lua index 2522a28a9d..332a936e3f 100644 --- a/test/functional/autocmd/termxx_spec.lua +++ b/test/functional/autocmd/termxx_spec.lua @@ -22,7 +22,6 @@ describe('autocmd TermClose', function() command('set shellcmdflag=EXE shellredir= shellpipe= shellquote= shellxquote=') end) - local function test_termclose_delete_own_buf() -- The terminal process needs to keep running so that TermClose isn't triggered immediately. nvim('set_option_value', 'shell', string.format('"%s" INTERACT', testprg('shell-test')), {}) diff --git a/test/functional/terminal/channel_spec.lua b/test/functional/terminal/channel_spec.lua index 51bf611860..8510df5347 100644 --- a/test/functional/terminal/channel_spec.lua +++ b/test/functional/terminal/channel_spec.lua @@ -8,6 +8,10 @@ local pcall_err = helpers.pcall_err local feed = helpers.feed local poke_eventloop = helpers.poke_eventloop local is_os = helpers.is_os +local meths = helpers.meths +local async_meths = helpers.async_meths +local testprg = helpers.testprg +local assert_alive = helpers.assert_alive describe('terminal channel is closed and later released if', function() local screen @@ -116,3 +120,82 @@ it('chansend sends lines to terminal channel in proper order', function() } end end) + +describe('no crash when TermOpen autocommand', function() + local screen + + before_each(function() + clear() + meths.set_option_value('shell', testprg('shell-test'), {}) + command('set shellcmdflag=EXE shellredir= shellpipe= shellquote= shellxquote=') + screen = Screen.new(60, 4) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}; + }) + screen:attach() + end) + + it('processes job exit event when using termopen()', function() + command([[autocmd TermOpen * call input('')]]) + async_meths.command('terminal foobar') + screen:expect{grid=[[ + | + {0:~ }| + {0:~ }| + ^ | + ]]} + feed('<CR>') + screen:expect{grid=[[ + ^ready $ foobar | + | + [Process exited 0] | + | + ]]} + feed('i<CR>') + screen:expect{grid=[[ + ^ | + {0:~ }| + {0:~ }| + | + ]]} + assert_alive() + end) + + it('wipes buffer and processes events when using termopen()', function() + command([[autocmd TermOpen * bwipe! | call input('')]]) + async_meths.command('terminal foobar') + screen:expect{grid=[[ + | + {0:~ }| + {0:~ }| + ^ | + ]]} + feed('<CR>') + screen:expect{grid=[[ + ^ | + {0:~ }| + {0:~ }| + | + ]]} + assert_alive() + end) + + it('wipes buffer and processes events when using nvim_open_term()', function() + command([[autocmd TermOpen * bwipe! | call input('')]]) + async_meths.open_term(0, {}) + screen:expect{grid=[[ + | + {0:~ }| + {0:~ }| + ^ | + ]]} + feed('<CR>') + screen:expect{grid=[[ + ^ | + {0:~ }| + {0:~ }| + | + ]]} + assert_alive() + end) +end) |