summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2019-05-24 11:03:33 +0200
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2019-05-27 13:03:22 +0200
commitfabb93a5dee650acb8d51e2766ace03e9da6fb35 (patch)
treebafb7fa50a9ecb39841543a5cedd2430800b15ac
parent4acd7dd62f367789c0f09c0fbff68e28e2ededf7 (diff)
downloadbundler-random_test_order.tar.gz
Fix bisectionsrandom_test_order
RSpec bisector needs to read the configuration, for example to find out which kind of runner to use. So, it needs to load the spec helper. It does that, though, before actually shelling out to run any tests. If we modify the environment at the top level, that changes it before shelling out and thus we fail to find RSpec in the subsequent subprocess. So, instead of modifying the environment at the top level, we do it lazily in the `before(:suite)` hook.
-rw-r--r--spec/spec_helper.rb15
1 files changed, 9 insertions, 6 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 29b292968d..d3de1ff784 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -23,12 +23,6 @@ end
$debug = false
Spec::Manpages.setup unless Gem.win_platform?
-Spec::Rubygems.setup
-ENV["RUBYOPT"] = "#{ENV["RUBYOPT"]} -r#{Spec::Path.spec_dir}/support/hax.rb"
-ENV["BUNDLE_SPEC_RUN"] = "true"
-
-# Don't wrap output in tests
-ENV["THOR_COLUMNS"] = "10000"
module Gem
def self.ruby=(ruby)
@@ -104,6 +98,15 @@ RSpec.configure do |config|
end
config.before :suite do
+ Spec::Rubygems.setup
+ ENV["RUBYOPT"] = original_env["RUBYOPT"] = "#{ENV["RUBYOPT"]} -r#{Spec::Path.spec_dir}/support/hax.rb"
+ ENV["BUNDLE_SPEC_RUN"] = original_env["BUNDLE_SPEC_RUN"] = "true"
+
+ # Don't wrap output in tests
+ ENV["THOR_COLUMNS"] = "10000"
+
+ original_env = ENV.to_hash.delete_if {|k, _v| k.start_with?(Bundler::EnvironmentPreserver::BUNDLER_PREFIX) }
+
if ENV["BUNDLE_RUBY"]
FileUtils.cp_r Spec::Path.bindir, File.join(Spec::Path.root, "lib", "exe")
end