Permalink
Browse files

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().
  • Loading branch information...
brammool committed Apr 30, 2018
1 parent 850d427 commit 0e9d1ae3216a5940b36bb56d155fb300b2e55b00
@@ -649,18 +649,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')
@@ -494,7 +494,7 @@ func Test_search_cmdline8()
call writefile(lines, 'Xsearch.txt')
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, ":14vsp\<cr>")
@@ -619,7 +619,7 @@ func Test_search_cmdline_incsearch_highlight_attr()
call writefile(lines, 'Xsearch.txt')
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
call term_wait(buf)
Oops, something went wrong.

0 comments on commit 0e9d1ae

Please sign in to comment.