I'm using Ruby PTY to integration-test a script that takes input and returns corresponding output.
The problem is that sometimes this script crashes, raising Errno::EIO
.
In my case the script crashes returning a certain traceback.
My question is, how can I capture the spawned process's traceback and print it?
PTY.spawn('ruby script.rb') do |reader, writer, pid|
reader.expect(/Input 1:/)
writer.puts('1')
reader.expect(/Input 2:/)
writer.puts('2')
# Assume exception occurs now, script.sh
# prints some 'undefined variable' traceback
reader.expect(/Input 3:/)
writer.puts('3')
end