Improve reporting in #uhwm_wait_output cucumber helper

This commit is contained in:
Thibault Jouan 2015-04-09 22:01:45 +00:00
parent 1079609cfc
commit f66d8d24ee

View File

@ -2,16 +2,17 @@ def uhwm_wait_output message, timeout: 1
Timeout.timeout(timeout) do Timeout.timeout(timeout) do
loop do loop do
break if case message break if case message
when Regexp when Regexp then @process.read_stdout =~ message
@process.read_stdout =~ message when String then assert_partial_output_interactive message
when String
assert_partial_output_interactive message
end end
sleep 0.1 sleep 0.1
end end
end end
rescue Timeout::Error rescue Timeout::Error
fail "expected message `#{message}' not seen after #{timeout} seconds" fail [
"expected `#{message}' not seen after #{timeout} seconds in:",
"```\n#{@process.stdout + @process.stderr}```"
].join "\n"
end end
Then /^the output must contain exactly the usage$/ do Then /^the output must contain exactly the usage$/ do