Skip to content

Commit

Permalink
Replace open4 library by open3
Browse files Browse the repository at this point in the history
for the following reasons:

1. `open4` is 3rd party library while `open3` is part of StdLib.
2. It is not clear if `popen` is maintained upstream or if it is just
   stable.
3. There needis to be special handling for `IO.popen4` in JRuby while
   `Open3.popen3` should work the same everywhere.
  • Loading branch information
voxik committed Jul 10, 2023
1 parent 50566a9 commit b0663f7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion excon.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Gem::Specification.new do |s|
s.add_development_dependency('activesupport')
s.add_development_dependency('delorean')
s.add_development_dependency('eventmachine', '>= 1.0.4')
s.add_development_dependency('open4')
s.add_development_dependency('open3')
s.add_development_dependency('rake')
s.add_development_dependency('shindo')
s.add_development_dependency('sinatra')
Expand Down
9 changes: 3 additions & 6 deletions lib/excon/test/server.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'open4'
require 'open3'
require 'excon'
require 'excon/test/plugin/server/webrick'
require 'excon/test/plugin/server/unicorn'
Expand Down Expand Up @@ -39,11 +39,8 @@ def initialize(args)
end

def open_process(*args)
if RUBY_PLATFORM == 'java'
@pid, @write, @read, @error = IO.popen4(*args)
else
@pid, @write, @read, @error = Open4.popen4(*args)
end
@write, @read, @error, wait_thread = Open3.popen3(*args)
@pid = wait_thread.pid
@started_at = Time.now
end

Expand Down
9 changes: 3 additions & 6 deletions tests/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'bundler/setup'
require 'excon'
require 'delorean'
require 'open4'
require 'open3'
require 'webrick'

require './spec/helpers/warning_helpers.rb'
Expand Down Expand Up @@ -316,11 +316,8 @@ def capture_response_block
end

def launch_process(*args)
unless RUBY_PLATFORM == 'java'
pid, w, r, e = Open4.popen4(*args)
else
pid, w, r, e = IO.popen4(*args)
end
w, r, e, wait_thread = Open3.popen3(*args)
pid = wait_thread.pid
return pid, w, r, e
end

Expand Down

0 comments on commit b0663f7

Please sign in to comment.