Mercurial > vim
comparison src/testdir/test_terminal.vim @ 12120:017031c7717e v8.0.0940
patch 8.0.0940: Test_terminal_scrape_multibyte is flaky
commit https://github.com/vim/vim/commit/c08706135d006453784f85d211c76e27b4f2a6d0
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Aug 14 22:01:16 2017 +0200
patch 8.0.0940: Test_terminal_scrape_multibyte is flaky
Problem: Test_terminal_scrape_multibyte is flaky. (James McCoy)
Solution: Use WaitFor() instead of term_wait().
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 14 Aug 2017 22:15:04 +0200 |
parents | bf53df1f17ba |
children | bb43ab26381e |
comparison
equal
deleted
inserted
replaced
12119:a7e24c12df21 | 12120:017031c7717e |
---|---|
187 if has('win32') | 187 if has('win32') |
188 let cmd = 'cmd /c "type Xtext"' | 188 let cmd = 'cmd /c "type Xtext"' |
189 else | 189 else |
190 let cmd = "cat Xtext" | 190 let cmd = "cat Xtext" |
191 endif | 191 endif |
192 let buf = term_start(cmd) | 192 let g:buf = term_start(cmd) |
193 | 193 |
194 call term_wait(buf) | 194 call WaitFor('term_scrape(g:buf, 1)[0].chars == "l"') |
195 if has('win32') | 195 let l = term_scrape(g:buf, 1) |
196 " TODO: this should not be needed | |
197 sleep 100m | |
198 endif | |
199 | |
200 let l = term_scrape(buf, 1) | |
201 call assert_true(len(l) >= 7) | 196 call assert_true(len(l) >= 7) |
202 call assert_equal('l', l[0].chars) | 197 call assert_equal('l', l[0].chars) |
203 call assert_equal('é', l[1].chars) | 198 call assert_equal('é', l[1].chars) |
204 call assert_equal(1, l[1].width) | 199 call assert_equal(1, l[1].width) |
205 call assert_equal('t', l[2].chars) | 200 call assert_equal('t', l[2].chars) |
207 call assert_equal('ま', l[4].chars) | 202 call assert_equal('ま', l[4].chars) |
208 call assert_equal(2, l[4].width) | 203 call assert_equal(2, l[4].width) |
209 call assert_equal('r', l[5].chars) | 204 call assert_equal('r', l[5].chars) |
210 call assert_equal('s', l[6].chars) | 205 call assert_equal('s', l[6].chars) |
211 | 206 |
212 let g:job = term_getjob(buf) | 207 let g:job = term_getjob(g:buf) |
213 call WaitFor('job_status(g:job) == "dead"') | 208 call WaitFor('job_status(g:job) == "dead"') |
214 call term_wait(buf) | 209 call term_wait(g:buf) |
215 | 210 |
216 exe buf . 'bwipe' | 211 exe g:buf . 'bwipe' |
212 unlet g:buf | |
217 call delete('Xtext') | 213 call delete('Xtext') |
218 endfunc | 214 endfunc |
219 | 215 |
220 func Test_terminal_scroll() | 216 func Test_terminal_scroll() |
221 call writefile(range(1, 200), 'Xtext') | 217 call writefile(range(1, 200), 'Xtext') |
407 | 403 |
408 func Test_terminal_env() | 404 func Test_terminal_env() |
409 if !has('unix') | 405 if !has('unix') |
410 return | 406 return |
411 endif | 407 endif |
412 let buf = Run_shell_in_terminal({'env': {'TESTENV': 'correct'}}) | 408 let g:buf = Run_shell_in_terminal({'env': {'TESTENV': 'correct'}}) |
413 " Wait for the shell to display a prompt | 409 " Wait for the shell to display a prompt |
414 call WaitFor('term_getline(1) != ""') | 410 call WaitFor('term_getline(g:buf, 1) != ""') |
415 call term_sendkeys(buf, "echo $TESTENV\r") | 411 call term_sendkeys(g:buf, "echo $TESTENV\r") |
416 call term_wait(buf) | 412 call term_wait(g:buf) |
417 call Stop_shell_in_terminal(buf) | 413 call Stop_shell_in_terminal(g:buf) |
418 call WaitFor('getline(2) == "correct"') | 414 call WaitFor('getline(2) == "correct"') |
419 call assert_equal('correct', getline(2)) | 415 call assert_equal('correct', getline(2)) |
420 | 416 |
421 exe buf . 'bwipe' | 417 exe g:buf . 'bwipe' |
418 unlet g:buf | |
422 endfunc | 419 endfunc |
423 | 420 |
424 " must be last, we can't go back from GUI to terminal | 421 " must be last, we can't go back from GUI to terminal |
425 func Test_zz_terminal_in_gui() | 422 func Test_zz_terminal_in_gui() |
426 if !CanRunGui() | 423 if !CanRunGui() |