From 3e5d4b2c421e8d24cd53cb38e4e3f1b875f2b387 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Mon, 22 Jul 2019 18:21:59 +0200 Subject: Remove unnecessary assignments --- spec/spec_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a90d8e9885..2580187402 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -99,8 +99,8 @@ RSpec.configure do |config| 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" + 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" -- cgit v1.2.1 From 038f0d7c37b8a3f0a3faeac87b4c7b02fd40c22a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 23 Jul 2019 08:15:15 +0200 Subject: Improve test to make it more independent from env --- spec/runtime/with_unbundled_env_spec.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/runtime/with_unbundled_env_spec.rb b/spec/runtime/with_unbundled_env_spec.rb index b901f28c8b..f78cdb5876 100644 --- a/spec/runtime/with_unbundled_env_spec.rb +++ b/spec/runtime/with_unbundled_env_spec.rb @@ -76,11 +76,12 @@ RSpec.describe "Bundler.with_env helpers" do expect(last_command.stdboth).not_to include("-rbundler/setup") end - it "should clean up RUBYLIB", :ruby_repo do + it "should restore RUBYLIB", :ruby_repo do code = "print #{modified_env}['RUBYLIB']" ENV["RUBYLIB"] = root.join("lib").to_s + File::PATH_SEPARATOR + "/foo" + ENV["BUNDLER_ORIG_RUBYLIB"] = root.join("lib").to_s + File::PATH_SEPARATOR + "/foo-original" bundle_exec_ruby! code.dump - expect(last_command.stdboth).to include("/foo") + expect(last_command.stdboth).to include("/foo-original") end it "should restore the original MANPATH" do -- cgit v1.2.1 From a82ad111e5bcd1db2b331cceed0330f453912e61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 23 Jul 2019 08:15:29 +0200 Subject: Remove uneeded bundler key It sounds like this was mistankenly added in 4337a499d0108fc3748084934aaed7591b355a26. Then the forgotten MANPATH key was added in bf5bf106230772934602768bb31a68dc925691f0, but this one should've been removed I think. --- lib/bundler/environment_preserver.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/bundler/environment_preserver.rb b/lib/bundler/environment_preserver.rb index af7c1ef0a4..c9014badad 100644 --- a/lib/bundler/environment_preserver.rb +++ b/lib/bundler/environment_preserver.rb @@ -6,7 +6,6 @@ module Bundler BUNDLER_KEYS = %w[ BUNDLE_BIN_PATH BUNDLE_GEMFILE - BUNDLER_ORIG_MANPATH BUNDLER_VERSION GEM_HOME GEM_PATH -- cgit v1.2.1 From 6d3b809695e579f0b64f111e023f47721cad3f30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 23 Jul 2019 08:14:02 +0200 Subject: Move environment reset to the only test needing it --- spec/runtime/with_unbundled_env_spec.rb | 2 ++ spec/spec_helper.rb | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/runtime/with_unbundled_env_spec.rb b/spec/runtime/with_unbundled_env_spec.rb index f78cdb5876..b346df6283 100644 --- a/spec/runtime/with_unbundled_env_spec.rb +++ b/spec/runtime/with_unbundled_env_spec.rb @@ -54,6 +54,8 @@ RSpec.describe "Bundler.with_env helpers" do end it "removes variables that bundler added", :ruby_repo do + ENV.replace(ENV.to_hash.delete_if {|k, _v| k.start_with?(Bundler::EnvironmentPreserver::BUNDLER_PREFIX) }) + original = ruby!('puts ENV.to_a.map {|e| e.join("=") }.sort.join("\n")') code = 'puts Bundler.original_env.to_a.map {|e| e.join("=") }.sort.join("\n")' bundle_exec_ruby! code.dump diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2580187402..e3af0f55d2 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -78,7 +78,7 @@ RSpec.configure do |config| config.filter_run_when_matching :focus unless ENV["CI"] original_wd = Dir.pwd - original_env = ENV.to_hash.delete_if {|k, _v| k.start_with?(Bundler::EnvironmentPreserver::BUNDLER_PREFIX) } + original_env = ENV.to_hash config.expect_with :rspec do |c| c.syntax = :expect @@ -105,7 +105,7 @@ RSpec.configure do |config| # 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) } + original_env = ENV.to_hash if ENV["BUNDLE_RUBY"] FileUtils.cp_r Spec::Path.bindir, File.join(Spec::Path.root, "lib", "exe") -- cgit v1.2.1 From 6d0a8f4128dbfe855a33421c85419d09d1311d01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 23 Jul 2019 08:16:17 +0200 Subject: Add a comment to explain the initial reset --- spec/runtime/with_unbundled_env_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/runtime/with_unbundled_env_spec.rb b/spec/runtime/with_unbundled_env_spec.rb index b346df6283..d5eed096c2 100644 --- a/spec/runtime/with_unbundled_env_spec.rb +++ b/spec/runtime/with_unbundled_env_spec.rb @@ -54,6 +54,7 @@ RSpec.describe "Bundler.with_env helpers" do end it "removes variables that bundler added", :ruby_repo do + # Simulate bundler has not yet been loaded ENV.replace(ENV.to_hash.delete_if {|k, _v| k.start_with?(Bundler::EnvironmentPreserver::BUNDLER_PREFIX) }) original = ruby!('puts ENV.to_a.map {|e| e.join("=") }.sort.join("\n")') -- cgit v1.2.1