Fix test-leak-client.lua under LuaCov

Both the test runner and the wibox use gears.timer.delayed_call(). The test
runner uses this to call steps and the wibox uses it to trigger redraws. When
running under LuaCov, the Lua code becomes slow enough that the wibox didn't
redraw yet when the leak check is run. This causes the check to fail, because
the client is still referenced by the tasklist and thus cannot be garbage
collected.

Fix this by waiting one more iteration before running the leak check.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2016-02-12 09:23:41 +01:00
parent 9e05ff63ce
commit 432908dd26
1 changed files with 5 additions and 0 deletions

View File

@ -46,6 +46,7 @@ collectgarbage("stop")
-- The first iteration starts xterm, the second keeps a weak reference to it and
-- closes it and the last one checks that the client object is GC'able.
local objs = nil
local second_call = false
local steps = {
function(count)
if count == 1 then
@ -56,6 +57,10 @@ local steps = {
objs = setmetatable({ c }, { __mode = "v" })
c:kill()
end
elseif not second_call then
-- Wait for one iteration so that gears.timer handles other delayed
-- calls (= the tasklist updates)
second_call = true
else
assert(#objs == 1)