patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Problem: In tests, when WaitFor() fails it doesn't say why. (James McCoy)
Solution: Add WaitForAssert(), which produces an assert error when it fails.
diff --git a/src/testdir/screendump.vim b/src/testdir/screendump.vim
index af9e371..7065fa0 100644
--- a/src/testdir/screendump.vim
+++ b/src/testdir/screendump.vim
@@ -64,9 +64,15 @@
let cols = term_getsize(buf)[1]
endif
- " Wait for "All" of the ruler in the status line to be shown.
- " This can be quite slow (e.g. when using valgrind).
- call WaitFor({-> len(term_getline(buf, rows)) >= cols - 1})
+ " Wait for "All" or "Top" of the ruler in the status line to be shown. This
+ " can be quite slow (e.g. when using valgrind).
+ " If it fails then show the terminal contents for debugging.
+ try
+ call WaitFor({-> len(term_getline(buf, rows)) >= cols - 1})
+ catch /timed out after/
+ let lines = map(range(1, rows), {key, val -> term_getline(buf, val)})
+ call assert_report('RunVimInTerminal() failed, screen contents: ' . join(lines, "<NL>"))
+ endtry
return buf
endfunc
@@ -75,7 +81,7 @@
func StopVimInTerminal(buf)
call assert_equal("running", term_getstatus(a:buf))
call term_sendkeys(a:buf, "\<Esc>\<Esc>:qa!\<cr>")
- call WaitFor('term_getstatus(' . a:buf . ') == "finished"')
+ call WaitForAssert({-> assert_equal("finished", term_getstatus(a:buf))})
only!
endfunc