@@ -855,49 +855,61 @@ func Test_terminal_response_to_control_sequence()
855855 unlet g: job
856856endfunc
857857
858- " Run Vim in a terminal, then start a terminal in that Vim with a kill
859- " argument, check that :qall works.
860- func Test_terminal_qall_kill_arg ()
861- if ! CanRunVimInTerminal ()
858+ " Run Vim, start a terminal in that Vim with the kill argument,
859+ " :qall works.
860+ func Run_terminal_qall_kill (line1, line2)
861+ " 1. Open a terminal window and wait for the prompt to appear
862+ " 2. set kill using term_setkill()
863+ " 3. make Vim exit, it will kill the shell
864+ let after = [
865+ \ a: line1 ,
866+ \ ' let buf = bufnr("%")' ,
867+ \ ' while term_getline(buf, 1) =~ "^\\s*$"' ,
868+ \ ' sleep 10m' ,
869+ \ ' endwhile' ,
870+ \ a: line2 ,
871+ \ ' au VimLeavePre * call writefile(["done"], "Xdone")' ,
872+ \ ' qall' ,
873+ \ ]
874+ if ! RunVim ([], after, ' ' )
862875 return
863876 endif
864- let buf = RunVimInTerminal (' ' , {})
865-
866- " Open a terminal window and wait for the prompt to appear
867- call term_sendkeys (buf , " :term ++kill=kill\<CR> " )
868- call WaitFor ({- > term_getline (buf , 10 ) = ~ ' \[running]' })
869- call WaitFor ({- > term_getline (buf , 1 ) !~ ' ^\s*$' })
870-
871- " make Vim exit, it will kill the shell
872- call term_sendkeys (buf , " \<C-W> :qall\<CR> " )
873- call WaitFor ({- > term_getstatus (buf ) == " finished" })
874-
875- " close the terminal window where Vim was running
876- quit
877+ call assert_equal (" done" , readfile (" Xdone" )[0 ])
878+ call delete (" Xdone" )
877879endfunc
878880
879881" Run Vim in a terminal, then start a terminal in that Vim with a kill
880882" argument, check that :qall works.
883+ func Test_terminal_qall_kill_arg ()
884+ call Run_terminal_qall_kill (' term ++kill=kill' , ' ' )
885+ endfunc
886+
887+ " Run Vim, start a terminal in that Vim, set the kill argument with
888+ " term_setkill(), check that :qall works.
881889func Test_terminal_qall_kill_func ()
882- if ! CanRunVimInTerminal ()
890+ call Run_terminal_qall_kill (' term' , ' call term_setkill(buf, "kill")' )
891+ endfunc
892+
893+ " Run Vim, start a terminal in that Vim without the kill argument,
894+ " check that :qall does not exit, :qall! does.
895+ func Test_terminal_qall_exit ()
896+ let after = [
897+ \ ' term' ,
898+ \ ' let buf = bufnr("%")' ,
899+ \ ' while term_getline(buf, 1) =~ "^\\s*$"' ,
900+ \ ' sleep 10m' ,
901+ \ ' endwhile' ,
902+ \ ' set nomore' ,
903+ \ ' au VimLeavePre * call writefile(["too early"], "Xdone")' ,
904+ \ ' qall' ,
905+ \ ' au! VimLeavePre * exe buf . "bwipe!" | call writefile(["done"], "Xdone")' ,
906+ \ ' cquit' ,
907+ \ ]
908+ if ! RunVim ([], after, ' ' )
883909 return
884910 endif
885- let buf = RunVimInTerminal (' ' , {})
886-
887- " Open a terminal window and wait for the prompt to appear
888- call term_sendkeys (buf , " :term\<CR> " )
889- call WaitFor ({- > term_getline (buf , 10 ) = ~ ' \[running]' })
890- call WaitFor ({- > term_getline (buf , 1 ) !~ ' ^\s*$' })
891-
892- " set kill using term_setkill()
893- call term_sendkeys (buf , " \<C-W> :call term_setkill(bufnr('%'), 'kill')\<CR> " )
894-
895- " make Vim exit, it will kill the shell
896- call term_sendkeys (buf , " \<C-W> :qall\<CR> " )
897- call WaitFor ({- > term_getstatus (buf ) == " finished" })
898-
899- " close the terminal window where Vim was running
900- quit
911+ call assert_equal (" done" , readfile (" Xdone" )[0 ])
912+ call delete (" Xdone" )
901913endfunc
902914
903915" Run Vim in a terminal, then start a terminal in that Vim without a kill
0 commit comments