Merged pull request #37 from sskirby/stack_overflow.

Stack overflow
This commit is contained in:
Nick Gauthier 2011-04-26 12:39:07 -07:00
commit 3fd2a7ae64
3 changed files with 31 additions and 8 deletions

View File

@ -8,6 +8,8 @@ module Hydra #:nodoc:
# IO.gets
# => Hydra::Message # or subclass
def gets
while true
begin
raise IOError unless @reader
message = @reader.gets
return nil unless message
@ -15,7 +17,8 @@ module Hydra #:nodoc:
rescue SyntaxError, NameError
# uncomment to help catch remote errors by seeing all traffic
#$stderr.write "Not a message: [#{message.inspect}]\n"
return gets
end
end
end
# Write a Message to the output IO object. It will automatically

View File

@ -0,0 +1,9 @@
#!/usr/bin/env ruby
10000.times do
$stdout.write "A non-hydra message...\n"
$stdout.flush
end
$stdout.write "{:class=>Hydra::Messages::TestMessage, :text=>\"My message\"}\n"
$stdout.flush

View File

@ -11,4 +11,15 @@ class SSHTest < Test::Unit::TestCase
assert_equal "Hello World", response.text
ssh.close
end
should "be able to handle a large number of non-Hydra console output" do
ssh = Hydra::SSH.new(
'localhost', # connect to this machine
File.expand_path(File.join(File.dirname(__FILE__))), # move to the test directory
"ruby fixtures/many_outputs_to_console.rb"
)
response = ssh.gets
assert_equal "My message", response.text
ssh.close
end
end