patch 9.1.1110: Vim tests are slow and flaky

Problem:  Vim tests are slow and flaky at the same time due to reliance
          on timeouts which are unreliable.
Solution: improve Vim test performance and reduce flakiness
          (Yee Cheng Chin)

A lot of Vim tests currently rely on waiting a specific amount of time
before asserting a condition. This is bad because 1) it is slow, as the
timeout is hardcoded, 2) it's unreliable as a resource-starved runner
may overshoot the timeout. Also, there are a lot of builtin sleep
commands in commonly used utilities like VerifyScreenDump and WaitFor()
which leads to a lot of unnecessary idle time.

Fix these issues by doing the following:
1. Make utilities like VerifyScreenDump and WaitFor use the lowest wait
   time possible (1 ms). This essentially turns it into a spin wait. On
   fast machines, these will finish very quickly. For existing tests
   that had an implicit reliance on the old timeouts (e.g.
   VerifyScreenDump had a 50ms wait before), fix the tests to wait that
   specific amount explicitly.
2. Fix tests that sleep or wait for long amounts of time to instead
   explicitly use a callback mechanism to be notified when a child
   terminal job has finished. This allows the test to only take as much
   time as possible instead of having to hard code an unreliable
   timeout.

With these fixes, tests should 1) completely quickly on fast machines,
and 2) on slow machines they will still run to completion albeit slowly.
Note that previoulsy both were not true. The hardcoded timeouts meant
that on fast machines the tests were mostly idling wasting time, whereas
on slow machines, the timeouts often were not generous enough to allow
them to run to completion.

closes: #16615

Signed-off-by: Yee Cheng Chin <ychin.git@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Yee Cheng Chin
2025-02-13 20:55:45 +01:00
committed by Christian Brabandt
parent 977561a719
commit e70587dbdb
17 changed files with 162 additions and 145 deletions

View File

@ -1,4 +1,4 @@
*various.txt* For Vim version 9.1. Last change: 2024 Dec 16
*various.txt* For Vim version 9.1. Last change: 2025 Feb 13
VIM REFERENCE MANUAL by Bram Moolenaar
@ -765,9 +765,8 @@ K Run a program to lookup the keyword under the
MS-Windows). "gs" stands for "goto sleep".
While sleeping the cursor is positioned in the text,
if at a visible position.
Also process the received netbeans messages. {only
available when compiled with the |+netbeans_intg|
feature}
Queued messages and timers (|+timers|) are processed
during the sleep as well.
*:sl!* *:sleep!*
:[N]sl[eep]! [N][m] Same as above, but hide the cursor.