Extended logging for debugging readline failures.

This commit is contained in:
Samuel Williams 2021-08-09 14:49:52 +12:00
parent 6736323194
commit 6f6a84f2f3
Notes: git 2021-08-09 14:03:57 +09:00

View file

@ -496,7 +496,8 @@ module BasetestReadline
begin begin
Thread.new{ Thread.new{
trap(:INT) { trap(:INT) {
p :INT puts 'TRAP'
$stdout.flush
} }
Readline.readline('input> ') Readline.readline('input> ')
exit!(0) # Cause the process to exit immediately. exit!(0) # Cause the process to exit immediately.
@ -520,13 +521,15 @@ module BasetestReadline
log << c if c log << c if c
break if log.include?('input>') break if log.include?('input>')
end end
log << "** SIGINT **"
Process.kill(:INT, pid) Process.kill(:INT, pid)
sleep 0.1 sleep 0.1
while c = _out.read(1) while c = _out.read(1)
log << c if c log << c if c
break if log.include?('INT') break if log.include?('TRAP')
end end
begin begin
log << "** NEWLINE **"
_in.write "\n" _in.write "\n"
rescue Errno::EPIPE rescue Errno::EPIPE
# The "write" will fail if Reline crashed by SIGINT. # The "write" will fail if Reline crashed by SIGINT.
@ -540,8 +543,8 @@ module BasetestReadline
assert false, "Should handle SIGINT correctly but exited successfully.\nLog: #{log}\n----" assert false, "Should handle SIGINT correctly but exited successfully.\nLog: #{log}\n----"
end end
end end
rescue Timeout::Error rescue Timeout::Error => e
assert false, "Timed out to handle SIGINT!\nLog: #{log}\n----" assert false, "Timed out to handle SIGINT!\nLog: #{log}\nBacktrace:\n#{e.full_message(highlight: false)}\n----"
end end
ensure ensure
status = Process.wait2(pid).last status = Process.wait2(pid).last