From 70f80b20f7da71f05f9c8dc0ad9c25312f61b511 Mon Sep 17 00:00:00 2001 From: danielsdeleo Date: Wed, 21 Nov 2012 13:49:55 -0800 Subject: break out of read loop after timeout --- spec/functional/shell_spec.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'spec/functional') diff --git a/spec/functional/shell_spec.rb b/spec/functional/shell_spec.rb index e202940e68..7f6b9df556 100644 --- a/spec/functional/shell_spec.rb +++ b/spec/functional/shell_spec.rb @@ -31,12 +31,12 @@ describe Chef::Shell do buffer = "" until buffer.include?(expected_value) begin - buffer << io.read_nonblock(10) - rescue Errno::EWOULDBLOCK, Errno::EAGAIN, Errno::EIO + buffer << io.read_nonblock(1) + rescue Errno::EWOULDBLOCK, Errno::EAGAIN, Errno::EIO, EOFError end - if Time.new - start > 30 - STDERR.puts "did not read expected value `#{expected_value}' within 30s" - STDERR.puts "Buffer so far: #{buffer}" + if Time.new - start > 15 + STDERR.puts "did not read expected value `#{expected_value}' within 15s" + STDERR.puts "Buffer so far: `#{buffer}'" break end end @@ -70,6 +70,7 @@ describe Chef::Shell do writer.print("exit\n") read_until(reader, "exit") read_until(reader, "exit") + read_until(reader, "\n") writer.close exitstatus = wait_or_die(pid) -- cgit v1.2.1