mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 8.0.1776: in tests, when WaitFor() fails it doesn't say why
Problem: In tests, when WaitFor() fails it doesn't say why. Solution: Turn a few more WaitFor() into WaitForAssert().
This commit is contained in:
@@ -649,18 +649,15 @@ func Test_popup_and_window_resize()
|
|||||||
call term_sendkeys(buf, "\<c-v>")
|
call term_sendkeys(buf, "\<c-v>")
|
||||||
call term_wait(buf, 100)
|
call term_wait(buf, 100)
|
||||||
" popup first entry "!" must be at the top
|
" popup first entry "!" must be at the top
|
||||||
call WaitFor({-> term_getline(buf, 1) =~ "^!"})
|
call WaitForAssert({-> assert_match('^!\s*$', term_getline(buf, 1))})
|
||||||
call assert_match('^!\s*$', term_getline(buf, 1))
|
|
||||||
exe 'resize +' . (h - 1)
|
exe 'resize +' . (h - 1)
|
||||||
call term_wait(buf, 100)
|
call term_wait(buf, 100)
|
||||||
redraw!
|
redraw!
|
||||||
" popup shifted down, first line is now empty
|
" popup shifted down, first line is now empty
|
||||||
call WaitFor({-> term_getline(buf, 1) == ""})
|
call WaitForAssert({-> assert_equal('', term_getline(buf, 1))})
|
||||||
call assert_equal('', term_getline(buf, 1))
|
|
||||||
sleep 100m
|
sleep 100m
|
||||||
" popup is below cursor line and shows first match "!"
|
" popup is below cursor line and shows first match "!"
|
||||||
call WaitFor({-> term_getline(buf, term_getcursor(buf)[0] + 1) =~ "^!"})
|
call WaitForAssert({-> assert_match('^!\s*$', term_getline(buf, term_getcursor(buf)[0] + 1))})
|
||||||
call assert_match('^!\s*$', term_getline(buf, term_getcursor(buf)[0] + 1))
|
|
||||||
" cursor line also shows !
|
" cursor line also shows !
|
||||||
call assert_match('^!\s*$', term_getline(buf, term_getcursor(buf)[0]))
|
call assert_match('^!\s*$', term_getline(buf, term_getcursor(buf)[0]))
|
||||||
bwipe!
|
bwipe!
|
||||||
|
@@ -54,34 +54,33 @@ func Do_test_quotestar_for_x11()
|
|||||||
" Make sure a previous server has exited
|
" Make sure a previous server has exited
|
||||||
try
|
try
|
||||||
call remote_send(name, ":qa!\<CR>")
|
call remote_send(name, ":qa!\<CR>")
|
||||||
call WaitFor('serverlist() !~ "' . name . '"')
|
|
||||||
catch /E241:/
|
catch /E241:/
|
||||||
endtry
|
endtry
|
||||||
call assert_notmatch(name, serverlist())
|
call WaitForAssert({-> assert_notmatch(name, serverlist())})
|
||||||
|
|
||||||
let cmd .= ' --servername ' . name
|
let cmd .= ' --servername ' . name
|
||||||
let job = job_start(cmd, {'stoponexit': 'kill', 'out_io': 'null'})
|
let job = job_start(cmd, {'stoponexit': 'kill', 'out_io': 'null'})
|
||||||
call WaitFor({-> job_status(job) == "run"})
|
call WaitForAssert({-> assert_equal("run", job_status(job))})
|
||||||
|
|
||||||
" Takes a short while for the server to be active.
|
" Takes a short while for the server to be active.
|
||||||
call WaitFor('serverlist() =~ "' . name . '"')
|
call WaitForAssert({-> assert_match(name, serverlist())})
|
||||||
|
|
||||||
" Wait for the server to be up and answering requests. One second is not
|
" Wait for the server to be up and answering requests. One second is not
|
||||||
" always sufficient.
|
" always sufficient.
|
||||||
call WaitFor('remote_expr("' . name . '", "v:version", "", 2) != ""')
|
call WaitForAssert({-> assert_notequal('', remote_expr(name, "v:version", "", 2))})
|
||||||
|
|
||||||
" Clear the *-register of this vim instance and wait for it to be picked up
|
" Clear the *-register of this vim instance and wait for it to be picked up
|
||||||
" by the server.
|
" by the server.
|
||||||
let @* = 'no'
|
let @* = 'no'
|
||||||
call remote_foreground(name)
|
call remote_foreground(name)
|
||||||
call WaitFor('remote_expr("' . name . '", "@*", "", 1) == "no"')
|
call WaitForAssert({-> assert_equal("no", remote_expr(name, "@*", "", 1))})
|
||||||
|
|
||||||
" Set the * register on the server.
|
" Set the * register on the server.
|
||||||
call remote_send(name, ":let @* = 'yes'\<CR>")
|
call remote_send(name, ":let @* = 'yes'\<CR>")
|
||||||
call WaitFor('remote_expr("' . name . '", "@*", "", 1) == "yes"')
|
call WaitForAssert({-> assert_equal("yes", remote_expr(name, "@*", "", 1))})
|
||||||
|
|
||||||
" Check that the *-register of this vim instance is changed as expected.
|
" Check that the *-register of this vim instance is changed as expected.
|
||||||
call WaitFor('@* == "yes"')
|
call WaitForAssert({-> assert_equal("yes", @*)})
|
||||||
|
|
||||||
" Handle the large selection over 262040 byte.
|
" Handle the large selection over 262040 byte.
|
||||||
let length = 262044
|
let length = 262044
|
||||||
@@ -109,18 +108,17 @@ func Do_test_quotestar_for_x11()
|
|||||||
call remote_send(name, ":gui -f\<CR>")
|
call remote_send(name, ":gui -f\<CR>")
|
||||||
endif
|
endif
|
||||||
" Wait for the server in the GUI to be up and answering requests.
|
" Wait for the server in the GUI to be up and answering requests.
|
||||||
call WaitFor('remote_expr("' . name . '", "has(\"gui_running\")", "", 1) =~ "1"')
|
call WaitForAssert({-> assert_match("1", remote_expr(name, "has('gui_running')", "", 1))})
|
||||||
|
|
||||||
call remote_send(name, ":let @* = 'maybe'\<CR>")
|
call remote_send(name, ":let @* = 'maybe'\<CR>")
|
||||||
call WaitFor('remote_expr("' . name . '", "@*", "", 1) == "maybe"')
|
call WaitForAssert({-> assert_equal("maybe", remote_expr(name, "@*", "", 2))})
|
||||||
call assert_equal('maybe', remote_expr(name, "@*", "", 2))
|
|
||||||
|
|
||||||
call assert_equal('maybe', @*)
|
call assert_equal('maybe', @*)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call remote_send(name, ":qa!\<CR>")
|
call remote_send(name, ":qa!\<CR>")
|
||||||
try
|
try
|
||||||
call WaitFor({-> job_status(job) == "dead"})
|
call WaitForAssert({-> assert_equal("dead", job_status(job))})
|
||||||
finally
|
finally
|
||||||
if job_status(job) != 'dead'
|
if job_status(job) != 'dead'
|
||||||
call assert_report('Server did not exit')
|
call assert_report('Server did not exit')
|
||||||
|
@@ -494,7 +494,7 @@ func Test_search_cmdline8()
|
|||||||
call writefile(lines, 'Xsearch.txt')
|
call writefile(lines, 'Xsearch.txt')
|
||||||
let buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile', 'Xsearch.txt'], {'term_rows': 3})
|
let buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile', 'Xsearch.txt'], {'term_rows': 3})
|
||||||
|
|
||||||
call WaitFor({-> lines == [term_getline(buf, 1), term_getline(buf, 2)] })
|
call WaitForAssert({-> assert_equal(lines, [term_getline(buf, 1), term_getline(buf, 2)])})
|
||||||
|
|
||||||
call term_sendkeys(buf, ":set incsearch hlsearch\<cr>")
|
call term_sendkeys(buf, ":set incsearch hlsearch\<cr>")
|
||||||
call term_sendkeys(buf, ":14vsp\<cr>")
|
call term_sendkeys(buf, ":14vsp\<cr>")
|
||||||
@@ -619,7 +619,7 @@ func Test_search_cmdline_incsearch_highlight_attr()
|
|||||||
call writefile(lines, 'Xsearch.txt')
|
call writefile(lines, 'Xsearch.txt')
|
||||||
let buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile', 'Xsearch.txt'], {'term_rows': 3})
|
let buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile', 'Xsearch.txt'], {'term_rows': 3})
|
||||||
|
|
||||||
call WaitFor({-> lines == [term_getline(buf, 1), term_getline(buf, 2)] })
|
call WaitForAssert({-> assert_equal(lines, [term_getline(buf, 1), term_getline(buf, 2)])})
|
||||||
" wait for vim to complete initialization
|
" wait for vim to complete initialization
|
||||||
call term_wait(buf)
|
call term_wait(buf)
|
||||||
|
|
||||||
|
@@ -100,7 +100,6 @@ func Test_terminal_split_quit()
|
|||||||
|
|
||||||
quit!
|
quit!
|
||||||
call WaitForAssert({-> assert_equal('dead', job_status(g:job))})
|
call WaitForAssert({-> assert_equal('dead', job_status(g:job))})
|
||||||
call assert_equal('dead', job_status(g:job))
|
|
||||||
|
|
||||||
exe buf . 'bwipe'
|
exe buf . 'bwipe'
|
||||||
unlet g:job
|
unlet g:job
|
||||||
@@ -142,8 +141,8 @@ func Test_terminal_nasty_cb()
|
|||||||
let g:buf = term_start(cmd, {'exit_cb': function('s:Nasty_exit_cb')})
|
let g:buf = term_start(cmd, {'exit_cb': function('s:Nasty_exit_cb')})
|
||||||
let g:job = term_getjob(g:buf)
|
let g:job = term_getjob(g:buf)
|
||||||
|
|
||||||
call WaitFor('job_status(g:job) == "dead"')
|
call WaitForAssert({-> assert_equal("dead", job_status(g:job))})
|
||||||
call WaitFor('g:buf == 0')
|
call WaitForAssert({-> assert_equal(0, g:buf)})
|
||||||
unlet g:buf
|
unlet g:buf
|
||||||
unlet g:job
|
unlet g:job
|
||||||
call delete('Xtext')
|
call delete('Xtext')
|
||||||
@@ -190,12 +189,12 @@ func Test_terminal_scrape_123()
|
|||||||
call term_wait(buf)
|
call term_wait(buf)
|
||||||
" On MS-Windows we first get a startup message of two lines, wait for the
|
" On MS-Windows we first get a startup message of two lines, wait for the
|
||||||
" "cls" to happen, after that we have one line with three characters.
|
" "cls" to happen, after that we have one line with three characters.
|
||||||
call WaitFor({-> len(term_scrape(buf, 1)) == 3})
|
call WaitForAssert({-> assert_equal(3, len(term_scrape(buf, 1)))})
|
||||||
call Check_123(buf)
|
call Check_123(buf)
|
||||||
|
|
||||||
" Must still work after the job ended.
|
" Must still work after the job ended.
|
||||||
let job = term_getjob(buf)
|
let job = term_getjob(buf)
|
||||||
call WaitFor({-> job_status(job) == "dead"})
|
call WaitForAssert({-> assert_equal("dead", job_status(job))})
|
||||||
call term_wait(buf)
|
call term_wait(buf)
|
||||||
call Check_123(buf)
|
call Check_123(buf)
|
||||||
|
|
||||||
@@ -234,7 +233,7 @@ func Test_terminal_scrape_multibyte()
|
|||||||
call assert_equal('s', l[6].chars)
|
call assert_equal('s', l[6].chars)
|
||||||
|
|
||||||
let job = term_getjob(buf)
|
let job = term_getjob(buf)
|
||||||
call WaitFor({-> job_status(job) == "dead"})
|
call WaitForAssert({-> assert_equal("dead", job_status(job))})
|
||||||
call term_wait(buf)
|
call term_wait(buf)
|
||||||
|
|
||||||
exe buf . 'bwipe'
|
exe buf . 'bwipe'
|
||||||
@@ -251,7 +250,7 @@ func Test_terminal_scroll()
|
|||||||
let buf = term_start(cmd)
|
let buf = term_start(cmd)
|
||||||
|
|
||||||
let job = term_getjob(buf)
|
let job = term_getjob(buf)
|
||||||
call WaitFor({-> job_status(job) == "dead"})
|
call WaitForAssert({-> assert_equal("dead", job_status(job))})
|
||||||
call term_wait(buf)
|
call term_wait(buf)
|
||||||
if has('win32')
|
if has('win32')
|
||||||
" TODO: this should not be needed
|
" TODO: this should not be needed
|
||||||
@@ -281,7 +280,7 @@ func Test_terminal_scrollback()
|
|||||||
endif
|
endif
|
||||||
let rows = term_getsize(buf)[0]
|
let rows = term_getsize(buf)[0]
|
||||||
" On MS-Windows there is an empty line, check both last line and above it.
|
" On MS-Windows there is an empty line, check both last line and above it.
|
||||||
call WaitFor({-> term_getline(buf, rows - 1) . term_getline(buf, rows - 2) =~ '149'})
|
call WaitForAssert({-> assert_match( '149', term_getline(buf, rows - 1) . term_getline(buf, rows - 2))})
|
||||||
let lines = line('$')
|
let lines = line('$')
|
||||||
call assert_inrange(91, 100, lines)
|
call assert_inrange(91, 100, lines)
|
||||||
|
|
||||||
@@ -408,16 +407,16 @@ func Test_terminal_finish_open_close()
|
|||||||
let buf = bufnr('%')
|
let buf = bufnr('%')
|
||||||
call assert_equal(2, winnr('$'))
|
call assert_equal(2, winnr('$'))
|
||||||
" Wait for the shell to display a prompt
|
" Wait for the shell to display a prompt
|
||||||
call WaitFor({-> term_getline(buf, 1) != ""})
|
call WaitForAssert({-> assert_notequal('', term_getline(buf, 1))})
|
||||||
call Stop_shell_in_terminal(buf)
|
call Stop_shell_in_terminal(buf)
|
||||||
call WaitFor("winnr('$') == 1", waittime)
|
call WaitForAssert({-> assert_equal(1, winnr('$'))}, waittime)
|
||||||
|
|
||||||
" shell terminal that does not close automatically
|
" shell terminal that does not close automatically
|
||||||
terminal ++noclose
|
terminal ++noclose
|
||||||
let buf = bufnr('%')
|
let buf = bufnr('%')
|
||||||
call assert_equal(2, winnr('$'))
|
call assert_equal(2, winnr('$'))
|
||||||
" Wait for the shell to display a prompt
|
" Wait for the shell to display a prompt
|
||||||
call WaitFor({-> term_getline(buf, 1) != ""})
|
call WaitForAssert({-> assert_notequal('', term_getline(buf, 1))})
|
||||||
call Stop_shell_in_terminal(buf)
|
call Stop_shell_in_terminal(buf)
|
||||||
call assert_equal(2, winnr('$'))
|
call assert_equal(2, winnr('$'))
|
||||||
quit
|
quit
|
||||||
@@ -426,36 +425,32 @@ func Test_terminal_finish_open_close()
|
|||||||
exe 'terminal ++close ' . cmd
|
exe 'terminal ++close ' . cmd
|
||||||
call assert_equal(2, winnr('$'))
|
call assert_equal(2, winnr('$'))
|
||||||
wincmd p
|
wincmd p
|
||||||
call WaitFor("winnr('$') == 1", waittime)
|
call WaitForAssert({-> assert_equal(1, winnr('$'))}, waittime)
|
||||||
|
|
||||||
call term_start(cmd, {'term_finish': 'close'})
|
call term_start(cmd, {'term_finish': 'close'})
|
||||||
call assert_equal(2, winnr('$'))
|
call assert_equal(2, winnr('$'))
|
||||||
wincmd p
|
wincmd p
|
||||||
call WaitFor("winnr('$') == 1", waittime)
|
call WaitForAssert({-> assert_equal(1, winnr('$'))}, waittime)
|
||||||
call assert_equal(1, winnr('$'))
|
call assert_equal(1, winnr('$'))
|
||||||
|
|
||||||
exe 'terminal ++open ' . cmd
|
exe 'terminal ++open ' . cmd
|
||||||
close!
|
close!
|
||||||
call WaitFor("winnr('$') == 2", waittime)
|
call WaitForAssert({-> assert_equal(2, winnr('$'))}, waittime)
|
||||||
call assert_equal(2, winnr('$'))
|
|
||||||
bwipe
|
bwipe
|
||||||
|
|
||||||
call term_start(cmd, {'term_finish': 'open'})
|
call term_start(cmd, {'term_finish': 'open'})
|
||||||
close!
|
close!
|
||||||
call WaitFor("winnr('$') == 2", waittime)
|
call WaitForAssert({-> assert_equal(2, winnr('$'))}, waittime)
|
||||||
call assert_equal(2, winnr('$'))
|
|
||||||
bwipe
|
bwipe
|
||||||
|
|
||||||
exe 'terminal ++hidden ++open ' . cmd
|
exe 'terminal ++hidden ++open ' . cmd
|
||||||
call assert_equal(1, winnr('$'))
|
call assert_equal(1, winnr('$'))
|
||||||
call WaitFor("winnr('$') == 2", waittime)
|
call WaitForAssert({-> assert_equal(2, winnr('$'))}, waittime)
|
||||||
call assert_equal(2, winnr('$'))
|
|
||||||
bwipe
|
bwipe
|
||||||
|
|
||||||
call term_start(cmd, {'term_finish': 'open', 'hidden': 1})
|
call term_start(cmd, {'term_finish': 'open', 'hidden': 1})
|
||||||
call assert_equal(1, winnr('$'))
|
call assert_equal(1, winnr('$'))
|
||||||
call WaitFor("winnr('$') == 2", waittime)
|
call WaitForAssert({-> assert_equal(2, winnr('$'))}, waittime)
|
||||||
call assert_equal(2, winnr('$'))
|
|
||||||
bwipe
|
bwipe
|
||||||
|
|
||||||
call assert_fails("call term_start(cmd, {'term_opencmd': 'open'})", 'E475:')
|
call assert_fails("call term_start(cmd, {'term_opencmd': 'open'})", 'E475:')
|
||||||
@@ -465,8 +460,7 @@ func Test_terminal_finish_open_close()
|
|||||||
|
|
||||||
call term_start(cmd, {'term_finish': 'open', 'term_opencmd': '4split | buffer %d'})
|
call term_start(cmd, {'term_finish': 'open', 'term_opencmd': '4split | buffer %d'})
|
||||||
close!
|
close!
|
||||||
call WaitFor("winnr('$') == 2", waittime)
|
call WaitForAssert({-> assert_equal(2, winnr('$'))}, waittime)
|
||||||
call assert_equal(2, winnr('$'))
|
|
||||||
call assert_equal(4, winheight(0))
|
call assert_equal(4, winheight(0))
|
||||||
bwipe
|
bwipe
|
||||||
endfunc
|
endfunc
|
||||||
@@ -477,8 +471,7 @@ func Test_terminal_cwd()
|
|||||||
endif
|
endif
|
||||||
call mkdir('Xdir')
|
call mkdir('Xdir')
|
||||||
let buf = term_start('pwd', {'cwd': 'Xdir'})
|
let buf = term_start('pwd', {'cwd': 'Xdir'})
|
||||||
call WaitFor('"Xdir" == fnamemodify(getline(1), ":t")')
|
call WaitForAssert({-> assert_equal('Xdir', fnamemodify(getline(1), ":t"))})
|
||||||
call assert_equal('Xdir', fnamemodify(getline(1), ":t"))
|
|
||||||
|
|
||||||
exe buf . 'bwipe'
|
exe buf . 'bwipe'
|
||||||
call delete('Xdir', 'rf')
|
call delete('Xdir', 'rf')
|
||||||
@@ -490,7 +483,7 @@ func Test_terminal_servername()
|
|||||||
endif
|
endif
|
||||||
let buf = Run_shell_in_terminal({})
|
let buf = Run_shell_in_terminal({})
|
||||||
" Wait for the shell to display a prompt
|
" Wait for the shell to display a prompt
|
||||||
call WaitFor({-> term_getline(buf, 1) != ""})
|
call WaitForAssert({-> assert_notequal('', term_getline(buf, 1))})
|
||||||
if has('win32')
|
if has('win32')
|
||||||
call term_sendkeys(buf, "echo %VIM_SERVERNAME%\r")
|
call term_sendkeys(buf, "echo %VIM_SERVERNAME%\r")
|
||||||
else
|
else
|
||||||
@@ -508,7 +501,7 @@ endfunc
|
|||||||
func Test_terminal_env()
|
func Test_terminal_env()
|
||||||
let buf = Run_shell_in_terminal({'env': {'TESTENV': 'correct'}})
|
let buf = Run_shell_in_terminal({'env': {'TESTENV': 'correct'}})
|
||||||
" Wait for the shell to display a prompt
|
" Wait for the shell to display a prompt
|
||||||
call WaitFor({-> term_getline(buf, 1) != ""})
|
call WaitForAssert({-> assert_notequal('', term_getline(buf, 1))})
|
||||||
if has('win32')
|
if has('win32')
|
||||||
call term_sendkeys(buf, "echo %TESTENV%\r")
|
call term_sendkeys(buf, "echo %TESTENV%\r")
|
||||||
else
|
else
|
||||||
@@ -516,8 +509,7 @@ func Test_terminal_env()
|
|||||||
endif
|
endif
|
||||||
call term_wait(buf)
|
call term_wait(buf)
|
||||||
call Stop_shell_in_terminal(buf)
|
call Stop_shell_in_terminal(buf)
|
||||||
call WaitFor('getline(2) == "correct"')
|
call WaitForAssert({-> assert_equal('correct', getline(2))})
|
||||||
call assert_equal('correct', getline(2))
|
|
||||||
|
|
||||||
exe buf . 'bwipe'
|
exe buf . 'bwipe'
|
||||||
endfunc
|
endfunc
|
||||||
@@ -539,8 +531,7 @@ func Test_zz_terminal_in_gui()
|
|||||||
call term_wait(buf)
|
call term_wait(buf)
|
||||||
|
|
||||||
" closing window wipes out the terminal buffer a with finished job
|
" closing window wipes out the terminal buffer a with finished job
|
||||||
call WaitFor("winnr('$') == 1")
|
call WaitForAssert({-> assert_equal(1, winnr('$'))})
|
||||||
call assert_equal(1, winnr('$'))
|
|
||||||
call assert_equal("", bufname(buf))
|
call assert_equal("", bufname(buf))
|
||||||
|
|
||||||
unlet g:job
|
unlet g:job
|
||||||
@@ -592,7 +583,7 @@ func Test_terminal_write_stdin()
|
|||||||
new
|
new
|
||||||
call setline(1, ['one', 'two', 'three'])
|
call setline(1, ['one', 'two', 'three'])
|
||||||
%term wc
|
%term wc
|
||||||
call WaitFor('getline("$") =~ "3"')
|
call WaitForAssert({-> assert_match('3', getline("$"))})
|
||||||
let nrs = split(getline('$'))
|
let nrs = split(getline('$'))
|
||||||
call assert_equal(['3', '3', '14'], nrs)
|
call assert_equal(['3', '3', '14'], nrs)
|
||||||
bwipe
|
bwipe
|
||||||
@@ -600,7 +591,7 @@ func Test_terminal_write_stdin()
|
|||||||
new
|
new
|
||||||
call setline(1, ['one', 'two', 'three', 'four'])
|
call setline(1, ['one', 'two', 'three', 'four'])
|
||||||
2,3term wc
|
2,3term wc
|
||||||
call WaitFor('getline("$") =~ "2"')
|
call WaitForAssert({-> assert_match('2', getline("$"))})
|
||||||
let nrs = split(getline('$'))
|
let nrs = split(getline('$'))
|
||||||
call assert_equal(['2', '2', '10'], nrs)
|
call assert_equal(['2', '2', '10'], nrs)
|
||||||
bwipe
|
bwipe
|
||||||
@@ -622,7 +613,7 @@ func Test_terminal_write_stdin()
|
|||||||
new
|
new
|
||||||
call setline(1, ['print("hello")'])
|
call setline(1, ['print("hello")'])
|
||||||
1term ++eof=<C-Z> python
|
1term ++eof=<C-Z> python
|
||||||
call WaitFor('getline("$") =~ "Z"')
|
call WaitForAssert({-> assert_match('Z', getline("$"))})
|
||||||
call assert_equal('hello', getline(line('$') - 1))
|
call assert_equal('hello', getline(line('$') - 1))
|
||||||
bwipe
|
bwipe
|
||||||
endif
|
endif
|
||||||
@@ -646,9 +637,8 @@ func Test_terminal_no_cmd()
|
|||||||
else
|
else
|
||||||
call system('echo "look here" > ' . pty)
|
call system('echo "look here" > ' . pty)
|
||||||
endif
|
endif
|
||||||
call WaitFor({-> term_getline(buf, 1) =~ "look here"})
|
call WaitForAssert({-> assert_match('look here', term_getline(buf, 1))})
|
||||||
|
|
||||||
call assert_match('look here', term_getline(buf, 1))
|
|
||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@@ -660,8 +650,7 @@ func Test_terminal_special_chars()
|
|||||||
call mkdir('Xdir with spaces')
|
call mkdir('Xdir with spaces')
|
||||||
call writefile(['x'], 'Xdir with spaces/quoted"file')
|
call writefile(['x'], 'Xdir with spaces/quoted"file')
|
||||||
term ls Xdir\ with\ spaces/quoted\"file
|
term ls Xdir\ with\ spaces/quoted\"file
|
||||||
call WaitFor('term_getline("", 1) =~ "quoted"')
|
call WaitForAssert({-> assert_match('quoted"file', term_getline('', 1))})
|
||||||
call assert_match('quoted"file', term_getline('', 1))
|
|
||||||
call term_wait('')
|
call term_wait('')
|
||||||
|
|
||||||
call delete('Xdir with spaces', 'rf')
|
call delete('Xdir with spaces', 'rf')
|
||||||
@@ -691,10 +680,10 @@ func Test_terminal_redir_file()
|
|||||||
let cmd = Get_cat_123_cmd()
|
let cmd = Get_cat_123_cmd()
|
||||||
let buf = term_start(cmd, {'out_io': 'file', 'out_name': 'Xfile'})
|
let buf = term_start(cmd, {'out_io': 'file', 'out_name': 'Xfile'})
|
||||||
call term_wait(buf)
|
call term_wait(buf)
|
||||||
call WaitFor('len(readfile("Xfile")) > 0')
|
call WaitForAssert({-> assert_notequal(0, len(readfile("Xfile")))})
|
||||||
call assert_match('123', readfile('Xfile')[0])
|
call assert_match('123', readfile('Xfile')[0])
|
||||||
let g:job = term_getjob(buf)
|
let g:job = term_getjob(buf)
|
||||||
call WaitFor('job_status(g:job) == "dead"')
|
call WaitForAssert({-> assert_equal("dead", job_status(g:job))})
|
||||||
call delete('Xfile')
|
call delete('Xfile')
|
||||||
bwipe
|
bwipe
|
||||||
endif
|
endif
|
||||||
@@ -703,10 +692,9 @@ func Test_terminal_redir_file()
|
|||||||
call writefile(['one line'], 'Xfile')
|
call writefile(['one line'], 'Xfile')
|
||||||
let buf = term_start('cat', {'in_io': 'file', 'in_name': 'Xfile'})
|
let buf = term_start('cat', {'in_io': 'file', 'in_name': 'Xfile'})
|
||||||
call term_wait(buf)
|
call term_wait(buf)
|
||||||
call WaitFor('term_getline(' . buf . ', 1) == "one line"')
|
call WaitForAssert({-> assert_equal('one line', term_getline(buf, 1))})
|
||||||
call assert_equal('one line', term_getline(buf, 1))
|
|
||||||
let g:job = term_getjob(buf)
|
let g:job = term_getjob(buf)
|
||||||
call WaitFor('job_status(g:job) == "dead"')
|
call WaitForAssert({-> assert_equal('dead', job_status(g:job))})
|
||||||
bwipe
|
bwipe
|
||||||
call delete('Xfile')
|
call delete('Xfile')
|
||||||
endif
|
endif
|
||||||
@@ -726,7 +714,7 @@ func TerminalTmap(remap)
|
|||||||
call assert_equal('456', maparg('123', 't'))
|
call assert_equal('456', maparg('123', 't'))
|
||||||
call assert_equal('abxde', maparg('456', 't'))
|
call assert_equal('abxde', maparg('456', 't'))
|
||||||
call feedkeys("123", 'tx')
|
call feedkeys("123", 'tx')
|
||||||
call WaitFor({-> term_getline(buf, term_getcursor(buf)[0]) =~ 'abxde\|456'})
|
call WaitForAssert({-> assert_match('abxde\|456', term_getline(buf, term_getcursor(buf)[0]))})
|
||||||
let lnum = term_getcursor(buf)[0]
|
let lnum = term_getcursor(buf)[0]
|
||||||
if a:remap
|
if a:remap
|
||||||
call assert_match('abxde', term_getline(buf, lnum))
|
call assert_match('abxde', term_getline(buf, lnum))
|
||||||
@@ -825,8 +813,7 @@ func Test_terminal_composing_unicode()
|
|||||||
call assert_equal("\u00a0\u0308", l[3].chars)
|
call assert_equal("\u00a0\u0308", l[3].chars)
|
||||||
|
|
||||||
call term_sendkeys(buf, "exit\r")
|
call term_sendkeys(buf, "exit\r")
|
||||||
call WaitFor('job_status(g:job) == "dead"')
|
call WaitForAssert({-> assert_equal('dead', job_status(g:job))})
|
||||||
call assert_equal('dead', job_status(g:job))
|
|
||||||
bwipe!
|
bwipe!
|
||||||
unlet g:job
|
unlet g:job
|
||||||
let &encoding = save_enc
|
let &encoding = save_enc
|
||||||
@@ -849,7 +836,7 @@ func Test_terminal_aucmd_on_close()
|
|||||||
call setline(1, ['one', 'two'])
|
call setline(1, ['one', 'two'])
|
||||||
exe 'term ++close ' . cmd
|
exe 'term ++close ' . cmd
|
||||||
wincmd p
|
wincmd p
|
||||||
call WaitFor("winnr('$') == 2", waittime)
|
call WaitForAssert({-> assert_equal(2, winnr('$'))}, waittime)
|
||||||
call assert_equal(1, s:called)
|
call assert_equal(1, s:called)
|
||||||
bwipe!
|
bwipe!
|
||||||
|
|
||||||
@@ -875,16 +862,16 @@ func Test_terminal_response_to_control_sequence()
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
let buf = Run_shell_in_terminal({})
|
let buf = Run_shell_in_terminal({})
|
||||||
call WaitFor({-> term_getline(buf, 1) != ''})
|
call WaitForAssert({-> assert_notequal('', term_getline(buf, 1))})
|
||||||
|
|
||||||
call term_sendkeys(buf, "cat\<CR>")
|
call term_sendkeys(buf, "cat\<CR>")
|
||||||
call WaitFor({-> term_getline(buf, 1) =~ 'cat'})
|
call WaitForAssert({-> assert_match('cat', term_getline(buf, 1))})
|
||||||
|
|
||||||
" Request the cursor position.
|
" Request the cursor position.
|
||||||
call term_sendkeys(buf, "\x1b[6n\<CR>")
|
call term_sendkeys(buf, "\x1b[6n\<CR>")
|
||||||
|
|
||||||
" Wait for output from tty to display, below an empty line.
|
" Wait for output from tty to display, below an empty line.
|
||||||
call WaitFor({-> term_getline(buf, 4) =~ '3;1R'})
|
call WaitForAssert({-> assert_match('3;1R', term_getline(buf, 4))})
|
||||||
|
|
||||||
" End "cat" gently.
|
" End "cat" gently.
|
||||||
call term_sendkeys(buf, "\<CR>\<C-D>")
|
call term_sendkeys(buf, "\<CR>\<C-D>")
|
||||||
@@ -961,14 +948,14 @@ func Test_terminal_qall_prompt()
|
|||||||
|
|
||||||
" Open a terminal window and wait for the prompt to appear
|
" Open a terminal window and wait for the prompt to appear
|
||||||
call term_sendkeys(buf, ":term\<CR>")
|
call term_sendkeys(buf, ":term\<CR>")
|
||||||
call WaitFor({-> term_getline(buf, 10) =~ '\[running]'})
|
call WaitForAssert({-> assert_match('\[running]', term_getline(buf, 10))})
|
||||||
call WaitFor({-> term_getline(buf, 1) !~ '^\s*$'})
|
call WaitForAssert({-> assert_notmatch('^\s*$', term_getline(buf, 1))})
|
||||||
|
|
||||||
" make Vim exit, it will prompt to kill the shell
|
" make Vim exit, it will prompt to kill the shell
|
||||||
call term_sendkeys(buf, "\<C-W>:confirm qall\<CR>")
|
call term_sendkeys(buf, "\<C-W>:confirm qall\<CR>")
|
||||||
call WaitFor({-> term_getline(buf, 20) =~ 'ancel:'})
|
call WaitForAssert({-> assert_match('ancel:', term_getline(buf, 20))})
|
||||||
call term_sendkeys(buf, "y")
|
call term_sendkeys(buf, "y")
|
||||||
call WaitFor({-> term_getstatus(buf) == "finished"})
|
call WaitForAssert({-> assert_equal('finished', term_getstatus(buf))})
|
||||||
|
|
||||||
" close the terminal window where Vim was running
|
" close the terminal window where Vim was running
|
||||||
quit
|
quit
|
||||||
@@ -1025,7 +1012,7 @@ func Test_terminal_dumpwrite_composing()
|
|||||||
let text = " a\u0300 e\u0302 o\u0308"
|
let text = " a\u0300 e\u0302 o\u0308"
|
||||||
call writefile([text], 'Xcomposing')
|
call writefile([text], 'Xcomposing')
|
||||||
let buf = RunVimInTerminal('Xcomposing', {})
|
let buf = RunVimInTerminal('Xcomposing', {})
|
||||||
call WaitFor({-> term_getline(buf, 1) =~ text})
|
call WaitForAssert({-> assert_match(text, term_getline(buf, 1))})
|
||||||
call term_dumpwrite(buf, 'Xdump')
|
call term_dumpwrite(buf, 'Xdump')
|
||||||
let dumpline = readfile('Xdump')[0]
|
let dumpline = readfile('Xdump')[0]
|
||||||
call assert_match('|à| |ê| |ö', dumpline)
|
call assert_match('|à| |ê| |ö', dumpline)
|
||||||
@@ -1235,7 +1222,7 @@ func Test_terminal_api_drop_oldwin()
|
|||||||
\ "set t_ts=",
|
\ "set t_ts=",
|
||||||
\ ], 'Xscript')
|
\ ], 'Xscript')
|
||||||
let buf = RunVimInTerminal('-S Xscript', {'rows': 10})
|
let buf = RunVimInTerminal('-S Xscript', {'rows': 10})
|
||||||
call WaitFor({-> expand('%:t') =='Xtextfile'})
|
call WaitForAssert({-> assert_equal('Xtextfile', expand('%:t'))})
|
||||||
call assert_equal(textfile_winid, win_getid())
|
call assert_equal(textfile_winid, win_getid())
|
||||||
|
|
||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
@@ -1284,7 +1271,7 @@ func Test_terminal_api_call_fails()
|
|||||||
call WriteApiCall('TryThis')
|
call WriteApiCall('TryThis')
|
||||||
call ch_logfile('Xlog', 'w')
|
call ch_logfile('Xlog', 'w')
|
||||||
let buf = RunVimInTerminal('-S Xscript', {})
|
let buf = RunVimInTerminal('-S Xscript', {})
|
||||||
call WaitFor({-> string(readfile('Xlog')) =~ 'Invalid function name: TryThis'})
|
call WaitForAssert({-> assert_match('Invalid function name: TryThis', string(readfile('Xlog')))})
|
||||||
|
|
||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
call delete('Xscript')
|
call delete('Xscript')
|
||||||
@@ -1309,7 +1296,7 @@ func Test_terminal_api_call_fail_delete()
|
|||||||
|
|
||||||
call WriteApiCall('Tapi_Delete')
|
call WriteApiCall('Tapi_Delete')
|
||||||
let buf = RunVimInTerminal('-S Xscript', {})
|
let buf = RunVimInTerminal('-S Xscript', {})
|
||||||
call WaitFor({-> s:caught_e937 == 1})
|
call WaitForAssert({-> assert_equal(1, s:caught_e937)})
|
||||||
|
|
||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
call delete('Xscript')
|
call delete('Xscript')
|
||||||
|
@@ -143,7 +143,7 @@ endfunc
|
|||||||
func Test_delete_myself()
|
func Test_delete_myself()
|
||||||
let g:called = 0
|
let g:called = 0
|
||||||
let t = timer_start(10, 'StopMyself', {'repeat': -1})
|
let t = timer_start(10, 'StopMyself', {'repeat': -1})
|
||||||
call WaitFor('g:called == 2')
|
call WaitForAssert({-> assert_equal(2, g:called)})
|
||||||
call assert_equal(2, g:called)
|
call assert_equal(2, g:called)
|
||||||
call assert_equal([], timer_info(t))
|
call assert_equal([], timer_info(t))
|
||||||
endfunc
|
endfunc
|
||||||
@@ -206,7 +206,7 @@ func Test_timer_errors()
|
|||||||
let g:call_count = 0
|
let g:call_count = 0
|
||||||
let timer = timer_start(10, 'FuncWithError', {'repeat': -1})
|
let timer = timer_start(10, 'FuncWithError', {'repeat': -1})
|
||||||
" Timer will be stopped after failing 3 out of 3 times.
|
" Timer will be stopped after failing 3 out of 3 times.
|
||||||
call WaitFor('g:call_count == 3')
|
call WaitForAssert({-> assert_equal(3, g:call_count)})
|
||||||
sleep 50m
|
sleep 50m
|
||||||
call assert_equal(3, g:call_count)
|
call assert_equal(3, g:call_count)
|
||||||
endfunc
|
endfunc
|
||||||
@@ -224,7 +224,7 @@ func Test_timer_catch_error()
|
|||||||
let g:call_count = 0
|
let g:call_count = 0
|
||||||
let timer = timer_start(10, 'FuncWithCaughtError', {'repeat': 4})
|
let timer = timer_start(10, 'FuncWithCaughtError', {'repeat': 4})
|
||||||
" Timer will not be stopped.
|
" Timer will not be stopped.
|
||||||
call WaitFor('g:call_count == 4')
|
call WaitForAssert({-> assert_equal(4, g:call_count)})
|
||||||
sleep 50m
|
sleep 50m
|
||||||
call assert_equal(4, g:call_count)
|
call assert_equal(4, g:call_count)
|
||||||
endfunc
|
endfunc
|
||||||
|
@@ -761,6 +761,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1776,
|
||||||
/**/
|
/**/
|
||||||
1775,
|
1775,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user