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 4, 2023
1 parent bd7d8ce commit 0242e92
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
2 changes: 1 addition & 1 deletion excon.gemspec
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
11 changes: 4 additions & 7 deletions lib/excon/test/server.rb
@@ -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,12 +39,9 @@ def initialize(args)
end

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

Expand Down
10 changes: 3 additions & 7 deletions tests/test_helper.rb
Expand Up @@ -2,7 +2,7 @@
require 'bundler/setup'
require 'excon'
require 'delorean'
require 'open4'
require 'open3'
require 'webrick'

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

def launch_process(*args)
unless RUBY_PLATFORM == 'java'
GC.disable if RUBY_VERSION < '1.9'
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 0242e92

Please sign in to comment.