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:
Daniel Hahler 2019-09-13 16:39:40 +02:00 committed by GitHub
parent a7674f2359
commit 4c31a0f745
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 40 deletions

View File

@ -91,14 +91,15 @@ end
-- success/failure, but can also return nothing if it needs to be called again
-- later.
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.
local t = timer({timeout=0})
local wait=20
local wait=options.wait_per_step / 0.1
local step=1
local step_count=0
options = options or {
kill_clients=true,
}
runner.run_direct()
if options.kill_clients then
@ -128,7 +129,7 @@ function runner.run_steps(steps, options)
-- Next step.
step = step+1
step_count = 0
wait = 20
wait = options.wait_per_step / 0.1
t.timeout = 0
t:again()
else

View File

@ -57,13 +57,7 @@ local selection_object
local selection_released
local continue
local function wait_a_bit(count)
if continue or count == 5 then
return true
end
end
runner.run_steps{
runner.run_steps({
function()
-- Get the selection
local s = assert(selection.acquire{ selection = "CLIPBOARD" },
@ -101,10 +95,8 @@ runner.run_steps{
end,
function()
-- Wait for the test to succeed
if not continue then
return
end
-- Wait for the previous test to succeed
if not continue then return end
continue = false
-- Now test piece-wise selection transfers
@ -141,10 +133,8 @@ runner.run_steps{
end,
function()
-- Wait for the test to succeed
if not continue then
return
end
-- Wait for the previous test to succeed
if not continue then return end
continue = false
-- Now test a huge transfer
@ -179,19 +169,9 @@ runner.run_steps{
return true
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()
-- Wait for the test to succeed
if not continue then
return
end
-- Wait for the previous test to succeed
if not continue then return end
continue = false
-- Now test that :release() works
@ -207,10 +187,8 @@ runner.run_steps{
end,
function()
-- Wait for the test to succeed
if not continue then
return
end
-- Wait for the previous test to succeed
if not continue then return end
continue = false
-- Test for "release" signal when we lose selection
@ -225,13 +203,15 @@ runner.run_steps{
function()
-- Wait for the previous test to succeed
if not continue then
return
end
if not continue then return end
continue = false
assert(selection_released)
return true
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