mirror of
https://github.com/neovim/neovim.git
synced 2025-10-07 02:16:31 +00:00
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:
@@ -681,18 +681,15 @@ func Test_popup_and_window_resize()
|
||||
call term_sendkeys(buf, "\<c-v>")
|
||||
call term_wait(buf, 100)
|
||||
" popup first entry "!" must be at the top
|
||||
call WaitFor({-> term_getline(buf, 1) =~ "^!"})
|
||||
call assert_match('^!\s*$', term_getline(buf, 1))
|
||||
call WaitForAssert({-> assert_match('^!\s*$', term_getline(buf, 1))})
|
||||
exe 'resize +' . (h - 1)
|
||||
call term_wait(buf, 100)
|
||||
redraw!
|
||||
" popup shifted down, first line is now empty
|
||||
call WaitFor({-> term_getline(buf, 1) == ""})
|
||||
call assert_equal('', term_getline(buf, 1))
|
||||
call WaitForAssert({-> assert_equal('', term_getline(buf, 1))})
|
||||
sleep 100m
|
||||
" popup is below cursor line and shows first match "!"
|
||||
call WaitFor({-> term_getline(buf, term_getcursor(buf)[0] + 1) =~ "^!"})
|
||||
call assert_match('^!\s*$', term_getline(buf, term_getcursor(buf)[0] + 1))
|
||||
call WaitForAssert({-> assert_match('^!\s*$', term_getline(buf, term_getcursor(buf)[0] + 1))})
|
||||
" cursor line also shows !
|
||||
call assert_match('^!\s*$', term_getline(buf, term_getcursor(buf)[0]))
|
||||
bwipe!
|
||||
|
@@ -54,34 +54,33 @@ func Do_test_quotestar_for_x11()
|
||||
" 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
|
||||
@@ -109,18 +108,17 @@ func Do_test_quotestar_for_x11()
|
||||
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')
|
||||
|
@@ -141,7 +141,7 @@ endfunc
|
||||
func Test_delete_myself()
|
||||
let g:called = 0
|
||||
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([], timer_info(t))
|
||||
endfunc
|
||||
@@ -208,7 +208,7 @@ func Test_timer_errors()
|
||||
let g:call_count = 0
|
||||
let timer = timer_start(10, 'FuncWithError', {'repeat': -1})
|
||||
" 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
|
||||
call assert_equal(3, g:call_count)
|
||||
endfunc
|
||||
@@ -226,7 +226,7 @@ func Test_timer_catch_error()
|
||||
let g:call_count = 0
|
||||
let timer = timer_start(10, 'FuncWithCaughtError', {'repeat': 4})
|
||||
" Timer will not be stopped.
|
||||
call WaitFor('g:call_count == 4')
|
||||
call WaitForAssert({-> assert_equal(4, g:call_count)})
|
||||
sleep 50m
|
||||
call assert_equal(4, g:call_count)
|
||||
endfunc
|
||||
|
Reference in New Issue
Block a user