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 spawn = require("awful.spawn")
|
||||||
|
local gtimer = require("gears.timer")
|
||||||
|
|
||||||
local lua_executable = os.getenv("LUA")
|
local lua_executable = os.getenv("LUA")
|
||||||
if lua_executable == nil or lua_executable == "" then
|
if lua_executable == nil or lua_executable == "" then
|
||||||
|
@ -118,13 +119,15 @@ local lgi = require("lgi")
|
||||||
local Gio = lgi.require("Gio")
|
local Gio = lgi.require("Gio")
|
||||||
|
|
||||||
local initialized = false
|
local initialized = false
|
||||||
local pipe
|
local pipe, pid
|
||||||
|
|
||||||
local function init()
|
local function init()
|
||||||
if initialized then return end
|
if initialized then return end
|
||||||
initialized = true
|
initialized = true
|
||||||
local cmd = { lua_executable, "-e", test_client_source }
|
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)
|
pipe = Gio.UnixOutputStream.new(stdin, true)
|
||||||
|
pid = _pid
|
||||||
stdout = Gio.UnixInputStream.new(stdout, true)
|
stdout = Gio.UnixInputStream.new(stdout, true)
|
||||||
stderr = Gio.UnixInputStream.new(stderr, true)
|
stderr = Gio.UnixInputStream.new(stderr, true)
|
||||||
spawn.read_lines(stdout, function(...) print("_client", ...) end)
|
spawn.read_lines(stdout, function(...) print("_client", ...) end)
|
||||||
|
@ -139,7 +142,29 @@ local function get_snid(sn_rules, callback)
|
||||||
return snid
|
return snid
|
||||||
end
|
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 {}
|
args = args or {}
|
||||||
class = class or "test_app"
|
class = class or "test_app"
|
||||||
title = title or "Awesome test client"
|
title = title or "Awesome test client"
|
||||||
|
@ -200,4 +225,6 @@ return function(class, title, sn_rules, callback, resize_increment, args)
|
||||||
return snid
|
return snid
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return setmetatable(module, {__call = new })
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
-- 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)
|
end)
|
||||||
|
|
||||||
-- Cleanup (otherwise there is a race with the root.buttons tests)
|
-- Cleanup (otherwise there is a race with the root.buttons tests)
|
||||||
table.insert(steps, function()
|
table.insert(steps, function(count)
|
||||||
if #mouse.screen.clients ~= 0 then return end
|
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
|
return true
|
||||||
end)
|
end)
|
||||||
|
@ -372,6 +384,8 @@ table.insert(steps, function()
|
||||||
return true
|
return true
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
table.insert(steps, test_client.terminate)
|
||||||
|
|
||||||
runner.run_steps(steps)
|
runner.run_steps(steps)
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||||
|
|
Loading…
Reference in New Issue