summaryrefslogtreecommitdiff
path: root/src/testdir/test_terminal.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-08-03 17:06:45 +0200
committerBram Moolenaar <Bram@vim.org>2017-08-03 17:06:45 +0200
commit3c3a80dc59ccc0e0aabb9c8bd58ea84a801dbfc1 (patch)
tree5d8bce6ec51630afd5819b8fbcc5bf788735cdcb /src/testdir/test_terminal.vim
parent2f3a90a3bd8505728c0b6d9ac3515f64ee19b357 (diff)
downloadvim-git-8.0.0849.tar.gz
patch 8.0.0849: crash when job exit callback wipes the terminalv8.0.0849
Problem: Crash when job exit callback wipes the terminal. Solution: Check for b_term to be NULL. (Yasuhiro Matsumoto, closes #1922) Implement options for term_start() to be able to test. Make term_wait() more reliable.
Diffstat (limited to 'src/testdir/test_terminal.vim')
-rw-r--r--src/testdir/test_terminal.vim27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim
index cc5afc394..90bc58b85 100644
--- a/src/testdir/test_terminal.vim
+++ b/src/testdir/test_terminal.vim
@@ -86,6 +86,23 @@ func Test_terminal_hide_buffer()
unlet g:job
endfunc
+func! s:Nasty_exit_cb(job, st)
+ exe g:buf . 'bwipe!'
+ let g:buf = 0
+endfunc
+
+func Test_terminal_nasty_cb()
+ let cmd = Get_cat_cmd()
+ let g:buf = term_start(cmd, {'exit_cb': function('s:Nasty_exit_cb')})
+ let g:job = term_getjob(g:buf)
+
+ call WaitFor('job_status(g:job) == "dead"')
+ call WaitFor('g:buf == 0')
+ unlet g:buf
+ unlet g:job
+ call delete('Xtext')
+endfunc
+
func Check_123(buf)
let l = term_scrape(a:buf, 0)
call assert_true(len(l) == 0)
@@ -113,13 +130,17 @@ func Check_123(buf)
call assert_equal('123', l)
endfunc
-func Test_terminal_scrape()
+func Get_cat_cmd()
if has('win32')
- let cmd = 'cmd /c "cls && color 2 && echo 123"'
+ return 'cmd /c "cls && color 2 && echo 123"'
else
call writefile(["\<Esc>[32m123"], 'Xtext')
- let cmd = "cat Xtext"
+ return "cat Xtext"
endif
+endfunc
+
+func Test_terminal_scrape()
+ let cmd = Get_cat_cmd()
let buf = term_start(cmd)
let termlist = term_list()