mirror of
https://github.com/awesomeWM/awesome
synced 2024-11-16 07:47:22 +01:00
e18bece3df
When e.g. test-leaks.lua fails, it will cause a Lua error before starting the test runner. This means that the test will just hang, because nothing causes awesome to quit. Handle this by starting a timer when the test runner is loaded and quitting awesome in there if no test run was started yet. This only works if all tests load the runner before doing anything that could fail, so the require("_runner") is moved to the beginning in every test. Signed-off-by: Uli Schlachter <psychon@znc.in>
31 lines
959 B
Lua
31 lines
959 B
Lua
--- Test for awful.widget.watch
|
|
|
|
local runner = require("_runner")
|
|
local watch = require("awful.widget.watch")
|
|
|
|
local callbacks_done = 0
|
|
|
|
local steps = {
|
|
function(count)
|
|
if count == 1 then
|
|
watch(
|
|
"echo hi", 0.1,
|
|
function(widget, stdout, stderr, exitreason, exitcode)
|
|
assert(widget == "i_am_widget_mock", widget)
|
|
assert(stdout == "hi\n", stdout)
|
|
assert(stderr == "", stderr)
|
|
assert(exitreason == "exit", exitreason)
|
|
assert(exitcode == 0, exitcode)
|
|
callbacks_done = callbacks_done + 1
|
|
end,
|
|
"i_am_widget_mock"
|
|
)
|
|
end
|
|
if callbacks_done > 1 then -- timer fired at least twice
|
|
return true
|
|
end
|
|
end
|
|
}
|
|
runner.run_steps(steps)
|
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|