tests: improve test-selection-transfer: use "wait_per_step" option (#2874)
* test-selection-transfer: clarify comment / condense Noticed this via flaky coverage for the check after the "wait_a_bit" block. Ref: https://codecov.io/gh/awesomeWM/awesome/pull/2872/changes#L193 * tests/_runner.lua: add support for wait_per_step
This commit is contained in:
parent
a7674f2359
commit
4c31a0f745
|
@ -91,14 +91,15 @@ end
|
||||||
-- success/failure, but can also return nothing if it needs to be called again
|
-- success/failure, but can also return nothing if it needs to be called again
|
||||||
-- later.
|
-- later.
|
||||||
function runner.run_steps(steps, options)
|
function runner.run_steps(steps, options)
|
||||||
|
options = gtable.crush({
|
||||||
|
kill_clients=true,
|
||||||
|
wait_per_step=2, -- how long to wait per step in seconds.
|
||||||
|
}, options or {})
|
||||||
-- Setup timer/timeout to limit waiting for signal and quitting awesome.
|
-- Setup timer/timeout to limit waiting for signal and quitting awesome.
|
||||||
local t = timer({timeout=0})
|
local t = timer({timeout=0})
|
||||||
local wait=20
|
local wait=options.wait_per_step / 0.1
|
||||||
local step=1
|
local step=1
|
||||||
local step_count=0
|
local step_count=0
|
||||||
options = options or {
|
|
||||||
kill_clients=true,
|
|
||||||
}
|
|
||||||
runner.run_direct()
|
runner.run_direct()
|
||||||
|
|
||||||
if options.kill_clients then
|
if options.kill_clients then
|
||||||
|
@ -128,7 +129,7 @@ function runner.run_steps(steps, options)
|
||||||
-- Next step.
|
-- Next step.
|
||||||
step = step+1
|
step = step+1
|
||||||
step_count = 0
|
step_count = 0
|
||||||
wait = 20
|
wait = options.wait_per_step / 0.1
|
||||||
t.timeout = 0
|
t.timeout = 0
|
||||||
t:again()
|
t:again()
|
||||||
else
|
else
|
||||||
|
|
|
@ -57,13 +57,7 @@ local selection_object
|
||||||
local selection_released
|
local selection_released
|
||||||
local continue
|
local continue
|
||||||
|
|
||||||
local function wait_a_bit(count)
|
runner.run_steps({
|
||||||
if continue or count == 5 then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
runner.run_steps{
|
|
||||||
function()
|
function()
|
||||||
-- Get the selection
|
-- Get the selection
|
||||||
local s = assert(selection.acquire{ selection = "CLIPBOARD" },
|
local s = assert(selection.acquire{ selection = "CLIPBOARD" },
|
||||||
|
@ -101,10 +95,8 @@ runner.run_steps{
|
||||||
end,
|
end,
|
||||||
|
|
||||||
function()
|
function()
|
||||||
-- Wait for the test to succeed
|
-- Wait for the previous test to succeed
|
||||||
if not continue then
|
if not continue then return end
|
||||||
return
|
|
||||||
end
|
|
||||||
continue = false
|
continue = false
|
||||||
|
|
||||||
-- Now test piece-wise selection transfers
|
-- Now test piece-wise selection transfers
|
||||||
|
@ -141,10 +133,8 @@ runner.run_steps{
|
||||||
end,
|
end,
|
||||||
|
|
||||||
function()
|
function()
|
||||||
-- Wait for the test to succeed
|
-- Wait for the previous test to succeed
|
||||||
if not continue then
|
if not continue then return end
|
||||||
return
|
|
||||||
end
|
|
||||||
continue = false
|
continue = false
|
||||||
|
|
||||||
-- Now test a huge transfer
|
-- Now test a huge transfer
|
||||||
|
@ -179,19 +169,9 @@ runner.run_steps{
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
|
|
||||||
-- The large data transfer above transfers 3 * 2^25 bytes of data. That's
|
|
||||||
-- 96 MiB and takes a while.
|
|
||||||
wait_a_bit,
|
|
||||||
wait_a_bit,
|
|
||||||
wait_a_bit,
|
|
||||||
wait_a_bit,
|
|
||||||
wait_a_bit,
|
|
||||||
|
|
||||||
function()
|
function()
|
||||||
-- Wait for the test to succeed
|
-- Wait for the previous test to succeed
|
||||||
if not continue then
|
if not continue then return end
|
||||||
return
|
|
||||||
end
|
|
||||||
continue = false
|
continue = false
|
||||||
|
|
||||||
-- Now test that :release() works
|
-- Now test that :release() works
|
||||||
|
@ -207,10 +187,8 @@ runner.run_steps{
|
||||||
end,
|
end,
|
||||||
|
|
||||||
function()
|
function()
|
||||||
-- Wait for the test to succeed
|
-- Wait for the previous test to succeed
|
||||||
if not continue then
|
if not continue then return end
|
||||||
return
|
|
||||||
end
|
|
||||||
continue = false
|
continue = false
|
||||||
|
|
||||||
-- Test for "release" signal when we lose selection
|
-- Test for "release" signal when we lose selection
|
||||||
|
@ -225,13 +203,15 @@ runner.run_steps{
|
||||||
|
|
||||||
function()
|
function()
|
||||||
-- Wait for the previous test to succeed
|
-- Wait for the previous test to succeed
|
||||||
if not continue then
|
if not continue then return end
|
||||||
return
|
|
||||||
end
|
|
||||||
continue = false
|
continue = false
|
||||||
assert(selection_released)
|
assert(selection_released)
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
}
|
}, {
|
||||||
|
-- Use a larger step timeout for the large data transfer, which
|
||||||
|
-- transfers 3 * 2^25 bytes of data (96 MiB), and takes a while.
|
||||||
|
wait_per_step = 10,
|
||||||
|
})
|
||||||
|
|
||||||
-- 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