vim-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().
0e9d1ae321
This commit is contained in:
Jan Edmund Lazo
2019-09-20 19:19:46 -04:00
parent 3878b0822e
commit 2a7ffc6567
3 changed files with 16 additions and 21 deletions

View File

@@ -681,18 +681,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!

View File

@@ -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')

View File

@@ -141,7 +141,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
@@ -208,7 +208,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
@@ -226,7 +226,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