comparison src/testdir/test_terminal.vim @ 13499:661394686fd8 v8.0.1623

patch 8.0.1623: terminal kill tests are flaky commit https://github.com/vim/vim/commit/3e8d385347b23b2925d1b8ca64b78764d37f21fe Author: Bram Moolenaar <Bram@vim.org> Date: Tue Mar 20 17:43:01 2018 +0100 patch 8.0.1623: terminal kill tests are flaky Problem: Terminal kill tests are flaky. Solution: Instead of running Vim in a terminal, run it as a normal command.
author Christian Brabandt <cb@256bit.org>
date Tue, 20 Mar 2018 17:45:07 +0100
parents d130044d4f1f
children 7d0a8ca17f30
comparison
equal deleted inserted replaced
13498:e2719254a7a4 13499:661394686fd8
853 exe buf . 'bwipe' 853 exe buf . 'bwipe'
854 call delete('Xescape') 854 call delete('Xescape')
855 unlet g:job 855 unlet g:job
856 endfunc 856 endfunc
857 857
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, '')
875 return
876 endif
877 call assert_equal("done", readfile("Xdone")[0])
878 call delete("Xdone")
879 endfunc
880
858 " Run Vim in a terminal, then start a terminal in that Vim with a kill 881 " Run Vim in a terminal, then start a terminal in that Vim with a kill
859 " argument, check that :qall works. 882 " argument, check that :qall works.
860 func Test_terminal_qall_kill_arg() 883 func Test_terminal_qall_kill_arg()
861 if !CanRunVimInTerminal() 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.
889 func Test_terminal_qall_kill_func()
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, '')
862 return 909 return
863 endif 910 endif
864 let buf = RunVimInTerminal('', {}) 911 call assert_equal("done", readfile("Xdone")[0])
865 912 call delete("Xdone")
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 endfunc
878
879 " Run Vim in a terminal, then start a terminal in that Vim with a kill
880 " argument, check that :qall works.
881 func Test_terminal_qall_kill_func()
882 if !CanRunVimInTerminal()
883 return
884 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
901 endfunc 913 endfunc
902 914
903 " Run Vim in a terminal, then start a terminal in that Vim without a kill 915 " Run Vim in a terminal, then start a terminal in that Vim without a kill
904 " argument, check that :confirm qall works. 916 " argument, check that :confirm qall works.
905 func Test_terminal_qall_prompt() 917 func Test_terminal_qall_prompt()