Permalink
Browse files

Fix exitcode checks to work on all rubies

  • Loading branch information...
1 parent 8e8bdcc commit b9ed78c664966a4f7756d18d67ebaf8bd3e6dc65 @indirect indirect committed Mar 30, 2010
Showing with 23 additions and 17 deletions.
  1. +13 −13 spec/other/check_spec.rb
  2. +10 −4 spec/support/helpers.rb
View
@@ -7,8 +7,8 @@
gem "rails"
G
- bundle :check
- @exitstatus.should == 0 if @exitstatus
+ bundle :check, :exit_status => true
+ @exitstatus.should == 0
out.should == "The Gemfile's dependencies are satisfied"
end
@@ -18,9 +18,9 @@
gem "rails"
G
- bundle :check
- @exitstatus.should_not == 0 if @exitstatus
- out.should =~ /rails \(>= 0, runtime\)/
+ bundle :check, :exit_status => true
+ @exitstatus.should == 1
+ out.should include("rails (>= 0, runtime)")
end
it "shows missing child dependencies" do
@@ -63,9 +63,9 @@
G
bundle "install --without foo"
- bundle "check"
- @exitstatus.should == 0 if @exitstatus
- out.should == "The Gemfile's dependencies are satisfied"
+ bundle "check", :exit_status => true
+ @exitstatus.should == 0
+ out.should include("The Gemfile's dependencies are satisfied")
end
it "ensures that gems are actually installed and not just cached" do
@@ -81,15 +81,15 @@
gem "rack"
G
- bundle "check"
- @exitstatus.should == 1 if @exitstatus
+ bundle "check", :exit_status => true
out.should include("rack (1.0.0) is cached, but not installed")
+ @exitstatus.should == 1
end
it "outputs an error when the default Gemspec is not found" do
- bundle :check
- @exitstatus.should_not == 0 if @exitstatus
- out.should =~ /The default Gemfile was not found/
+ bundle :check, :exit_status => true
+ @exitstatus.should == 10
+ out.should include("The default Gemfile was not found")
end
describe "when locked" do
View
@@ -41,10 +41,12 @@ def lib
def bundle(cmd, options = {})
expect_err = options.delete(:expect_err)
+ exit_status = options.delete(:exit_status)
env = (options.delete(:env) || {}).map{|k,v| "#{k}='#{v}' "}.join
args = options.map { |k,v| " --#{k} #{v}"}.join
gemfile = File.expand_path('../../../bin/bundle', __FILE__)
- sys_exec("#{env}#{Gem.ruby} -I#{lib} #{gemfile} #{cmd}#{args}", expect_err)
+ cmd = "#{env}#{Gem.ruby} -I#{lib} #{gemfile} #{cmd}#{args}"
+ exit_status ? sys_status(cmd) : sys_exec(cmd, expect_err)
end
def ruby(ruby, options = {})
@@ -56,15 +58,19 @@ def ruby(ruby, options = {})
def sys_exec(cmd, expect_err = false)
require "open3"
- input, out, err, waitthread = Open3.popen3(cmd)
+ input, out, err = Open3.popen3(cmd)
@err = err.read.strip
puts @err if !expect_err && $show_err && !@err.empty?
@out = out.read.strip
- @exitstatus = nil
- @exitstatus = waitthread.value.to_i if waitthread
@out
end
+ def sys_status(cmd)
+ @err = nil
+ @out = %x{#{cmd}}.strip
+ @exitstatus = $?.exitstatus
+ end
+
def config(config = nil)
path = bundled_app('.bundle/config')
return YAML.load_file(path) unless config

0 comments on commit b9ed78c

Please sign in to comment.