Put the result of the process into a variable once

To make the meaning of assertion easier to understand,
This commit is contained in:
aycabta 2021-08-11 14:07:28 +09:00
Родитель 01e49af81d
Коммит 4f324514aa
1 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -539,18 +539,20 @@ module BasetestReadline
log << "** Errno::EPIPE **" log << "** Errno::EPIPE **"
# The "write" will fail if Reline crashed by SIGINT. # The "write" will fail if Reline crashed by SIGINT.
end end
interrupt_suppressed = nil
loop do loop do
c = _out.read(1) c = _out.read(1)
log << c if c log << c if c
if log.include?('FAILED') if log.include?('FAILED')
assert false, "Should handle SIGINT correctly but raised interrupt.\nLog: #{log}\n----" interrupt_suppressed = false
break break
end end
if log.include?('SUCCEEDED') if log.include?('SUCCEEDED')
assert false, "Should handle SIGINT correctly but exited successfully.\nLog: #{log}\n----" interrupt_suppressed = true
break break
end end
end end
assert interrupt_suppressed, "Should handle SIGINT correctly but raised interrupt.\nLog: #{log}\n----"
rescue Timeout::Error => e rescue Timeout::Error => e
assert false, "Timed out to handle SIGINT!\nLog: #{log}\nBacktrace:\n#{e.full_message(highlight: false)}\n----" assert false, "Timed out to handle SIGINT!\nLog: #{log}\nBacktrace:\n#{e.full_message(highlight: false)}\n----"
end end