Use pipe factory method to handle 1.8 incompatible signature for IO.pipe.
This commit is contained in:
@@ -21,6 +21,10 @@ def mock_error(subject, message)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def make_pipe
|
||||||
|
IO.method(:pipe).arity.zero? ? IO.pipe : IO.pipe("BINARY")
|
||||||
|
end
|
||||||
|
|
||||||
def foreman(args)
|
def foreman(args)
|
||||||
capture_stdout do
|
capture_stdout do
|
||||||
begin
|
begin
|
||||||
@@ -31,14 +35,14 @@ def foreman(args)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def forked_foreman(args)
|
def forked_foreman(args)
|
||||||
rd, wr = IO.pipe("BINARY")
|
rd, wr = make_pipe
|
||||||
Process.spawn("bundle exec bin/foreman #{args}", :out => wr, :err => wr)
|
Process.spawn("bundle exec bin/foreman #{args}", :out => wr, :err => wr)
|
||||||
wr.close
|
wr.close
|
||||||
rd.read
|
rd.read
|
||||||
end
|
end
|
||||||
|
|
||||||
def fork_and_capture(&blk)
|
def fork_and_capture(&blk)
|
||||||
rd, wr = IO.pipe("BINARY")
|
rd, wr = make_pipe
|
||||||
pid = fork do
|
pid = fork do
|
||||||
rd.close
|
rd.close
|
||||||
wr.sync = true
|
wr.sync = true
|
||||||
@@ -141,7 +145,7 @@ end
|
|||||||
|
|
||||||
def capture_stdout
|
def capture_stdout
|
||||||
old_stdout = $stdout.dup
|
old_stdout = $stdout.dup
|
||||||
rd, wr = IO.method(:pipe).arity.zero? ? IO.pipe : IO.pipe("BINARY")
|
rd, wr = make_pipe
|
||||||
$stdout = wr
|
$stdout = wr
|
||||||
yield
|
yield
|
||||||
wr.close
|
wr.close
|
||||||
|
|||||||
Reference in New Issue
Block a user