Permalink
Browse files

Don't use IO.select in the tests. It doesn't work on windows.

  • Loading branch information...
1 parent 262d961 commit 65ab01a6b7a5eae2586c914ef977ec0589f45355 Carl Lerche committed Aug 20, 2010
Showing with 13 additions and 10 deletions.
  1. +0 −4 spec/spec_helper.rb
  2. +7 −4 spec/support/helpers.rb
  3. +6 −2 spec/support/ruby_ext.rb
View
@@ -62,10 +62,6 @@ def check(*args)
end
config.after :each do
- # clean up open pipes
- @in_p.close if @in_p
- @out_p.close if @out_p
- @err_p.close if @err_p
Dir.chdir(original_wd)
# Reset ENV
ENV['PATH'] = original_path
View
@@ -79,12 +79,15 @@ def gembin(cmd)
end
def sys_exec(cmd, expect_err = false)
- @in_p, @out_p, @err_p = Open3.popen3(cmd.to_s)
+ Open3.popen3(cmd.to_s) do |stdin, stdout, stderr|
+ @in_p, @out_p, @err_p = stdin, stdout, stderr
- yield @in_p if block_given?
+ yield @in_p if block_given?
+ @in_p.close
- @err = @err_p.read_available_bytes.strip
- @out = @out_p.read_available_bytes.strip
+ @out = @out_p.read_available_bytes.strip
+ @err = @err_p.read_available_bytes.strip
+ end
puts @err unless expect_err || @err.empty? || !$show_err
@out
View
@@ -2,14 +2,18 @@ class IO
def read_available_bytes(chunk_size = 1024, select_timeout = 5)
buffer = []
- while self.class.select([self], nil, nil, select_timeout)
+ return "" if closed? || eof?
+ # IO.select cannot be used here due to the fact that it
+ # just does not work on windows
+ while true
begin
buffer << self.readpartial(chunk_size)
+ sleep 0.1
rescue(EOFError)
break
end
end
return buffer.join
end
-end
+end

0 comments on commit 65ab01a

Please sign in to comment.