comparison src/testdir/test_terminal2.vim @ 31780:8f15c56ff2fb v9.0.1222

patch 9.0.1222: terminal tests are flaky on MacOS Commit: https://github.com/vim/vim/commit/e446a017ffeaf1941589ac51ce9153b859018e5b Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Thu Jan 19 17:49:58 2023 +0000 patch 9.0.1222: terminal tests are flaky on MacOS Problem: Terminal tests are flaky on MacOS. Solution: Add TermWait() calls. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/11852)
author Bram Moolenaar <Bram@vim.org>
date Thu, 19 Jan 2023 19:00:06 +0100
parents c8ebe35b2475
children 1bc6f0899715
comparison
equal deleted inserted replaced
31779:b2a3e51f40e6 31780:8f15c56ff2fb
127 " hidden terminal must not change current window size 127 " hidden terminal must not change current window size
128 func Test_terminal_hidden_winsize() 128 func Test_terminal_hidden_winsize()
129 let cmd = GetDummyCmd() 129 let cmd = GetDummyCmd()
130 let rows = winheight(0) 130 let rows = winheight(0)
131 let buf = term_start(cmd, #{hidden: 1, term_rows: 10}) 131 let buf = term_start(cmd, #{hidden: 1, term_rows: 10})
132 call TermWait(buf)
132 call assert_equal(rows, winheight(0)) 133 call assert_equal(rows, winheight(0))
133 call assert_equal([10, &columns], term_getsize(buf)) 134 call assert_equal([10, &columns], term_getsize(buf))
134 exe "bwipe! " .. buf 135 exe "bwipe! " .. buf
135 endfunc 136 endfunc
136 137
194 \ ], 'Xechoerrout.sh', 'D') 195 \ ], 'Xechoerrout.sh', 'D')
195 call setfperm('Xechoerrout.sh', 'rwxrwx---') 196 call setfperm('Xechoerrout.sh', 'rwxrwx---')
196 197
197 let outfile = 'Xtermstdout' 198 let outfile = 'Xtermstdout'
198 let buf = term_start(['./Xechoerrout.sh'], {'out_io': 'file', 'out_name': outfile}) 199 let buf = term_start(['./Xechoerrout.sh'], {'out_io': 'file', 'out_name': outfile})
200 call TermWait(buf)
199 201
200 call WaitFor({-> !empty(readfile(outfile)) && !empty(term_getline(buf, 1))}) 202 call WaitFor({-> !empty(readfile(outfile)) && !empty(term_getline(buf, 1))})
201 call assert_equal(['this is standard out'], readfile(outfile)) 203 call assert_equal(['this is standard out'], readfile(outfile))
202 call assert_equal('this is standard error', term_getline(buf, 1)) 204 call assert_equal('this is standard error', term_getline(buf, 1))
203 205
214 216
215 " Let the terminal output more than 'termwinscroll' lines, some at the start 217 " Let the terminal output more than 'termwinscroll' lines, some at the start
216 " will be dropped. 218 " will be dropped.
217 exe 'set termwinscroll=' . &lines 219 exe 'set termwinscroll=' . &lines
218 let buf = term_start('/bin/sh') 220 let buf = term_start('/bin/sh')
221 call TermWait(buf)
219 for i in range(1, &lines) 222 for i in range(1, &lines)
220 call feedkeys("echo " . i . "\<CR>", 'xt') 223 call feedkeys("echo " . i . "\<CR>", 'xt')
221 call WaitForAssert({-> assert_match(string(i), term_getline(buf, term_getcursor(buf)[0] - 1))}) 224 call WaitForAssert({-> assert_match(string(i), term_getline(buf, term_getcursor(buf)[0] - 1))})
222 endfor 225 endfor
223 " Go to Terminal-Normal mode to update the buffer. 226 " Go to Terminal-Normal mode to update the buffer.
506 if !has('title') || empty(&t_ts) 509 if !has('title') || empty(&t_ts)
507 throw "Skipped: can't get/set title" 510 throw "Skipped: can't get/set title"
508 endif 511 endif
509 512
510 let term = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile', '-c', 'set title']) 513 let term = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile', '-c', 'set title'])
514 call TermWait(term)
511 " When Vim is running as a server then the title ends in VIM{number}, thus 515 " When Vim is running as a server then the title ends in VIM{number}, thus
512 " optionally match a number after "VIM". 516 " optionally match a number after "VIM".
513 call WaitForAssert({-> assert_match('^\[No Name\] - VIM\d*$', term_gettitle(term)) }) 517 call WaitForAssert({-> assert_match('^\[No Name\] - VIM\d*$', term_gettitle(term)) })
514 call term_sendkeys(term, ":e Xfoo\r") 518 call term_sendkeys(term, ":e Xfoo\r")
515 call WaitForAssert({-> assert_match('^Xfoo (.*[/\\]testdir) - VIM\d*$', term_gettitle(term)) }) 519 call WaitForAssert({-> assert_match('^Xfoo (.*[/\\]testdir) - VIM\d*$', term_gettitle(term)) })