tests: Blind attempt at making a flacky test under luajit stable.
I could not reproduce the issue locally.
This commit is contained in:
parent
90a2b003a2
commit
a08191913e
|
@ -1,4 +1,5 @@
|
|||
local spawn = require("awful.spawn")
|
||||
local gtimer = require("gears.timer")
|
||||
|
||||
local lua_executable = os.getenv("LUA")
|
||||
if lua_executable == nil or lua_executable == "" then
|
||||
|
@ -118,13 +119,15 @@ local lgi = require("lgi")
|
|||
local Gio = lgi.require("Gio")
|
||||
|
||||
local initialized = false
|
||||
local pipe
|
||||
local pipe, pid
|
||||
|
||||
local function init()
|
||||
if initialized then return end
|
||||
initialized = true
|
||||
local cmd = { lua_executable, "-e", test_client_source }
|
||||
local _, _, stdin, stdout, stderr = awesome.spawn(cmd, false, true, true, true)
|
||||
local _pid, _, stdin, stdout, stderr = awesome.spawn(cmd, false, true, true, true)
|
||||
pipe = Gio.UnixOutputStream.new(stdin, true)
|
||||
pid = _pid
|
||||
stdout = Gio.UnixInputStream.new(stdout, true)
|
||||
stderr = Gio.UnixInputStream.new(stderr, true)
|
||||
spawn.read_lines(stdout, function(...) print("_client", ...) end)
|
||||
|
@ -139,7 +142,29 @@ local function get_snid(sn_rules, callback)
|
|||
return snid
|
||||
end
|
||||
|
||||
return function(class, title, sn_rules, callback, resize_increment, args)
|
||||
local module = {}
|
||||
|
||||
function module.terminate()
|
||||
if not initialized then return end
|
||||
|
||||
for _, c in ipairs(client.get()) do
|
||||
c:kill()
|
||||
end
|
||||
|
||||
pipe:close()
|
||||
initialized, pipe = false, nil
|
||||
|
||||
-- Make a copy to avoid the re-initialized race condition.
|
||||
local original_pid = pid
|
||||
|
||||
gtimer.delayed_call(function()
|
||||
awesome.kill(original_pid, 9)
|
||||
end)
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local function new(_, class, title, sn_rules, callback, resize_increment, args)
|
||||
args = args or {}
|
||||
class = class or "test_app"
|
||||
title = title or "Awesome test client"
|
||||
|
@ -200,4 +225,6 @@ return function(class, title, sn_rules, callback, resize_increment, args)
|
|||
return snid
|
||||
end
|
||||
|
||||
return setmetatable(module, {__call = new })
|
||||
|
||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||
|
|
|
@ -243,8 +243,20 @@ for _, type_name in ipairs { "key", "button" } do
|
|||
end)
|
||||
|
||||
-- Cleanup (otherwise there is a race with the root.buttons tests)
|
||||
table.insert(steps, function()
|
||||
if #mouse.screen.clients ~= 0 then return end
|
||||
table.insert(steps, function(count)
|
||||
if #mouse.screen.clients ~= 0 then
|
||||
if count > 5 then
|
||||
-- It's stuck, kill it.
|
||||
test_client.terminate()
|
||||
else
|
||||
for _, c in pairs(client.get()) do
|
||||
c:kill()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
return true
|
||||
end)
|
||||
|
@ -372,6 +384,8 @@ table.insert(steps, function()
|
|||
return true
|
||||
end)
|
||||
|
||||
table.insert(steps, test_client.terminate)
|
||||
|
||||
runner.run_steps(steps)
|
||||
|
||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||
|
|
Loading…
Reference in New Issue