summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlhuda <carlhuda@engineyard.com>2010-08-11 17:20:46 -0700
committerCarlhuda <carlhuda@engineyard.com>2010-08-11 18:17:38 -0700
commit5b7f69566a10369ef1cc6c100f58a0631e74bdc3 (patch)
tree96f0490496acf9af90e34684d4eed5a56e2d0a66
parent3e63a35750521eb392a7af746988bf7b2f15d306 (diff)
downloadbundler-removing_the_spec_gil.tar.gz
-rw-r--r--spec/install/deploy_spec.rb2
-rw-r--r--spec/install/gems/env_spec.rb14
-rw-r--r--spec/install/gems/simple_case_spec.rb4
-rw-r--r--spec/install/gems/sudo_spec.rb2
-rw-r--r--spec/install/git_spec.rb4
-rw-r--r--spec/install/path_spec.rb2
-rw-r--r--spec/other/check_spec.rb4
-rw-r--r--spec/other/config_spec.rb6
-rw-r--r--spec/other/exec_spec.rb19
-rw-r--r--spec/other/show_spec.rb4
-rw-r--r--spec/resolver/basic_spec.rb2
-rw-r--r--spec/runtime/load_spec.rb21
-rw-r--r--spec/runtime/setup_spec.rb10
-rw-r--r--spec/runtime/with_clean_env_spec.rb27
-rw-r--r--spec/spec_helper.rb100
-rw-r--r--spec/support/builders.rb41
-rw-r--r--spec/support/helpers.rb58
-rw-r--r--spec/support/rubygems_ext.rb2
18 files changed, 221 insertions, 101 deletions
diff --git a/spec/install/deploy_spec.rb b/spec/install/deploy_spec.rb
index 6ad43b7e70..06c8e2e8d0 100644
--- a/spec/install/deploy_spec.rb
+++ b/spec/install/deploy_spec.rb
@@ -64,7 +64,7 @@ describe "install with --deployment or --frozen" do
gem "rack-obama"
G
- ENV['BUNDLE_FROZEN'] = '1'
+ env['BUNDLE_FROZEN'] = '1'
bundle "install"
out.should include("You have modified your Gemfile")
out.should include("You have added to the Gemfile")
diff --git a/spec/install/gems/env_spec.rb b/spec/install/gems/env_spec.rb
index 285c23b0fb..973b291abf 100644
--- a/spec/install/gems/env_spec.rb
+++ b/spec/install/gems/env_spec.rb
@@ -18,7 +18,7 @@ describe "bundle install with ENV conditionals" do
end
it "includes the gems when the ENV variable is set" do
- ENV['BUNDLER_TEST'] = '1'
+ env['BUNDLER_TEST'] = '1'
bundle :install
should_be_installed "rack 1.0"
end
@@ -41,7 +41,7 @@ describe "bundle install with ENV conditionals" do
end
it "includes the gems when the ENV variable is set" do
- ENV['BUNDLER_TEST'] = '1'
+ env['BUNDLER_TEST'] = '1'
bundle :install
should_be_installed "rack 1.0"
end
@@ -64,13 +64,13 @@ describe "bundle install with ENV conditionals" do
end
it "excludes the gems when the ENV variable is set but does not match the condition" do
- ENV['BUNDLER_TEST'] = '1'
+ env['BUNDLER_TEST'] = '1'
bundle :install
should_not_be_installed "rack"
end
it "includes the gems when the ENV variable is set and matches the condition" do
- ENV['BUNDLER_TEST'] = 'foo'
+ env['BUNDLER_TEST'] = 'foo'
bundle :install
should_be_installed "rack 1.0"
end
@@ -93,15 +93,15 @@ describe "bundle install with ENV conditionals" do
end
it "excludes the gems when the ENV variable is set but does not match the condition" do
- ENV['BUNDLER_TEST'] = 'fo'
+ env['BUNDLER_TEST'] = 'fo'
bundle :install
should_not_be_installed "rack"
end
it "includes the gems when the ENV variable is set and matches the condition" do
- ENV['BUNDLER_TEST'] = 'foobar'
+ env['BUNDLER_TEST'] = 'foobar'
bundle :install
should_be_installed "rack 1.0"
end
end
-end \ No newline at end of file
+end
diff --git a/spec/install/gems/simple_case_spec.rb b/spec/install/gems/simple_case_spec.rb
index 54550d748c..e52679c6d4 100644
--- a/spec/install/gems/simple_case_spec.rb
+++ b/spec/install/gems/simple_case_spec.rb
@@ -346,7 +346,7 @@ describe "bundle install with gem sources" do
def set_bundle_path(type, location)
if type == :env
- ENV["BUNDLE_PATH"] = location
+ env["BUNDLE_PATH"] = location
elsif type == :global
bundle "config path #{location}", "no-color" => nil
end
@@ -419,7 +419,7 @@ describe "bundle install with gem sources" do
bundle :install, :gemfile => bundled_app("NotGemfile")
- ENV['BUNDLE_GEMFILE'] = "NotGemfile"
+ env['BUNDLE_GEMFILE'] = "NotGemfile"
should_be_installed "rack 1.0.0"
end
end
diff --git a/spec/install/gems/sudo_spec.rb b/spec/install/gems/sudo_spec.rb
index 4b200f252a..5009baa351 100644
--- a/spec/install/gems/sudo_spec.rb
+++ b/spec/install/gems/sudo_spec.rb
@@ -26,7 +26,7 @@ describe "when using sudo" do
FileUtils.mkdir_p bundle_path
sudo "chown -R root #{bundle_path}"
- ENV['BUNDLE_PATH'] = bundle_path.to_s
+ env['BUNDLE_PATH'] = bundle_path.to_s
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "rack", '1.0'
diff --git a/spec/install/git_spec.rb b/spec/install/git_spec.rb
index 7e9b35827c..76fa7b6e74 100644
--- a/spec/install/git_spec.rb
+++ b/spec/install/git_spec.rb
@@ -71,7 +71,7 @@ describe "bundle install with git sources" do
bundle "install vendor"
FileUtils.mv bundled_app, tmp('bundled_app.bck')
- Dir.chdir tmp('bundled_app.bck')
+ chdir tmp('bundled_app.bck')
should_be_installed "foo 1.0"
end
@@ -81,7 +81,7 @@ describe "bundle install with git sources" do
update_git "foo", "1.1", :path => lib_path("foo-1.0")
- Dir.chdir tmp('bundled_app.bck')
+ chdir tmp('bundled_app.bck')
gemfile tmp('bundled_app.bck/Gemfile'), <<-G
source "file://#{gem_repo1}"
git "#{lib_path('foo-1.0')}" do
diff --git a/spec/install/path_spec.rb b/spec/install/path_spec.rb
index ba4dff63ea..be11823ef5 100644
--- a/spec/install/path_spec.rb
+++ b/spec/install/path_spec.rb
@@ -25,7 +25,7 @@ describe "bundle install with explicit source paths" do
it "supports relative paths" do
build_lib "foo"
- relative_path = lib_path('foo-1.0').relative_path_from(Pathname.new(Dir.pwd))
+ relative_path = lib_path('foo-1.0').relative_path_from(Pathname.new(pwd))
install_gemfile <<-G
gem 'foo', :path => "#{relative_path}"
diff --git a/spec/other/check_spec.rb b/spec/other/check_spec.rb
index a371a207cf..4975043fec 100644
--- a/spec/other/check_spec.rb
+++ b/spec/other/check_spec.rb
@@ -18,7 +18,7 @@ describe "bundle check" do
gem "rails"
G
- Dir.chdir tmp
+ chdir tmp
bundle "check --gemfile bundled_app/Gemfile"
out.should == "The Gemfile's dependencies are satisfied"
end
@@ -29,7 +29,7 @@ describe "bundle check" do
gem "rails"
G
- FileUtils.rm("Gemfile.lock")
+ rm("Gemfile.lock")
bundle "check"
diff --git a/spec/other/config_spec.rb b/spec/other/config_spec.rb
index 6d059e90ff..bb4cd9e0e6 100644
--- a/spec/other/config_spec.rb
+++ b/spec/other/config_spec.rb
@@ -9,7 +9,7 @@ describe ".bundle/config" do
end
it "can be moved with an environment variable" do
- ENV['BUNDLE_APP_CONFIG'] = tmp('foo/bar').to_s
+ env['BUNDLE_APP_CONFIG'] = tmp('foo/bar').to_s
bundle "install vendor"
bundled_app('.bundle').should_not exist
@@ -21,7 +21,7 @@ describe ".bundle/config" do
FileUtils.mkdir_p bundled_app('omg')
Dir.chdir bundled_app('omg')
- ENV['BUNDLE_APP_CONFIG'] = "../foo"
+ env['BUNDLE_APP_CONFIG'] = "../foo"
bundle "install vendor"
bundled_app(".bundle").should_not exist
@@ -31,7 +31,7 @@ describe ".bundle/config" do
it "removes environment.rb from BUNDLE_APP_CONFIG's path" do
FileUtils.mkdir_p(tmp('foo/bar'))
- ENV['BUNDLE_APP_CONFIG'] = tmp('foo/bar').to_s
+ env['BUNDLE_APP_CONFIG'] = tmp('foo/bar').to_s
bundle "install"
FileUtils.touch tmp('foo/bar/environment.rb')
should_be_installed "rack 1.0.0"
diff --git a/spec/other/exec_spec.rb b/spec/other/exec_spec.rb
index 7b5514e7b7..31666895c8 100644
--- a/spec/other/exec_spec.rb
+++ b/spec/other/exec_spec.rb
@@ -45,21 +45,20 @@ describe "bundle exec" do
gem "rack", "0.9.1"
G
- Dir.chdir bundled_app2 do
- install_gemfile bundled_app2('Gemfile'), <<-G
- source "file://#{gem_repo2}"
- gem "rack_two", "1.0.0"
- G
- end
+ chdir bundled_app2
+ install_gemfile bundled_app2('Gemfile'), <<-G
+ source "file://#{gem_repo2}"
+ gem "rack_two", "1.0.0"
+ G
+ chdir bundled_app
bundle "exec rackup"
check out.should == "0.9.1"
- Dir.chdir bundled_app2 do
- bundle "exec rackup"
- out.should == "1.0.0"
- end
+ chdir bundled_app2
+ bundle "exec rackup"
+ out.should == "1.0.0"
end
it "handles gems installed with --without" do
diff --git a/spec/other/show_spec.rb b/spec/other/show_spec.rb
index 4655d4fc43..52017da4ff 100644
--- a/spec/other/show_spec.rb
+++ b/spec/other/show_spec.rb
@@ -9,7 +9,7 @@ describe "bundle show" do
end
it "creates a Gemfile.lock if one did not exist" do
- FileUtils.rm("Gemfile.lock")
+ rm("Gemfile.lock")
bundle "show"
@@ -17,7 +17,7 @@ describe "bundle show" do
end
it "creates a Gemfile.lock if one did not exist and we're doing bundle show rails" do
- FileUtils.rm("Gemfile.lock")
+ rm("Gemfile.lock")
bundle "show rails"
diff --git a/spec/resolver/basic_spec.rb b/spec/resolver/basic_spec.rb
index 177a7b0c94..cd1016fd11 100644
--- a/spec/resolver/basic_spec.rb
+++ b/spec/resolver/basic_spec.rb
@@ -17,4 +17,4 @@ describe "Resolving" do
should_resolve_as %w(actionpack-2.3.5 activesupport-2.3.5 rack-1.0)
end
-end \ No newline at end of file
+end
diff --git a/spec/runtime/load_spec.rb b/spec/runtime/load_spec.rb
index 2dd92308e8..2ca53f154d 100644
--- a/spec/runtime/load_spec.rb
+++ b/spec/runtime/load_spec.rb
@@ -18,8 +18,8 @@ describe "Bundler.load" do
gem "rack"
G
- env = Bundler.load
- env.dependencies.should have_dep("rack", ">= 0")
+ run "deps = Bundler.load.dependencies; puts deps.any? { |d| d == Gem::Dependency.new('rack', '>=0') }"
+ out.should == "true"
end
it "provides a list of the resolved gems" do
@@ -28,8 +28,8 @@ describe "Bundler.load" do
gem "rack"
G
- env = Bundler.load
- env.gems.should have_gem("rack-1.0.0", "bundler-#{Bundler::VERSION}")
+ run "gems = Bundler.load.gems; puts gems.length && gems.any? { |a| a.full_name == 'rack-1.0.0' }"
+ out.should == "true"
end
it "raises an exception if the default gemfile is not found" do
@@ -39,10 +39,9 @@ describe "Bundler.load" do
end
it "raises an exception if a specified gemfile is not found" do
- lambda {
- ENV['BUNDLE_GEMFILE'] = "omg.rb"
- Bundler.load
- }.should raise_error(Bundler::GemfileNotFound, /omg\.rb/)
+ env['BUNDLE_GEMFILE'] = "omg.rb"
+ run "Bundler.load", :expect_err => true
+ err.should =~ /omg\.rb/
end
describe "when called twice" do
@@ -97,10 +96,8 @@ describe "Bundler.load" do
gem "activerecord"
G
- Bundler.load.specs.each do |spec|
- spec.to_yaml.should_not =~ /^\s+source:/
- spec.to_yaml.should_not =~ /^\s+groups:/
- end
+ run "specs = Bundler.load.specs; puts specs.all? { |s| s.to_yaml !~ /^\s+(source|groups):/ }"
+ out.should == "true"
end
end
diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb
index 88729dca3e..35551db409 100644
--- a/spec/runtime/setup_spec.rb
+++ b/spec/runtime/setup_spec.rb
@@ -87,14 +87,14 @@ describe "Bundler.setup" do
gem "activesupport", "2.3.5"
G
- ENV['BUNDLE_GEMFILE'] = bundled_app('4realz').to_s
+ env['BUNDLE_GEMFILE'] = bundled_app('4realz').to_s
bundle :install
should_be_installed "activesupport 2.3.5"
end
it "prioritizes gems in BUNDLE_PATH over gems in GEM_HOME" do
- ENV['BUNDLE_PATH'] = bundled_app('.bundle').to_s
+ env['BUNDLE_PATH'] = bundled_app('.bundle').to_s
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "rack", "1.0.0"
@@ -246,14 +246,14 @@ describe "Bundler.setup" do
begin
bundle "install vendor"
- Dir["**/*"].each do |f|
+ Dir["#{pwd}/**/*"].each do |f|
File.directory?(f) ?
File.chmod(0555, f) :
File.chmod(0444, f)
end
should_be_installed "rack 1.0.0"
ensure
- Dir["**/*"].each do |f|
+ Dir["#{pwd}/**/*"].each do |f|
File.directory?(f) ?
File.chmod(0755, f) :
File.chmod(0644, f)
@@ -370,7 +370,7 @@ describe "Bundler.setup" do
gem "rack"
G
- ENV["GEM_HOME"] = ""
+ env["GEM_HOME"] = ""
bundle %{exec ruby -e "require 'set'"}
err.should be_empty
diff --git a/spec/runtime/with_clean_env_spec.rb b/spec/runtime/with_clean_env_spec.rb
index 51ecc29e53..92164cc5e4 100644
--- a/spec/runtime/with_clean_env_spec.rb
+++ b/spec/runtime/with_clean_env_spec.rb
@@ -3,13 +3,28 @@ require "spec_helper"
describe "Bundler.with_clean_env" do
it "should reset and restore the environment" do
- gem_path = ENV['GEM_PATH']
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
- Bundler.with_clean_env do
- `echo $GEM_PATH`.strip.should_not == gem_path
- end
+ bundle "install --path vendor"
+ puts out
- ENV['GEM_PATH'].should == gem_path
+ env["GEM_HOME"] = "omg"
+
+ run <<-RUBY
+ puts ENV['GEM_HOME']
+
+ Bundler.with_clean_env do
+ puts `echo $GEM_HOME`.strip
+ end
+
+ puts ENV['GEM_HOME'].strip
+ RUBY
+
+ home = File.expand_path(vendored_gems)
+ out.should == "#{home}\nomg\n#{home}"
end
-end \ No newline at end of file
+end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 69914ee943..597553a5be 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -41,13 +41,14 @@ RSpec.configure do |config|
end
config.before :all do
+ @__current_dir__ = Dir.pwd
build_repo1
end
config.before :each do
reset!
system_gems []
- in_app_root
+ chdir bundled_app.to_s
end
config.after :each do
@@ -57,15 +58,92 @@ RSpec.configure do |config|
@err_p.close if @err_p
Dir.chdir(original_wd)
# Reset ENV
- ENV['PATH'] = original_path
- ENV['GEM_HOME'] = original_gem_home
- ENV['GEM_PATH'] = original_gem_home
- ENV['BUNDLE_PATH'] = nil
- ENV['BUNDLE_GEMFILE'] = nil
- ENV['BUNDLER_TEST'] = nil
- ENV['BUNDLE_FROZEN'] = nil
- ENV['BUNDLER_SPEC_PLATFORM'] = nil
- ENV['BUNDLER_SPEC_VERSION'] = nil
- ENV['BUNDLE_APP_CONFIG'] = nil
+ env.clear
end
+
+ Thread.abort_on_exception = true
+
+ class Queue
+ def initialize
+ @pipes = []
+ end
+
+ def push(pipe)
+ @pipes << pipe
+ end
+
+ def read
+ Thread.new do
+ loop do
+ begin
+ sleep 0.1 until @pipes[0]
+ pipe = @pipes.shift
+ break if pipe == :EOF
+
+ puts "READING: #{pipe.inspect}"
+ while line = pipe.gets
+ puts line
+ end
+
+ pipe.close
+ rescue Exception => e
+ puts "OMGOMGOMG ERRORZ: #{e.message} - #{e.class}"
+ puts e.backtrace
+ exit!
+ end
+ end
+ end
+ end
+ end
+
+ module ForkingRunner
+ @queue = Queue.new
+
+ def self.queue
+ @queue
+ end
+
+ def self.pipe
+ Thread.current[:pipe]
+ end
+
+ def self.pipe=(pipe)
+ Thread.current[:pipe] = pipe
+ end
+
+ def run(reporter)
+ if ForkingRunner.pipe
+ super
+ else
+ read, write = IO.pipe
+ ForkingRunner.queue.push read
+ t = Thread.new do
+ ForkingRunner.pipe = write
+
+ def reporter.output
+ ForkingRunner.pipe || super
+ end
+
+ puts "PUSHING A PIPE YO"
+ super
+ puts "CLOSING A PIPE YO"
+ write.close
+ end
+ end
+ end
+ end
+
+ # config.extend ForkingRunner
end
+
+# module RSpec::Core::CommandLine::ExampleGroups
+# alias old_run_examples run_examples
+#
+# def run_examples(reporter)
+# t = ForkingRunner.queue.read
+# old_run_examples(reporter)
+# ForkingRunner.queue.push :EOF
+#
+# t.join
+# end
+# end
diff --git a/spec/support/builders.rb b/spec/support/builders.rb
index 4e40385924..5b577e11c1 100644
--- a/spec/support/builders.rb
+++ b/spec/support/builders.rb
@@ -260,7 +260,7 @@ module Spec
yield
@_build_path = nil
with_gem_path_as Path.base_system_gems do
- Dir.chdir(path) { gem_command :generate_index }
+ chdir(path) { gem_command :generate_index }
end
end
@@ -476,10 +476,10 @@ module Spec
def _build(options)
path = options[:path] || _default_path
super(options.merge(:path => path))
- Dir.chdir(path) do
- `git init`
- `git add *`
- `git commit -m 'OMG INITIAL COMMIT'`
+ @context.chdir(path) do
+ @context.sys_exec "git init"
+ @context.sys_exec "git add *"
+ @context.sys_exec "git commit -m 'OMG INITIAL COMMIT'"
end
end
end
@@ -489,34 +489,34 @@ module Spec
NULL = WINDOWS ? "NUL" : "/dev/null"
def silently(str)
- `#{str} 2>#{NULL}`
+ @context.sys_exec "#{str} 2>#{NULL}"
end
def _build(options)
libpath = options[:path] || _default_path
- Dir.chdir(libpath) do
+ @context.chdir(libpath) do
silently "git checkout master"
if branch = options[:branch]
raise "You can't specify `master` as the branch" if branch == "master"
- if `git branch | grep #{branch}`.empty?
+ if @context.sys_exec("git branch | grep #{branch}").empty?
silently("git branch #{branch}")
end
silently("git checkout #{branch}")
elsif tag = options[:tag]
- `git tag #{tag}`
+ @context.sys_exec("git tag #{tag}")
end
- current_ref = `git rev-parse HEAD`.strip
+ current_ref = context.sys_exec("git rev-parse HEAD").strip
_default_files.keys.each do |path|
_default_files[path] << "\n#{Builders.constantize(name)}_PREV_REF = '#{current_ref}'"
end
super(options.merge(:path => libpath))
- `git add *`
- `git commit -m "BUMP"`
+ @context.sys_exec("git add *")
+ @context.sys_exec("git commit -m \"BUMP\"")
end
end
end
@@ -537,7 +537,7 @@ module Spec
private
def git(cmd)
- Dir.chdir(@path) { `git #{cmd}`.strip }
+ @context.chdir(@path) { @context.sys_exec("git #{cmd}").strip }
end
end
@@ -546,14 +546,21 @@ module Spec
def _build(opts)
lib_path = super(opts.merge(:path => @context.tmp(".tmp/#{@spec.full_name}"), :no_default => opts[:no_default]))
- Dir.chdir(lib_path) do
+ @context.chdir(lib_path) do
destination = opts[:path] || _default_path
FileUtils.mkdir_p(destination)
- Gem::Builder.new(@spec).build
+
+ gemspec_path = "#{lib_path}/#{@spec.full_name}.omg.gemspec"
+ File.open(gemspec_path, "w") do |file|
+ file.puts @spec.to_ruby
+ end
+
+ @context.gem_command "build #{gemspec_path}"
+
if opts[:to_system]
- `gem install --ignore-dependencies #{@spec.full_name}.gem`
+ @context.sys_exec "gem install --ignore-dependencies #{@spec.full_name}.gem"
else
- FileUtils.mv("#{@spec.full_name}.gem", opts[:path] || _default_path)
+ FileUtils.mv("#{@context.pwd}/#{@spec.full_name}.gem", opts[:path] || _default_path)
end
end
end
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb
index 75a2a6fafb..fdb956dd3b 100644
--- a/spec/support/helpers.rb
+++ b/spec/support/helpers.rb
@@ -4,7 +4,7 @@ module Spec
@in_p, @out_p, @err_p = nil, nil, nil
Dir["#{tmp}/{gems/*,*}"].each do |dir|
next if %(base remote1 gems rubygems_1_3_5 rubygems_1_3_6 rubygems_master).include?(File.basename(dir))
- unless ENV['BUNDLER_SUDO_TESTS']
+ unless env['BUNDLER_SUDO_TESTS']
FileUtils.rm_rf(dir)
else
`sudo rm -rf #{dir}`
@@ -26,6 +26,25 @@ module Spec
Dir.chdir(bundled_app2, &blk)
end
+ def chdir(dir)
+ old_dir, @__current_dir__ = @__current_dir__, dir
+ yield if block_given?
+ ensure
+ @__current_dir__ = old_dir if block_given?
+ end
+
+ def pwd
+ @__current_dir__
+ end
+
+ def env
+ @__env__ ||= {}
+ end
+
+ def rm(file)
+ FileUtils.rm("#{@__current_dir__}/#{file}")
+ end
+
def run(cmd, *args)
opts = args.last.is_a?(Hash) ? args.pop : {}
expect_err = opts.delete(:expect_err)
@@ -71,16 +90,16 @@ module Spec
def gembin(cmd)
lib = File.expand_path("../../../lib", __FILE__)
- old, ENV['RUBYOPT'] = ENV['RUBYOPT'], "#{ENV['RUBYOPT']} -I#{lib}"
+ old, env['RUBYOPT'] = env['RUBYOPT'], "#{env['RUBYOPT']} -I#{lib}"
cmd = bundled_app("bin/#{cmd}") unless cmd.to_s.include?("/")
sys_exec(cmd.to_s)
ensure
- ENV['RUBYOPT'] = old
+ env['RUBYOPT'] = old
end
def sys_exec(cmd, expect_err = false)
require "open3"
- @in_p, @out_p, @err_p = Open3.popen3(cmd.to_s)
+ @in_p, @out_p, @err_p = Open3.popen3(command(cmd))
yield @in_p if block_given?
@@ -93,10 +112,15 @@ module Spec
def sys_status(cmd)
@err = nil
- @out = %x{#{cmd}}.strip
+ @out = %x{#{command(cmd)}}.strip
@exitstatus = $?.exitstatus
end
+ def command(cmd)
+ env_string = self.env.map { |k,v| "#{k}=#{v}" }.join(" ")
+ "cd #{@__current_dir__} && #{env_string} #{cmd}"
+ end
+
def config(config = nil)
path = bundled_app('.bundle/config')
return YAML.load_file(path) unless config
@@ -150,11 +174,11 @@ module Spec
alias install_gem install_gems
def with_gem_path_as(path)
- gem_home, gem_path = ENV['GEM_HOME'], ENV['GEM_PATH']
- ENV['GEM_HOME'], ENV['GEM_PATH'] = path.to_s, path.to_s
+ gem_home, gem_path = env['GEM_HOME'], env['GEM_PATH']
+ env['GEM_HOME'], env['GEM_PATH'] = path.to_s, path.to_s
yield
ensure
- ENV['GEM_HOME'], ENV['GEM_PATH'] = gem_home, gem_path
+ env['GEM_HOME'], env['GEM_PATH'] = gem_home, gem_path
end
def break_git!
@@ -163,7 +187,7 @@ module Spec
f.puts "#!/usr/bin/env ruby\nSTDERR.puts 'This is not the git you are looking for'\nexit 1"
end
- ENV["PATH"] = "#{tmp("broken_path")}:#{ENV["PATH"]}"
+ env["PATH"] = "#{tmp("broken_path")}:#{env["PATH"]}"
end
def system_gems(*gems)
@@ -174,16 +198,16 @@ module Spec
Gem.clear_paths
- gem_home, gem_path, path = ENV['GEM_HOME'], ENV['GEM_PATH'], ENV['PATH']
- ENV['GEM_HOME'], ENV['GEM_PATH'] = system_gem_path.to_s, system_gem_path.to_s
+ gem_home, gem_path, path = env['GEM_HOME'], env['GEM_PATH'], env['PATH']
+ env['GEM_HOME'], env['GEM_PATH'] = system_gem_path.to_s, system_gem_path.to_s
install_gems(*gems)
if block_given?
begin
yield
ensure
- ENV['GEM_HOME'], ENV['GEM_PATH'] = gem_home, gem_path
- ENV['PATH'] = path
+ env['GEM_HOME'], env['GEM_PATH'] = gem_home, gem_path
+ env['PATH'] = path
end
end
end
@@ -208,17 +232,17 @@ module Spec
end
def simulate_platform(platform)
- old, ENV['BUNDLER_SPEC_PLATFORM'] = ENV['BUNDLER_SPEC_PLATFORM'], platform.to_s
+ old, env['BUNDLER_SPEC_PLATFORM'] = env['BUNDLER_SPEC_PLATFORM'], platform.to_s
yield if block_given?
ensure
- ENV['BUNDLER_SPEC_PLATFORM'] = old if block_given?
+ env['BUNDLER_SPEC_PLATFORM'] = old if block_given?
end
def simulate_bundler_version(version)
- old, ENV['BUNDLER_SPEC_VERSION'] = ENV['BUNDLER_SPEC_VERSION'], version.to_s
+ old, env['BUNDLER_SPEC_VERSION'] = env['BUNDLER_SPEC_VERSION'], version.to_s
yield if block_given?
ensure
- ENV['BUNDLER_SPEC_VERSION'] = old if block_given?
+ env['BUNDLER_SPEC_VERSION'] = old if block_given?
end
def revision_for(path)
diff --git a/spec/support/rubygems_ext.rb b/spec/support/rubygems_ext.rb
index d51fe70b2d..0b797c7760 100644
--- a/spec/support/rubygems_ext.rb
+++ b/spec/support/rubygems_ext.rb
@@ -24,7 +24,7 @@ module Spec
args = %["#{args}"]
end
lib = File.join(File.dirname(__FILE__), '..', '..', 'lib')
- %x{#{Gem.ruby} -I#{lib} -rubygems -S gem --backtrace #{command} #{args}}.strip
+ sys_exec "#{Gem.ruby} -I#{lib} -rubygems -S gem --backtrace #{command} #{args}".strip
end
end
end