" Make sure a previous server has exited
try
call remote_send(name, ":qa!\<CR>")
- call WaitFor('serverlist() !~ "' . name . '"')
catch /E241:/
endtry
- call assert_notmatch(name, serverlist())
+ call WaitForAssert({-> assert_notmatch(name, serverlist())})
let cmd .= ' --servername ' . name
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.
- call WaitFor('serverlist() =~ "' . name . '"')
+ call WaitForAssert({-> assert_match(name, serverlist())})
" Wait for the server to be up and answering requests. One second is not
" 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
" by the server.
let @* = 'no'
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.
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.
- call WaitFor('@* == "yes"')
+ call WaitForAssert({-> assert_equal("yes", @*)})
" Handle the large selection over 262040 byte.
let length = 262044
call remote_send(name, ":gui -f\<CR>")
endif
" 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 WaitFor('remote_expr("' . name . '", "@*", "", 1) == "maybe"')
- call assert_equal('maybe', remote_expr(name, "@*", "", 2))
+ call WaitForAssert({-> assert_equal("maybe", remote_expr(name, "@*", "", 2))})
call assert_equal('maybe', @*)
endif
call remote_send(name, ":qa!\<CR>")
try
- call WaitFor({-> job_status(job) == "dead"})
+ call WaitForAssert({-> assert_equal("dead", job_status(job))})
finally
if job_status(job) != 'dead'
call assert_report('Server did not exit')
quit!
call WaitForAssert({-> assert_equal('dead', job_status(g:job))})
- call assert_equal('dead', job_status(g:job))
exe buf . 'bwipe'
unlet g:job
let g:buf = term_start(cmd, {'exit_cb': function('s:Nasty_exit_cb')})
let g:job = term_getjob(g:buf)
- call WaitFor('job_status(g:job) == "dead"')
- call WaitFor('g:buf == 0')
+ call WaitForAssert({-> assert_equal("dead", job_status(g:job))})
+ call WaitForAssert({-> assert_equal(0, g:buf)})
unlet g:buf
unlet g:job
call delete('Xtext')
call term_wait(buf)
" 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.
- call WaitFor({-> len(term_scrape(buf, 1)) == 3})
+ call WaitForAssert({-> assert_equal(3, len(term_scrape(buf, 1)))})
call Check_123(buf)
" Must still work after the job ended.
let job = term_getjob(buf)
- call WaitFor({-> job_status(job) == "dead"})
+ call WaitForAssert({-> assert_equal("dead", job_status(job))})
call term_wait(buf)
call Check_123(buf)
call assert_equal('s', l[6].chars)
let job = term_getjob(buf)
- call WaitFor({-> job_status(job) == "dead"})
+ call WaitForAssert({-> assert_equal("dead", job_status(job))})
call term_wait(buf)
exe buf . 'bwipe'
let buf = term_start(cmd)
let job = term_getjob(buf)
- call WaitFor({-> job_status(job) == "dead"})
+ call WaitForAssert({-> assert_equal("dead", job_status(job))})
call term_wait(buf)
if has('win32')
" TODO: this should not be needed
endif
let rows = term_getsize(buf)[0]
" 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('$')
call assert_inrange(91, 100, lines)
let buf = bufnr('%')
call assert_equal(2, winnr('$'))
" 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 WaitFor("winnr('$') == 1", waittime)
+ call WaitForAssert({-> assert_equal(1, winnr('$'))}, waittime)
" shell terminal that does not close automatically
terminal ++noclose
let buf = bufnr('%')
call assert_equal(2, winnr('$'))
" 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 assert_equal(2, winnr('$'))
quit
exe 'terminal ++close ' . cmd
call assert_equal(2, winnr('$'))
wincmd p
- call WaitFor("winnr('$') == 1", waittime)
+ call WaitForAssert({-> assert_equal(1, winnr('$'))}, waittime)
call term_start(cmd, {'term_finish': 'close'})
call assert_equal(2, winnr('$'))
wincmd p
- call WaitFor("winnr('$') == 1", waittime)
+ call WaitForAssert({-> assert_equal(1, winnr('$'))}, waittime)
call assert_equal(1, winnr('$'))
exe 'terminal ++open ' . cmd
close!
- call WaitFor("winnr('$') == 2", waittime)
- call assert_equal(2, winnr('$'))
+ call WaitForAssert({-> assert_equal(2, winnr('$'))}, waittime)
bwipe
call term_start(cmd, {'term_finish': 'open'})
close!
- call WaitFor("winnr('$') == 2", waittime)
- call assert_equal(2, winnr('$'))
+ call WaitForAssert({-> assert_equal(2, winnr('$'))}, waittime)
bwipe
exe 'terminal ++hidden ++open ' . cmd
call assert_equal(1, winnr('$'))
- call WaitFor("winnr('$') == 2", waittime)
- call assert_equal(2, winnr('$'))
+ call WaitForAssert({-> assert_equal(2, winnr('$'))}, waittime)
bwipe
call term_start(cmd, {'term_finish': 'open', 'hidden': 1})
call assert_equal(1, winnr('$'))
- call WaitFor("winnr('$') == 2", waittime)
- call assert_equal(2, winnr('$'))
+ call WaitForAssert({-> assert_equal(2, winnr('$'))}, waittime)
bwipe
call assert_fails("call term_start(cmd, {'term_opencmd': 'open'})", 'E475:')
call term_start(cmd, {'term_finish': 'open', 'term_opencmd': '4split | buffer %d'})
close!
- call WaitFor("winnr('$') == 2", waittime)
- call assert_equal(2, winnr('$'))
+ call WaitForAssert({-> assert_equal(2, winnr('$'))}, waittime)
call assert_equal(4, winheight(0))
bwipe
endfunc
endif
call mkdir('Xdir')
let buf = term_start('pwd', {'cwd': 'Xdir'})
- call WaitFor('"Xdir" == fnamemodify(getline(1), ":t")')
- call assert_equal('Xdir', fnamemodify(getline(1), ":t"))
+ call WaitForAssert({-> assert_equal('Xdir', fnamemodify(getline(1), ":t"))})
exe buf . 'bwipe'
call delete('Xdir', 'rf')
endif
let buf = Run_shell_in_terminal({})
" 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')
call term_sendkeys(buf, "echo %VIM_SERVERNAME%\r")
else
func Test_terminal_env()
let buf = Run_shell_in_terminal({'env': {'TESTENV': 'correct'}})
" 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')
call term_sendkeys(buf, "echo %TESTENV%\r")
else
endif
call term_wait(buf)
call Stop_shell_in_terminal(buf)
- call WaitFor('getline(2) == "correct"')
- call assert_equal('correct', getline(2))
+ call WaitForAssert({-> assert_equal('correct', getline(2))})
exe buf . 'bwipe'
endfunc
call term_wait(buf)
" closing window wipes out the terminal buffer a with finished job
- call WaitFor("winnr('$') == 1")
- call assert_equal(1, winnr('$'))
+ call WaitForAssert({-> assert_equal(1, winnr('$'))})
call assert_equal("", bufname(buf))
unlet g:job
new
call setline(1, ['one', 'two', 'three'])
%term wc
- call WaitFor('getline("$") =~ "3"')
+ call WaitForAssert({-> assert_match('3', getline("$"))})
let nrs = split(getline('$'))
call assert_equal(['3', '3', '14'], nrs)
bwipe
new
call setline(1, ['one', 'two', 'three', 'four'])
2,3term wc
- call WaitFor('getline("$") =~ "2"')
+ call WaitForAssert({-> assert_match('2', getline("$"))})
let nrs = split(getline('$'))
call assert_equal(['2', '2', '10'], nrs)
bwipe
new
call setline(1, ['print("hello")'])
1term ++eof=<C-Z> python
- call WaitFor('getline("$") =~ "Z"')
+ call WaitForAssert({-> assert_match('Z', getline("$"))})
call assert_equal('hello', getline(line('$') - 1))
bwipe
endif
else
call system('echo "look here" > ' . pty)
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!
endfunc
call mkdir('Xdir with spaces')
call writefile(['x'], 'Xdir with spaces/quoted"file')
term ls Xdir\ with\ spaces/quoted\"file
- call WaitFor('term_getline("", 1) =~ "quoted"')
- call assert_match('quoted"file', term_getline('', 1))
+ call WaitForAssert({-> assert_match('quoted"file', term_getline('', 1))})
call term_wait('')
call delete('Xdir with spaces', 'rf')
let cmd = Get_cat_123_cmd()
let buf = term_start(cmd, {'out_io': 'file', 'out_name': 'Xfile'})
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])
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')
bwipe
endif
call writefile(['one line'], 'Xfile')
let buf = term_start('cat', {'in_io': 'file', 'in_name': 'Xfile'})
call term_wait(buf)
- call WaitFor('term_getline(' . buf . ', 1) == "one line"')
- call assert_equal('one line', term_getline(buf, 1))
+ call WaitForAssert({-> assert_equal('one line', term_getline(buf, 1))})
let g:job = term_getjob(buf)
- call WaitFor('job_status(g:job) == "dead"')
+ call WaitForAssert({-> assert_equal('dead', job_status(g:job))})
bwipe
call delete('Xfile')
endif
call assert_equal('456', maparg('123', 't'))
call assert_equal('abxde', maparg('456', 't'))
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]
if a:remap
call assert_match('abxde', term_getline(buf, lnum))
call assert_equal("\u00a0\u0308", l[3].chars)
call term_sendkeys(buf, "exit\r")
- call WaitFor('job_status(g:job) == "dead"')
- call assert_equal('dead', job_status(g:job))
+ call WaitForAssert({-> assert_equal('dead', job_status(g:job))})
bwipe!
unlet g:job
let &encoding = save_enc
call setline(1, ['one', 'two'])
exe 'term ++close ' . cmd
wincmd p
- call WaitFor("winnr('$') == 2", waittime)
+ call WaitForAssert({-> assert_equal(2, winnr('$'))}, waittime)
call assert_equal(1, s:called)
bwipe!
endif
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 WaitFor({-> term_getline(buf, 1) =~ 'cat'})
+ call WaitForAssert({-> assert_match('cat', term_getline(buf, 1))})
" Request the cursor position.
call term_sendkeys(buf, "\x1b[6n\<CR>")
" 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.
call term_sendkeys(buf, "\<CR>\<C-D>")
" Open a terminal window and wait for the prompt to appear
call term_sendkeys(buf, ":term\<CR>")
- call WaitFor({-> term_getline(buf, 10) =~ '\[running]'})
- call WaitFor({-> term_getline(buf, 1) !~ '^\s*$'})
+ call WaitForAssert({-> assert_match('\[running]', term_getline(buf, 10))})
+ call WaitForAssert({-> assert_notmatch('^\s*$', term_getline(buf, 1))})
" make Vim exit, it will prompt to kill the shell
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 WaitFor({-> term_getstatus(buf) == "finished"})
+ call WaitForAssert({-> assert_equal('finished', term_getstatus(buf))})
" close the terminal window where Vim was running
quit
let text = " a\u0300 e\u0302 o\u0308"
call writefile([text], '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')
let dumpline = readfile('Xdump')[0]
call assert_match('|à| |ê| |ö', dumpline)
\ "set t_ts=",
\ ], 'Xscript')
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 StopVimInTerminal(buf)
call WriteApiCall('TryThis')
call ch_logfile('Xlog', 'w')
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 delete('Xscript')
call WriteApiCall('Tapi_Delete')
let buf = RunVimInTerminal('-S Xscript', {})
- call WaitFor({-> s:caught_e937 == 1})
+ call WaitForAssert({-> assert_equal(1, s:caught_e937)})
call StopVimInTerminal(buf)
call delete('Xscript')