Skip to content

Commit

Permalink
excise ruby 1.8 and posix-spawn
Browse files Browse the repository at this point in the history
  • Loading branch information
ddollar committed May 23, 2014
1 parent fc5ae65 commit a7f5c56
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 62 deletions.
4 changes: 0 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ platform :mingw do
gem "win32console", "~> 1.3.0"
end

platform :jruby, :ruby_18 do
gem "posix-spawn", "~> 0.3.6"
end

group :development do
gem 'aws-s3'
gem 'rake'
Expand Down
36 changes: 18 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@ PATH
GEM
remote: http://rubygems.org/
specs:
aws-s3 (0.6.2)
aws-s3 (0.6.3)
builder
mime-types
xml-simple
builder (3.0.0)
builder (3.2.2)
diff-lcs (1.2.5)
docile (1.1.3)
dotenv (0.7.0)
fakefs (0.3.2)
hpricot (0.8.6)
hpricot (0.8.6-java)
mime-types (1.16)
multi_json (1.0.4)
mustache (0.11.2)
posix-spawn (0.3.6)
rake (0.9.2.2)
rdiscount (1.6.5)
mime-types (2.2)
multi_json (1.10.1)
mustache (0.99.5)
rake (10.3.2)
rdiscount (2.1.7.1)
ronn (0.7.3)
hpricot (>= 0.8.2)
mustache (>= 0.7.0)
rdiscount (>= 1.5.8)
rr (1.0.2)
rr (1.0.5)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
Expand All @@ -37,15 +37,16 @@ GEM
rspec-expectations (2.14.5)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.6)
simplecov (0.5.4)
multi_json (~> 1.0.3)
simplecov-html (~> 0.5.3)
simplecov-html (0.5.3)
simplecov (0.8.2)
docile (~> 1.1.0)
multi_json
simplecov-html (~> 0.8.0)
simplecov-html (0.8.0)
thor (0.17.0)
timecop (0.3.5)
win32console (1.3.0-x86-mingw32)
xml-simple (1.0.15)
yard (0.8.2)
timecop (0.7.1)
win32console (1.3.2-x86-mingw32)
xml-simple (1.1.3)
yard (0.8.7.4)

PLATFORMS
java
Expand All @@ -56,7 +57,6 @@ DEPENDENCIES
aws-s3
fakefs (~> 0.3.2)
foreman!
posix-spawn (~> 0.3.6)
rake
ronn
rr (~> 1.0.2)
Expand Down
9 changes: 0 additions & 9 deletions lib/foreman/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def is_thor_reserved_word?(word, type)
end

def start(process=nil)
require_posix_spawn_for_ruby_18!
check_procfile!
load_environment!
engine.load_procfile(procfile)
Expand Down Expand Up @@ -139,14 +138,6 @@ def load_environment!
end
end

def require_posix_spawn_for_ruby_18!
begin
Kernel.require 'posix/spawn' # Use Kernel explicitly so we can mock the require call in the spec
rescue LoadError
error "foreman requires gem `posix-spawn` on Ruby #{RUBY_VERSION}. Please `gem install posix-spawn`."
end if Foreman.ruby_18?
end

def procfile
case
when options[:procfile] then options[:procfile]
Expand Down
4 changes: 0 additions & 4 deletions lib/foreman/process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ def run(options={})
Dir.chdir(cwd) do
Process.spawn env, expanded_command(env), :out => output, :err => output
end
elsif Foreman.jruby_18? || Foreman.ruby_18?
require "posix/spawn"
wrapped_command = "#{runner} -d '#{cwd}' -p -- #{expanded_command(env)}"
POSIX::Spawn.spawn(*spawn_args(env, wrapped_command.shellsplit, {:out => output, :err => output}))
else
wrapped_command = "exec #{runner} -d '#{cwd}' -p -- #{command}"
Process.spawn env, wrapped_command, :out => output, :err => output
Expand Down
8 changes: 0 additions & 8 deletions spec/foreman/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,4 @@
end
end

describe "when posix-spawn is not present on ruby 1.8" do
it "should fail with an error" do
double(Kernel).require('posix/spawn') { raise LoadError }
output = foreman("start -f #{resource_path("Procfile")}")
expect(output).to eq("ERROR: foreman requires gem `posix-spawn` on Ruby #{RUBY_VERSION}. Please `gem install posix-spawn`.\n")
end
end if running_ruby_18?

end
21 changes: 2 additions & 19 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@

$:.unshift File.expand_path("../../lib", __FILE__)

begin
def running_ruby_18?
defined?(RUBY_VERSION) and RUBY_VERSION =~ /^1\.8\.\d+/
end
require 'posix/spawn' if running_ruby_18?
rescue LoadError
STDERR.puts "WARNING: foreman requires gem `posix-spawn` on Ruby #{RUBY_VERSION}. Please `gem install posix-spawn`."
end

def mock_export_error(message)
expect { yield }.to raise_error(Foreman::Export::Exception, message)
end
Expand All @@ -45,11 +36,7 @@ def foreman(args)

def forked_foreman(args)
rd, wr = make_pipe
if running_ruby_18?
POSIX::Spawn.spawn({}, "bundle exec bin/foreman #{args}", :out => wr, :err => wr)
else
Process.spawn("bundle exec bin/foreman #{args}", :out => wr, :err => wr)
end
Process.spawn("bundle exec bin/foreman #{args}", :out => wr, :err => wr)
wr.close
rd.read
end
Expand All @@ -74,11 +61,7 @@ def fork_and_capture(&blk)
end

def fork_and_get_exitstatus(args)
pid = if running_ruby_18?
POSIX::Spawn.spawn({}, "bundle exec bin/foreman #{args}", :out => "/dev/null", :err => "/dev/null")
else
Process.spawn("bundle exec bin/foreman #{args}", :out => "/dev/null", :err => "/dev/null")
end
pid = Process.spawn("bundle exec bin/foreman #{args}", :out => "/dev/null", :err => "/dev/null")
Process.wait(pid)
$?.exitstatus
end
Expand Down

0 comments on commit a7f5c56

Please sign in to comment.