blob: 21a399b4a5f33740f17509019c89b543906a9d65 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# frozen_string_literal: true
module QA
module Support
module Waiter
module_function
def wait(max: 60, interval: 0.1)
QA::Runtime::Logger.debug("with wait: max #{max}; interval #{interval}")
start = Time.now
while Time.now - start < max
result = yield
if result
log_end(Time.now - start)
return result
end
sleep(interval)
end
log_end(Time.now - start)
false
end
def self.log_end(duration)
QA::Runtime::Logger.debug("ended wait after #{duration} seconds")
end
end
end
end
|