Merge branch 'fix-ci-cucumber_output_wait'
This commit is contained in:
commit
417eaecad9
@ -27,3 +27,7 @@ end
|
||||
Around '@other_wm_running' do |_, block|
|
||||
with_other_wm { block.call }
|
||||
end
|
||||
|
||||
if ENV.key? 'TRAVIS'
|
||||
ENV['UHWMTEST_TIMEOUT'] = 8.to_s
|
||||
end
|
||||
|
@ -22,23 +22,18 @@ module Uh
|
||||
@process.stdout
|
||||
end
|
||||
|
||||
def uhwm_wait_output message, timeout: 1
|
||||
Timeout.timeout(timeout) do
|
||||
loop do
|
||||
break if case message
|
||||
when Regexp then @process.stdout + @process.stderr =~ message
|
||||
when String then assert_partial_output_interactive message
|
||||
end
|
||||
sleep 0.1
|
||||
def uhwm_wait_output message
|
||||
output = -> { @process.stdout + @process.stderr }
|
||||
timeout_until do
|
||||
case message
|
||||
when Regexp then output.call =~ message
|
||||
when String then assert_partial_output_interactive message
|
||||
end
|
||||
end
|
||||
rescue Timeout::Error
|
||||
output = (@process.stdout + @process.stderr).lines
|
||||
.map { |e| " #{e}" }
|
||||
.join
|
||||
rescue TimeoutError => e
|
||||
fail [
|
||||
"expected `#{message}' not seen after #{timeout} seconds in:",
|
||||
" ```\n#{output} ```"
|
||||
"expected `#{message}' not seen after #{e.timeout} seconds in:",
|
||||
" ```\n#{output.call.lines.map { |e| " #{e}" }.join} ```"
|
||||
].join "\n"
|
||||
end
|
||||
|
||||
@ -90,6 +85,30 @@ module Uh
|
||||
|
||||
private
|
||||
|
||||
def timeout_until
|
||||
timeout = ENV.key?('UHWMTEST_TIMEOUT') ?
|
||||
ENV['UHWMTEST_TIMEOUT'].to_i :
|
||||
1
|
||||
Timeout.timeout(timeout) do
|
||||
loop do
|
||||
break if yield
|
||||
sleep 0.1
|
||||
end
|
||||
end
|
||||
rescue Timeout::Error
|
||||
fail TimeoutError.new('execution expired', timeout)
|
||||
end
|
||||
|
||||
|
||||
class TimeoutError < ::StandardError
|
||||
attr_reader :timeout
|
||||
|
||||
def initialize message, timeout
|
||||
super message
|
||||
@timeout = timeout
|
||||
end
|
||||
end
|
||||
|
||||
class XClient
|
||||
attr_reader :name
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user