Commit 62550d8a authored by Samuel E. Giddins's avatar Samuel E. Giddins

[Executable] Use popen3 instead of open4 to execute commands

parent 3d184acc
...@@ -77,7 +77,6 @@ PATH ...@@ -77,7 +77,6 @@ PATH
escape (~> 0.0.4) escape (~> 0.0.4)
molinillo (~> 0.2.3) molinillo (~> 0.2.3)
nap (~> 0.8) nap (~> 0.8)
open4 (~> 1.3)
xcodeproj (~> 0.24.0) xcodeproj (~> 0.24.0)
GEM GEM
...@@ -124,7 +123,6 @@ GEM ...@@ -124,7 +123,6 @@ GEM
nap (0.8.0) nap (0.8.0)
netrc (0.7.8) netrc (0.7.8)
notify (0.5.2) notify (0.5.2)
open4 (1.3.4)
parser (2.2.0.3) parser (2.2.0.3)
ast (>= 1.1, < 3.0) ast (>= 1.1, < 3.0)
powerpack (0.1.0) powerpack (0.1.0)
......
...@@ -38,7 +38,6 @@ Gem::Specification.new do |s| ...@@ -38,7 +38,6 @@ Gem::Specification.new do |s|
s.add_runtime_dependency 'colored', '~> 1.2' s.add_runtime_dependency 'colored', '~> 1.2'
s.add_runtime_dependency 'escape', '~> 0.0.4' s.add_runtime_dependency 'escape', '~> 0.0.4'
s.add_runtime_dependency 'open4', '~> 1.3'
s.add_runtime_dependency 'activesupport', '>= 3.2.15' s.add_runtime_dependency 'activesupport', '>= 3.2.15'
s.add_runtime_dependency 'nap', '~> 0.8' s.add_runtime_dependency 'nap', '~> 0.8'
......
...@@ -51,7 +51,7 @@ module Pod ...@@ -51,7 +51,7 @@ module Pod
bin = `which #{executable}`.strip bin = `which #{executable}`.strip
raise Informative, "Unable to locate the executable `#{executable}`" if bin.empty? raise Informative, "Unable to locate the executable `#{executable}`" if bin.empty?
require 'open4' require 'open3'
require 'shellwords' require 'shellwords'
command = command.map(&:to_s) command = command.map(&:to_s)
...@@ -64,8 +64,13 @@ module Pod ...@@ -64,8 +64,13 @@ module Pod
stdout, stderr = Indenter.new, Indenter.new stdout, stderr = Indenter.new, Indenter.new
end end
options = { :stdout => stdout, :stderr => stderr, :status => true } status = Open3.popen3(bin, *command) do |i, o, e, t|
status = Open4.spawn(bin, command, options) out_reader = Thread.new { while s = o.gets; stdout << s; end }
err_reader = Thread.new { while s = e.gets; stderr << s; end }
i.close
[out_reader, err_reader].each(&:join)
t.value
end
output = stdout.join("\n") + stderr.join("\n") output = stdout.join("\n") + stderr.join("\n")
unless status.success? unless status.success?
if raise_on_failure if raise_on_failure
......
...@@ -16,7 +16,7 @@ module Pod ...@@ -16,7 +16,7 @@ module Pod
result = mock result = mock
result.stubs(:success?).returns(true) result.stubs(:success?).returns(true)
Open4.expects(:spawn).with('/Spa ces/are"/fun/false', [], :stdout => [], :stderr => [], :status => true).once.returns(result) Open3.expects(:popen3).with('/Spa ces/are"/fun/false').once.returns(result)
Executable.execute_command(cmd, [], true) Executable.execute_command(cmd, [], true)
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment