From 18e7cd9e972701e095c92221244245c868ebff69 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Sun, 11 Jun 2017 11:36:44 +0100 Subject: [PATCH] test: Prevent waiting for already current state. Some of the UI tests screen:expect() the same screen state twice in a row. This ends up waiting the entire timeout period for a screen redraw event that never happens. So check at the start of screen:wait() that the screen is not already in the desired end state. This shaves a third off the total run-time of the functional tests on FreeBSD. Some of the tests that look for the same state twice are mouse_spec tests, which have their timeouts raised to a quarter of a minute for each screen:expect() in the test. --- test/functional/ui/screen.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index 7d9cd6c026..85196dca89 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -259,7 +259,8 @@ screen:redraw_debug() to show all intermediate screen states. ]]) end function Screen:wait(check, timeout) - local err, checked = false + local err = check() + local checked = false local success_seen = false local failure_after_success = false local function notification_cb(method, args) @@ -277,7 +278,9 @@ function Screen:wait(check, timeout) return true end - run(nil, notification_cb, nil, timeout or self.timeout) + if err then + run(nil, notification_cb, nil, timeout or self.timeout) + end if not checked then err = check() end