commit
3fd2a7ae64
@ -8,14 +8,17 @@ module Hydra #:nodoc:
|
|||||||
# IO.gets
|
# IO.gets
|
||||||
# => Hydra::Message # or subclass
|
# => Hydra::Message # or subclass
|
||||||
def gets
|
def gets
|
||||||
raise IOError unless @reader
|
while true
|
||||||
message = @reader.gets
|
begin
|
||||||
return nil unless message
|
raise IOError unless @reader
|
||||||
return Message.build(eval(message.chomp))
|
message = @reader.gets
|
||||||
rescue SyntaxError, NameError
|
return nil unless message
|
||||||
# uncomment to help catch remote errors by seeing all traffic
|
return Message.build(eval(message.chomp))
|
||||||
#$stderr.write "Not a message: [#{message.inspect}]\n"
|
rescue SyntaxError, NameError
|
||||||
return gets
|
# uncomment to help catch remote errors by seeing all traffic
|
||||||
|
#$stderr.write "Not a message: [#{message.inspect}]\n"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Write a Message to the output IO object. It will automatically
|
# Write a Message to the output IO object. It will automatically
|
||||||
|
9
test/fixtures/many_outputs_to_console.rb
vendored
Normal file
9
test/fixtures/many_outputs_to_console.rb
vendored
Normal 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
|
@ -11,4 +11,15 @@ class SSHTest < Test::Unit::TestCase
|
|||||||
assert_equal "Hello World", response.text
|
assert_equal "Hello World", response.text
|
||||||
ssh.close
|
ssh.close
|
||||||
end
|
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
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user