From 94f664fc4c55441736aa173b57b1bad6d7ef761d Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Tue, 16 Oct 2018 11:34:40 +0900 Subject: Support file structure of ruby core repository. --- bundler.gemspec | 8 +++++++- lib/bundler/shared_helpers.rb | 16 ++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/bundler.gemspec b/bundler.gemspec index d04bf34e7c..c004de0965 100644 --- a/bundler.gemspec +++ b/bundler.gemspec @@ -1,7 +1,13 @@ # coding: utf-8 # frozen_string_literal: true -require File.expand_path("../lib/bundler/version", __FILE__) +begin + require File.expand_path("../lib/bundler/version", __FILE__) +rescue LoadError + # for Ruby core repository + require File.expand_path("../bundler/version", __FILE__) +end + require "shellwords" Gem::Specification.new do |s| diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index dca17885dd..c4dce8c38f 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -274,8 +274,14 @@ module Bundler until !File.directory?(current) || current == previous if ENV["BUNDLE_SPEC_RUN"] + if File.file?(File.join(current, "bundler.gemspec")) + gemspec = "bundler.gemspec" + else + # for Ruby Core + gemspec = "lib/bundler.gemspec" + end # avoid stepping above the tmp directory when testing - return nil if File.file?(File.join(current, "bundler.gemspec")) + return nil if File.file?(File.join(current, gemspec)) end names.each do |name| @@ -304,10 +310,12 @@ module Bundler unless File.exist?(exe_file) exe_file = File.expand_path("../../../exe/bundle", __FILE__) end - - Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file rescue Gem::GemNotFoundException - Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", File.expand_path("../../../exe/bundle", __FILE__) + exe_file = File.expand_path("../../../exe/bundle", __FILE__) + # for Ruby core repository + exe_file = File.expand_path("../../../../bin/bundle", __FILE__) unless File.exist?(exe_file) + ensure + Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file end # Set BUNDLE_GEMFILE -- cgit v1.2.1 From 91aaca762be64f807072a1445d6291314790a06d Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Tue, 16 Oct 2018 17:32:29 +0900 Subject: rubocop -a --- lib/bundler/shared_helpers.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index c4dce8c38f..b5ca8c2bd3 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -274,12 +274,10 @@ module Bundler until !File.directory?(current) || current == previous if ENV["BUNDLE_SPEC_RUN"] - if File.file?(File.join(current, "bundler.gemspec")) - gemspec = "bundler.gemspec" - else - # for Ruby Core - gemspec = "lib/bundler.gemspec" - end + gemspec = File.join(current, "bundler.gemspec") + # for Ruby Core + gemspec = File.join(current, "lib/bundler.gemspec") unless File.file?(gemspec) + # avoid stepping above the tmp directory when testing return nil if File.file?(File.join(current, gemspec)) end -- cgit v1.2.1 From ce655f16ca1cc4b07af4bb981c20636bc6b02c84 Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Tue, 16 Oct 2018 18:13:54 +0900 Subject: Fixed existence example. --- lib/bundler/shared_helpers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index b5ca8c2bd3..28699dc61f 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -308,11 +308,11 @@ module Bundler unless File.exist?(exe_file) exe_file = File.expand_path("../../../exe/bundle", __FILE__) end + Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file rescue Gem::GemNotFoundException exe_file = File.expand_path("../../../exe/bundle", __FILE__) # for Ruby core repository exe_file = File.expand_path("../../../../bin/bundle", __FILE__) unless File.exist?(exe_file) - ensure Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file end -- cgit v1.2.1 From 5417b218c499db48b23de2bdc38ba2f33d3223c0 Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Tue, 16 Oct 2018 20:45:45 +0900 Subject: Added to support BUNDLE_RUBY and BUNDLE_GEM environmental variables. They are replaced build binary on ruby core repository. --- lib/bundler/shared_helpers.rb | 10 +++++++--- spec/bundler/cli_spec.rb | 3 ++- spec/commands/newgem_spec.rb | 5 ++++- spec/spec_helper.rb | 19 +++++++++++++++++++ spec/support/helpers.rb | 3 ++- spec/support/path.rb | 20 ++++++++++++++++---- 6 files changed, 50 insertions(+), 10 deletions(-) diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index 28699dc61f..9d5684aeaf 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -274,9 +274,13 @@ module Bundler until !File.directory?(current) || current == previous if ENV["BUNDLE_SPEC_RUN"] - gemspec = File.join(current, "bundler.gemspec") - # for Ruby Core - gemspec = File.join(current, "lib/bundler.gemspec") unless File.file?(gemspec) + # avoid stepping above the tmp directory when testing + if !!(ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]) + # for Ruby Core + gemspec = "lib/bundler.gemspec" + else + gemspec = "bundler.gemspec" + end # avoid stepping above the tmp directory when testing return nil if File.file?(File.join(current, gemspec)) diff --git a/spec/bundler/cli_spec.rb b/spec/bundler/cli_spec.rb index 73868d10fb..c82383cabf 100644 --- a/spec/bundler/cli_spec.rb +++ b/spec/bundler/cli_spec.rb @@ -15,7 +15,8 @@ RSpec.describe "bundle executable" do it "looks for a binary and executes it if it's named bundler-" do File.open(tmp("bundler-testtasks"), "w", 0o755) do |f| - f.puts "#!/usr/bin/env ruby\nputs 'Hello, world'\n" + ruby = ENV['BUNDLE_RUBY'] || "/usr/bin/env ruby" + f.puts "#!#{ruby}\nputs 'Hello, world'\n" end with_path_added(tmp) do diff --git a/spec/commands/newgem_spec.rb b/spec/commands/newgem_spec.rb index 598d68ec3a..cfea63ece5 100644 --- a/spec/commands/newgem_spec.rb +++ b/spec/commands/newgem_spec.rb @@ -211,7 +211,10 @@ RSpec.describe "bundle gem" do end Dir.chdir(bundled_app("newgem")) do - system_gems ["rake-10.0.2", :bundler], :path => :bundle_path + gems = ["rake-10.0.2", :bundler] + # for Ruby core repository, Ruby 2.6+ has bundler as standard library. + gems.delete(:bundler) if ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"] + system_gems gems, :path => :bundle_path bundle! "exec rake build" end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1091c0b7f3..f39a4509a2 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -52,6 +52,12 @@ ENV["THOR_COLUMNS"] = "10000" Spec::CodeClimate.setup +module Gem + def self.ruby= ruby + @ruby = ruby + end +end + RSpec.configure do |config| config.include Spec::Builders config.include Spec::Helpers @@ -107,6 +113,13 @@ RSpec.configure do |config| mocks.allow_message_expectations_on_nil = false end + config.before :suite do + if ENV['BUNDLE_RUBY'] + @orig_ruby = Gem.ruby + Gem.ruby = ENV['BUNDLE_RUBY'] + end + end + config.before :all do build_repo1 end @@ -131,4 +144,10 @@ RSpec.configure do |config| Dir.chdir(original_wd) ENV.replace(original_env) end + + config.after :suite do + if ENV['BUNDLE_RUBY'] + Gem.ruby = @orig_ruby + end + end end diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index 87d6152522..e5ff90785e 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -212,7 +212,8 @@ module Spec args = args.gsub(/(?=")/, "\\") args = %("#{args}") end - sys_exec("#{Gem.ruby} -rrubygems -S gem --backtrace #{command} #{args}") + gem = ENV['BUNDLE_GEM'] || "#{Gem.ruby} -rrubygems -S gem --backtrace" + sys_exec("#{gem} #{command} #{args}") end bang :gem_command diff --git a/spec/support/path.rb b/spec/support/path.rb index 8dd8f5a277..d57a2282f0 100644 --- a/spec/support/path.rb +++ b/spec/support/path.rb @@ -5,19 +5,19 @@ require "pathname" module Spec module Path def root - @root ||= Pathname.new(File.expand_path("../../..", __FILE__)) + @root ||= Pathname.new(for_ruby_core? ? "../../../.." : "../../..").expand_path(__FILE__) end def gemspec - @gemspec ||= root.join("bundler.gemspec") + @gemspec ||= root.join(for_ruby_core? ? "lib/bundler.gemspec" : "bundler.gemspec") end def bindir - @bindir ||= root.join("exe") + @bindir ||= root.join(for_ruby_core? ? "bin" : "exe") end def spec_dir - @spec_dir ||= root.join("spec") + @spec_dir ||= root.join(for_ruby_core? ? "spec/bundler" : "spec") end def tmp(*path) @@ -111,5 +111,17 @@ module Spec end extend self + + private + def for_ruby_core? + # avoid to wornings + @for_ruby_core ||= nil + + if @for_ruby_core.nil? + @for_ruby_core = true & (ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]) + else + @for_ruby_core + end + end end end -- cgit v1.2.1 From 2519ba9faf0dda681545fe38c6be7979155007c8 Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Tue, 16 Oct 2018 20:59:38 +0900 Subject: Added ruby_core filtering condition with some examples. The ruby core repository couldn't invoke its examples. --- spec/commands/binstubs_spec.rb | 2 +- spec/commands/clean_spec.rb | 2 +- spec/commands/exec_spec.rb | 24 ++++++++++++------------ spec/commands/help_spec.rb | 16 ++++++++-------- spec/commands/info_spec.rb | 2 +- spec/commands/pristine_spec.rb | 4 ++-- spec/commands/show_spec.rb | 4 ++-- spec/install/deploy_spec.rb | 2 +- spec/install/gemfile/git_spec.rb | 6 +++--- spec/install/gems/compact_index_spec.rb | 2 +- spec/install/gems/dependency_api_spec.rb | 2 +- spec/install/gems/native_extensions_spec.rb | 2 +- spec/install/gems/resolving_spec.rb | 6 +++--- spec/install/gems/standalone_spec.rb | 2 +- spec/install/global_cache_spec.rb | 2 +- spec/install/path_spec.rb | 2 +- spec/other/bundle_ruby_spec.rb | 2 +- spec/quality_spec.rb | 16 ++++++++-------- spec/runtime/setup_spec.rb | 8 ++++---- spec/runtime/with_clean_env_spec.rb | 8 ++++---- spec/spec_helper.rb | 1 + 21 files changed, 58 insertions(+), 57 deletions(-) diff --git a/spec/commands/binstubs_spec.rb b/spec/commands/binstubs_spec.rb index ad859a21d5..09371572eb 100644 --- a/spec/commands/binstubs_spec.rb +++ b/spec/commands/binstubs_spec.rb @@ -192,7 +192,7 @@ RSpec.describe "bundle binstubs " do end end - context "using another binstub" do + context "using another binstub", :ruby_repo do let(:system_bundler_version) { :bundler } it "loads all gems" do sys_exec! bundled_app("bin/print_loaded_gems").to_s diff --git a/spec/commands/clean_spec.rb b/spec/commands/clean_spec.rb index ff3317bb1d..00fa40f92e 100644 --- a/spec/commands/clean_spec.rb +++ b/spec/commands/clean_spec.rb @@ -712,7 +712,7 @@ RSpec.describe "bundle clean" do should_not_have_gems "foo-1.0" end - it "doesn't remove extensions artifacts from bundled git gems after clean", :rubygems => "2.2" do + it "doesn't remove extensions artifacts from bundled git gems after clean", :ruby_repo, :rubygems => "2.2" do build_git "very_simple_git_binary", &:add_c_extension revision = revision_for(lib_path("very_simple_git_binary-1.0")) diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb index acf12ced79..490bedacf0 100644 --- a/spec/commands/exec_spec.rb +++ b/spec/commands/exec_spec.rb @@ -33,7 +33,7 @@ RSpec.describe "bundle exec" do expect(out).to eq("1.0.0") end - it "works when running from a random directory" do + it "works when running from a random directory", :ruby_repo do install_gemfile <<-G gem "rack" G @@ -178,7 +178,7 @@ RSpec.describe "bundle exec" do expect(out).to have_rubyopts(rubyopt) end - it "does not duplicate already exec'ed RUBYLIB" do + it "does not duplicate already exec'ed RUBYLIB", :ruby_repo do install_gemfile <<-G gem "rack" G @@ -226,7 +226,7 @@ RSpec.describe "bundle exec" do expect(out).to include("bundler: exec needs a command to run") end - it "raises a helpful error when exec'ing to something outside of the bundle", :rubygems => ">= 2.5.2" do + it "raises a helpful error when exec'ing to something outside of the bundle", :ruby_repo, :rubygems => ">= 2.5.2" do bundle! "config clean false" # want to keep the rackup binstub install_gemfile! <<-G source "file://#{gem_repo1}" @@ -303,35 +303,35 @@ RSpec.describe "bundle exec" do expect(out).to eq('args: ["-h"]') end - it "shows bundle-exec's man page when --help is between exec and the executable" do + it "shows bundle-exec's man page when --help is between exec and the executable", :ruby_repo do with_fake_man do bundle "#{exec} --help cat" end expect(out).to include(%(["#{root}/man/bundle-exec.1"])) end - it "shows bundle-exec's man page when --help is before exec" do + it "shows bundle-exec's man page when --help is before exec", :ruby_repo do with_fake_man do bundle "--help #{exec}" end expect(out).to include(%(["#{root}/man/bundle-exec.1"])) end - it "shows bundle-exec's man page when -h is before exec" do + it "shows bundle-exec's man page when -h is before exec", :ruby_repo do with_fake_man do bundle "-h #{exec}" end expect(out).to include(%(["#{root}/man/bundle-exec.1"])) end - it "shows bundle-exec's man page when --help is after exec" do + it "shows bundle-exec's man page when --help is after exec", :ruby_repo do with_fake_man do bundle "#{exec} --help" end expect(out).to include(%(["#{root}/man/bundle-exec.1"])) end - it "shows bundle-exec's man page when -h is after exec" do + it "shows bundle-exec's man page when -h is after exec", :ruby_repo do with_fake_man do bundle "#{exec} -h" end @@ -349,13 +349,13 @@ RSpec.describe "bundle exec" do G end - it "works when unlocked" do + it "works when unlocked", :ruby_repo do bundle "exec 'cd #{tmp("gems")} && rackup'", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" } expect(out).to eq("1.0.0") expect(out).to include("1.0.0") end - it "works when locked" do + it "works when locked", :ruby_repo do expect(the_bundle).to be_locked bundle "exec 'cd #{tmp("gems")} && rackup'", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" } expect(out).to include("1.0.0") @@ -633,7 +633,7 @@ RSpec.describe "bundle exec" do it_behaves_like "it runs" end - context "when the file uses the current ruby shebang" do + context "when the file uses the current ruby shebang", :ruby_repo do let(:shebang) { "#!#{Gem.ruby}" } it_behaves_like "it runs" end @@ -785,7 +785,7 @@ __FILE__: #{path.to_s.inspect} end end - context "nested bundle exec" do + context "nested bundle exec", :ruby_repo do let(:system_gems_to_install) { super() << :bundler } context "with shared gems disabled" do diff --git a/spec/commands/help_spec.rb b/spec/commands/help_spec.rb index 56b1b6f722..cd6f13756c 100644 --- a/spec/commands/help_spec.rb +++ b/spec/commands/help_spec.rb @@ -10,21 +10,21 @@ RSpec.describe "bundle help" do expect(err).to include("running `gem cleanup bundler`.") end - it "uses mann when available" do + it "uses mann when available", :ruby_repo do with_fake_man do bundle "help gemfile" end expect(out).to eq(%(["#{root}/man/gemfile.5"])) end - it "prefixes bundle commands with bundle- when finding the groff files" do + it "prefixes bundle commands with bundle- when finding the groff files", :ruby_repo do with_fake_man do bundle "help install" end expect(out).to eq(%(["#{root}/man/bundle-install.1"])) end - it "simply outputs the txt file when there is no man on the path" do + it "simply outputs the txt file when there is no man on the path", :ruby_repo do with_path_as("") do bundle "help install" end @@ -49,28 +49,28 @@ RSpec.describe "bundle help" do expect(out).to eq("--help") end - it "is called when the --help flag is used after the command" do + it "is called when the --help flag is used after the command", :ruby_repo do with_fake_man do bundle "install --help" end expect(out).to eq(%(["#{root}/man/bundle-install.1"])) end - it "is called when the --help flag is used before the command" do + it "is called when the --help flag is used before the command", :ruby_repo do with_fake_man do bundle "--help install" end expect(out).to eq(%(["#{root}/man/bundle-install.1"])) end - it "is called when the -h flag is used before the command" do + it "is called when the -h flag is used before the command", :ruby_repo do with_fake_man do bundle "-h install" end expect(out).to eq(%(["#{root}/man/bundle-install.1"])) end - it "is called when the -h flag is used after the command" do + it "is called when the -h flag is used after the command", :ruby_repo do with_fake_man do bundle "install -h" end @@ -84,7 +84,7 @@ RSpec.describe "bundle help" do expect(out).to include('Could not find command "instill".') end - it "is called when only using the --help flag" do + it "is called when only using the --help flag", :ruby_repo do with_fake_man do bundle "--help" end diff --git a/spec/commands/info_spec.rb b/spec/commands/info_spec.rb index a08965ec0e..a9ab8fc210 100644 --- a/spec/commands/info_spec.rb +++ b/spec/commands/info_spec.rb @@ -24,7 +24,7 @@ RSpec.describe "bundle info" do end end - context "given a default gem shippped in ruby" do + context "given a default gem shippped in ruby", :ruby_repo do it "prints information about the default gem", :if => (RUBY_VERSION >= "2.0") do bundle "info rdoc" expect(out).to include("* rdoc") diff --git a/spec/commands/pristine_spec.rb b/spec/commands/pristine_spec.rb index de3cb8054b..da6bb1c093 100644 --- a/spec/commands/pristine_spec.rb +++ b/spec/commands/pristine_spec.rb @@ -2,7 +2,7 @@ require "bundler/vendored_fileutils" -RSpec.describe "bundle pristine" do +RSpec.describe "bundle pristine", :ruby_repo do before :each do build_lib "baz", :path => bundled_app do |s| s.version = "1.0.0" @@ -42,7 +42,7 @@ RSpec.describe "bundle pristine" do expect(changes_txt).to_not be_file end - it "does not delete the bundler gem" do + it "does not delete the bundler gem", :ruby_repo do ENV["BUNDLER_SPEC_KEEP_DEFAULT_BUNDLER_GEM"] = "true" system_gems :bundler bundle! "install" diff --git a/spec/commands/show_spec.rb b/spec/commands/show_spec.rb index 102b9534de..369d0d708a 100644 --- a/spec/commands/show_spec.rb +++ b/spec/commands/show_spec.rb @@ -60,12 +60,12 @@ RSpec.describe "bundle show" do and include(default_bundle_path("gems", "rails-2.3.2").to_s) end - it "prints the path to the running bundler", :bundler => "< 2" do + it "prints the path to the running bundler", :ruby_repo, :bundler => "< 2" do bundle "show bundler" expect(out).to eq(root.to_s) end - it "prints the path to the running bundler", :bundler => "2" do + it "prints the path to the running bundler", :ruby_repo, :bundler => "2" do bundle "show bundler" expect(out).to eq( "[DEPRECATED FOR 2.0] use `bundle info bundler` instead of `bundle show bundler`\n" + diff --git a/spec/install/deploy_spec.rb b/spec/install/deploy_spec.rb index 491801e27a..3b9d68982a 100644 --- a/spec/install/deploy_spec.rb +++ b/spec/install/deploy_spec.rb @@ -64,7 +64,7 @@ RSpec.describe "install with --deployment or --frozen" do bundle! :install, forgotten_command_line_options(:deployment => true, :without => "test") end - it "works when you bundle exec bundle" do + it "works when you bundle exec bundle", :ruby_repo do bundle :install bundle "install --deployment" bundle! "exec bundle check" diff --git a/spec/install/gemfile/git_spec.rb b/spec/install/gemfile/git_spec.rb index 651deb3265..ab9fdd9f86 100644 --- a/spec/install/gemfile/git_spec.rb +++ b/spec/install/gemfile/git_spec.rb @@ -1099,7 +1099,7 @@ RSpec.describe "bundle install with git sources" do end context "with an extension" do - it "installs the extension" do + it "installs the extension", :ruby_repo do build_git "foo" do |s| s.add_dependency "rake" s.extensions << "Rakefile" @@ -1131,7 +1131,7 @@ RSpec.describe "bundle install with git sources" do expect(out).to eq(Pathname.glob(default_bundle_path("bundler/gems/extensions/**/foo-1.0-*")).first.to_s) end - it "does not use old extension after ref changes" do + it "does not use old extension after ref changes", :ruby_repo do git_reader = build_git "foo", :no_default => true do |s| s.extensions = ["ext/extconf.rb"] s.write "ext/extconf.rb", <<-RUBY @@ -1193,7 +1193,7 @@ In Gemfile: expect(out).not_to include("gem install foo") end - it "does not reinstall the extension", :rubygems => ">= 2.3.0" do + it "does not reinstall the extension", :ruby_repo, :rubygems => ">= 2.3.0" do build_git "foo" do |s| s.add_dependency "rake" s.extensions << "Rakefile" diff --git a/spec/install/gems/compact_index_spec.rb b/spec/install/gems/compact_index_spec.rb index 02a37a77d5..b06b72ecfa 100644 --- a/spec/install/gems/compact_index_spec.rb +++ b/spec/install/gems/compact_index_spec.rb @@ -717,7 +717,7 @@ The checksum of /versions does not match the checksum provided by the server! So end end - context "when ruby is compiled without openssl" do + context "when ruby is compiled without openssl", :ruby_repo do before do # Install a monkeypatch that reproduces the effects of openssl being # missing when the fetcher runs, as happens in real life. The reason diff --git a/spec/install/gems/dependency_api_spec.rb b/spec/install/gems/dependency_api_spec.rb index 2ffe4b62d7..fe696f38c3 100644 --- a/spec/install/gems/dependency_api_spec.rb +++ b/spec/install/gems/dependency_api_spec.rb @@ -691,7 +691,7 @@ RSpec.describe "gemcutter's dependency API" do end end - context "when ruby is compiled without openssl" do + context "when ruby is compiled without openssl", :ruby_repo do before do # Install a monkeypatch that reproduces the effects of openssl being # missing when the fetcher runs, as happens in real life. The reason diff --git a/spec/install/gems/native_extensions_spec.rb b/spec/install/gems/native_extensions_spec.rb index c8252b81f1..ea616f60d3 100644 --- a/spec/install/gems/native_extensions_spec.rb +++ b/spec/install/gems/native_extensions_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe "installing a gem with native extensions" do +RSpec.describe "installing a gem with native extensions", :ruby_repo do it "installs" do build_repo2 do build_gem "c_extension" do |s| diff --git a/spec/install/gems/resolving_spec.rb b/spec/install/gems/resolving_spec.rb index f581522c71..ddf803ed7d 100644 --- a/spec/install/gems/resolving_spec.rb +++ b/spec/install/gems/resolving_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true RSpec.describe "bundle install with install-time dependencies" do - it "installs gems with implicit rake dependencies" do + it "installs gems with implicit rake dependencies", :ruby_repo do install_gemfile <<-G source "file://#{gem_repo1}" gem "with_implicit_rake_dep" @@ -48,7 +48,7 @@ RSpec.describe "bundle install with install-time dependencies" do expect(the_bundle).to include_gems "net_b 1.0" end - it "installs plugins depended on by other plugins" do + it "installs plugins depended on by other plugins", :ruby_repo do install_gemfile <<-G source "file://#{gem_repo1}" gem "net_a" @@ -57,7 +57,7 @@ RSpec.describe "bundle install with install-time dependencies" do expect(the_bundle).to include_gems "net_a 1.0", "net_b 1.0" end - it "installs multiple levels of dependencies" do + it "installs multiple levels of dependencies", :ruby_repo do install_gemfile <<-G source "file://#{gem_repo1}" gem "net_c" diff --git a/spec/install/gems/standalone_spec.rb b/spec/install/gems/standalone_spec.rb index b149d9d00b..10ce589eef 100644 --- a/spec/install/gems/standalone_spec.rb +++ b/spec/install/gems/standalone_spec.rb @@ -67,7 +67,7 @@ RSpec.shared_examples "bundle install --standalone" do include_examples "common functionality" end - describe "with gems with native extension" do + describe "with gems with native extension", :ruby_repo do before do install_gemfile <<-G, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => true) source "file://#{gem_repo1}" diff --git a/spec/install/global_cache_spec.rb b/spec/install/global_cache_spec.rb index 3664d3963a..e41e7e0157 100644 --- a/spec/install/global_cache_spec.rb +++ b/spec/install/global_cache_spec.rb @@ -187,7 +187,7 @@ RSpec.describe "global gem caching" do end end - describe "extension caching", :rubygems => "2.2" do + describe "extension caching", :ruby_repo, :rubygems => "2.2" do it "works" do build_git "very_simple_git_binary", &:add_c_extension build_lib "very_simple_path_binary", &:add_c_extension diff --git a/spec/install/path_spec.rb b/spec/install/path_spec.rb index 5f3fedb862..44439c275e 100644 --- a/spec/install/path_spec.rb +++ b/spec/install/path_spec.rb @@ -207,7 +207,7 @@ RSpec.describe "bundle install" do expect(the_bundle).to include_gems "rack 1.0.0" end - it "re-installs gems whose extensions have been deleted", :rubygems => ">= 2.3" do + it "re-installs gems whose extensions have been deleted", :ruby_repo, :rubygems => ">= 2.3" do build_lib "very_simple_binary", "1.0.0", :to_system => true do |s| s.write "lib/very_simple_binary.rb", "raise 'FAIL'" end diff --git a/spec/other/bundle_ruby_spec.rb b/spec/other/bundle_ruby_spec.rb index a7da9cbec9..8e365a489c 100644 --- a/spec/other/bundle_ruby_spec.rb +++ b/spec/other/bundle_ruby_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe "bundle_ruby", :bundler => "< 2" do +RSpec.describe "bundle_ruby", :ruby_repo, :bundler => "< 2" do context "without patchlevel" do it "returns the ruby version" do gemfile <<-G diff --git a/spec/quality_spec.rb b/spec/quality_spec.rb index f8aec009ef..84da4aaeb9 100644 --- a/spec/quality_spec.rb +++ b/spec/quality_spec.rb @@ -104,7 +104,7 @@ RSpec.describe "The library itself" do end end - it "has no malformed whitespace" do + it "has no malformed whitespace", :ruby_repo do exempt = /\.gitmodules|\.marshal|fixtures|vendor|ssl_certs|LICENSE|vcr_cassettes/ error_messages = [] Dir.chdir(root) do @@ -117,7 +117,7 @@ RSpec.describe "The library itself" do expect(error_messages.compact).to be_well_formed end - it "does not include any leftover debugging or development mechanisms" do + it "does not include any leftover debugging or development mechanisms", :ruby_repo do exempt = %r{quality_spec.rb|support/helpers|vcr_cassettes|\.md|\.ronn} error_messages = [] Dir.chdir(root) do @@ -129,7 +129,7 @@ RSpec.describe "The library itself" do expect(error_messages.compact).to be_well_formed end - it "does not include any unresolved merge conflicts" do + it "does not include any unresolved merge conflicts", :ruby_repo do error_messages = [] exempt = %r{lock/lockfile_(bundler_1_)?spec|quality_spec|vcr_cassettes|\.ronn|lockfile_parser\.rb} Dir.chdir(root) do @@ -141,7 +141,7 @@ RSpec.describe "The library itself" do expect(error_messages.compact).to be_well_formed end - it "maintains language quality of the documentation" do + it "maintains language quality of the documentation", :ruby_repo do included = /ronn/ error_messages = [] Dir.chdir(root) do @@ -154,7 +154,7 @@ RSpec.describe "The library itself" do expect(error_messages.compact).to be_well_formed end - it "maintains language quality of sentences used in source code" do + it "maintains language quality of sentences used in source code", :ruby_repo do error_messages = [] exempt = /vendor/ Dir.chdir(root) do @@ -167,7 +167,7 @@ RSpec.describe "The library itself" do expect(error_messages.compact).to be_well_formed end - it "documents all used settings" do + it "documents all used settings", :ruby_repo do exemptions = %w[ auto_config_jobs cache_command_is_package @@ -216,7 +216,7 @@ RSpec.describe "The library itself" do expect(documented_settings).to be_sorted end - it "can still be built" do + it "can still be built", :ruby_repo do Dir.chdir(root) do begin gem_command! :build, "bundler.gemspec" @@ -235,7 +235,7 @@ RSpec.describe "The library itself" do end end - it "does not contain any warnings" do + it "does not contain any warnings", :ruby_repo do Dir.chdir(root) do exclusions = %w[ lib/bundler/capistrano.rb diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index 93a25b1ea8..376053a625 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -119,7 +119,7 @@ RSpec.describe "Bundler.setup" do lp.map! {|p| p.sub(/^#{Regexp.union system_gem_path.to_s, default_bundle_path.to_s}/i, "") } end - it "puts loaded gems after -I and RUBYLIB" do + it "puts loaded gems after -I and RUBYLIB", :ruby_repo do install_gemfile <<-G source "file://#{gem_repo1}" gem "rack" @@ -144,7 +144,7 @@ RSpec.describe "Bundler.setup" do expect(rack_load_order).to be > 0 end - it "orders the load path correctly when there are dependencies" do + it "orders the load path correctly when there are dependencies", :ruby_repo do install_gemfile <<-G source "file://#{gem_repo1}" gem "rails" @@ -824,7 +824,7 @@ end expect(out).to eq("yay") end - it "should clean $LOAD_PATH properly" do + it "should clean $LOAD_PATH properly", :ruby_repo do gem_name = "very_simple_binary" full_gem_name = gem_name + "-1.0" ext_dir = File.join(tmp("extensions", full_gem_name)) @@ -1265,7 +1265,7 @@ end expect(out).to eq("undefined\nconstant") end - describe "default gem activation" do + describe "default gem activation", :ruby_repo do let(:exemptions) do if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("2.7") || ENV["RGV"] == "master" [] diff --git a/spec/runtime/with_clean_env_spec.rb b/spec/runtime/with_clean_env_spec.rb index fd621071ad..c88da3cd02 100644 --- a/spec/runtime/with_clean_env_spec.rb +++ b/spec/runtime/with_clean_env_spec.rb @@ -16,7 +16,7 @@ RSpec.describe "Bundler.with_env helpers" do bundle "install" end - it "should return the PATH present before bundle was activated" do + it "should return the PATH present before bundle was activated", :ruby_repo do code = "print Bundler.original_env['PATH']" path = `getconf PATH`.strip + "#{File::PATH_SEPARATOR}/foo" with_path_as(path) do @@ -34,7 +34,7 @@ RSpec.describe "Bundler.with_env helpers" do end end - it "works with nested bundle exec invocations" do + it "works with nested bundle exec invocations", :ruby_repo do create_file("exe.rb", <<-'RB') count = ARGV.first.to_i exit if count < 0 @@ -55,7 +55,7 @@ RSpec.describe "Bundler.with_env helpers" do EOS end - it "removes variables that bundler added" do + it "removes variables that bundler added", :ruby_repo do original = ruby!('puts ENV.to_a.map {|e| e.join("=") }.sort.join("\n")', :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }) code = 'puts Bundler.original_env.to_a.map {|e| e.join("=") }.sort.join("\n")' bundle! "exec '#{Gem.ruby}' -e #{code.dump}", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" } @@ -84,7 +84,7 @@ RSpec.describe "Bundler.with_env helpers" do expect(last_command.stdboth).not_to include("-rbundler/setup") end - it "should clean up RUBYLIB" do + it "should clean up RUBYLIB", :ruby_repo do code = "print Bundler.clean_env['RUBYLIB']" ENV["RUBYLIB"] = root.join("lib").to_s + File::PATH_SEPARATOR + "/foo" bundle_exec_ruby! code.dump diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f39a4509a2..45a3bcbf89 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -99,6 +99,7 @@ RSpec.configure do |config| config.filter_run_excluding :git => LessThanProc.with(git_version) config.filter_run_excluding :rubygems_master => (ENV["RGV"] != "master") config.filter_run_excluding :bundler => LessThanProc.with(Bundler::VERSION.split(".")[0, 2].join(".")) + config.filter_run_excluding :ruby_repo => !!(ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]) config.filter_run_when_matching :focus unless ENV["CI"] -- cgit v1.2.1 From 96f24244c7bad1b78fdf60edcad7f9a092dea6fa Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Tue, 16 Oct 2018 21:00:52 +0900 Subject: Restore rubygems certificates. Current bundler examples will remove them after finished bundler rspec. --- spec/bundler/ssl_certs/certificate_manager_spec.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spec/bundler/ssl_certs/certificate_manager_spec.rb b/spec/bundler/ssl_certs/certificate_manager_spec.rb index 2e43193359..d1ec08bdc4 100644 --- a/spec/bundler/ssl_certs/certificate_manager_spec.rb +++ b/spec/bundler/ssl_certs/certificate_manager_spec.rb @@ -11,13 +11,19 @@ RSpec.describe Bundler::SSLCerts::CertificateManager do # Pretend bundler root is rubygems root before do + # Backing up rubygems ceriticates + FileUtils.mv(rubygems_certs_dir, rubygems_certs_dir + ".back") if !!(ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]) + FileUtils.mkdir_p(rubygems_certs_dir) FileUtils.touch(stub_cert) end after do rubygems_dir = File.join(root.to_s, "lib", "rubygems") - FileUtils.rm_rf(rubygems_dir) + FileUtils.rm_rf(rubygems_certs_dir) + + # Restore rubygems certificates + FileUtils.mv(rubygems_certs_dir + ".back", rubygems_certs_dir) if !!(ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]) end describe "#update_from" do -- cgit v1.2.1 From 6d2c0d2a199564a75612eb492adec5e27eaa923d Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Wed, 17 Oct 2018 16:01:39 +0900 Subject: rubocop -a --- lib/bundler/shared_helpers.rb | 6 +++--- spec/bundler/cli_spec.rb | 2 +- spec/bundler/ssl_certs/certificate_manager_spec.rb | 5 ++--- spec/spec_helper.rb | 12 +++++------- spec/support/helpers.rb | 2 +- spec/support/path.rb | 3 ++- 6 files changed, 14 insertions(+), 16 deletions(-) diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index 9d5684aeaf..e09e5e8b74 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -275,11 +275,11 @@ module Bundler until !File.directory?(current) || current == previous if ENV["BUNDLE_SPEC_RUN"] # avoid stepping above the tmp directory when testing - if !!(ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]) + gemspec = if ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"] # for Ruby Core - gemspec = "lib/bundler.gemspec" + "lib/bundler.gemspec" else - gemspec = "bundler.gemspec" + "bundler.gemspec" end # avoid stepping above the tmp directory when testing diff --git a/spec/bundler/cli_spec.rb b/spec/bundler/cli_spec.rb index c82383cabf..c82d46587e 100644 --- a/spec/bundler/cli_spec.rb +++ b/spec/bundler/cli_spec.rb @@ -15,7 +15,7 @@ RSpec.describe "bundle executable" do it "looks for a binary and executes it if it's named bundler-" do File.open(tmp("bundler-testtasks"), "w", 0o755) do |f| - ruby = ENV['BUNDLE_RUBY'] || "/usr/bin/env ruby" + ruby = ENV["BUNDLE_RUBY"] || "/usr/bin/env ruby" f.puts "#!#{ruby}\nputs 'Hello, world'\n" end diff --git a/spec/bundler/ssl_certs/certificate_manager_spec.rb b/spec/bundler/ssl_certs/certificate_manager_spec.rb index d1ec08bdc4..4250bfc497 100644 --- a/spec/bundler/ssl_certs/certificate_manager_spec.rb +++ b/spec/bundler/ssl_certs/certificate_manager_spec.rb @@ -12,18 +12,17 @@ RSpec.describe Bundler::SSLCerts::CertificateManager do # Pretend bundler root is rubygems root before do # Backing up rubygems ceriticates - FileUtils.mv(rubygems_certs_dir, rubygems_certs_dir + ".back") if !!(ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]) + FileUtils.mv(rubygems_certs_dir, rubygems_certs_dir + ".back") if ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"] FileUtils.mkdir_p(rubygems_certs_dir) FileUtils.touch(stub_cert) end after do - rubygems_dir = File.join(root.to_s, "lib", "rubygems") FileUtils.rm_rf(rubygems_certs_dir) # Restore rubygems certificates - FileUtils.mv(rubygems_certs_dir + ".back", rubygems_certs_dir) if !!(ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]) + FileUtils.mv(rubygems_certs_dir + ".back", rubygems_certs_dir) if ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"] end describe "#update_from" do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 45a3bcbf89..711bf576a9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -53,7 +53,7 @@ ENV["THOR_COLUMNS"] = "10000" Spec::CodeClimate.setup module Gem - def self.ruby= ruby + def self.ruby=(ruby) @ruby = ruby end end @@ -99,7 +99,7 @@ RSpec.configure do |config| config.filter_run_excluding :git => LessThanProc.with(git_version) config.filter_run_excluding :rubygems_master => (ENV["RGV"] != "master") config.filter_run_excluding :bundler => LessThanProc.with(Bundler::VERSION.split(".")[0, 2].join(".")) - config.filter_run_excluding :ruby_repo => !!(ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]) + config.filter_run_excluding :ruby_repo => (ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]) config.filter_run_when_matching :focus unless ENV["CI"] @@ -115,9 +115,9 @@ RSpec.configure do |config| end config.before :suite do - if ENV['BUNDLE_RUBY'] + if ENV["BUNDLE_RUBY"] @orig_ruby = Gem.ruby - Gem.ruby = ENV['BUNDLE_RUBY'] + Gem.ruby = ENV["BUNDLE_RUBY"] end end @@ -147,8 +147,6 @@ RSpec.configure do |config| end config.after :suite do - if ENV['BUNDLE_RUBY'] - Gem.ruby = @orig_ruby - end + Gem.ruby = @orig_ruby if ENV["BUNDLE_RUBY"] end end diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index e5ff90785e..e3b57c1a31 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -212,7 +212,7 @@ module Spec args = args.gsub(/(?=")/, "\\") args = %("#{args}") end - gem = ENV['BUNDLE_GEM'] || "#{Gem.ruby} -rrubygems -S gem --backtrace" + gem = ENV["BUNDLE_GEM"] || "#{Gem.ruby} -rrubygems -S gem --backtrace" sys_exec("#{gem} #{command} #{args}") end bang :gem_command diff --git a/spec/support/path.rb b/spec/support/path.rb index d57a2282f0..1a3444f365 100644 --- a/spec/support/path.rb +++ b/spec/support/path.rb @@ -112,7 +112,8 @@ module Spec extend self - private + private + def for_ruby_core? # avoid to wornings @for_ruby_core ||= nil -- cgit v1.2.1 From 09bfdfa31ad5ae34d29745344493f6a63d355804 Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Thu, 1 Nov 2018 21:49:41 +0900 Subject: Backport from ruby core --- spec/bundler/env_spec.rb | 2 +- spec/bundler/mirror_spec.rb | 2 +- spec/bundler/shared_helpers_spec.rb | 3 ++- spec/commands/binstubs_spec.rb | 4 ++-- spec/commands/clean_spec.rb | 2 +- spec/commands/exec_spec.rb | 22 +++++++++--------- spec/commands/help_spec.rb | 16 ++++++------- spec/commands/pristine_spec.rb | 2 +- spec/install/gemfile/platform_spec.rb | 8 +++---- spec/install/gems/compact_index_spec.rb | 2 +- spec/install/gems/dependency_api_spec.rb | 2 +- spec/lock/lockfile_bundler_1_spec.rb | 2 +- spec/other/bundle_ruby_spec.rb | 2 +- spec/quality_spec.rb | 39 +++++++++++++++++++------------- spec/runtime/gem_tasks_spec.rb | 2 +- spec/runtime/setup_spec.rb | 11 +++++---- spec/runtime/with_clean_env_spec.rb | 2 +- spec/spec_helper.rb | 2 +- spec/support/helpers.rb | 6 ++++- spec/support/path.rb | 24 +++++++++----------- 20 files changed, 83 insertions(+), 72 deletions(-) diff --git a/spec/bundler/env_spec.rb b/spec/bundler/env_spec.rb index 10762b3cd2..20bd38b021 100644 --- a/spec/bundler/env_spec.rb +++ b/spec/bundler/env_spec.rb @@ -141,7 +141,7 @@ RSpec.describe Bundler::Env do end end - describe ".version_of" do + describe ".version_of", :ruby_repo do let(:parsed_version) { described_class.send(:version_of, "ruby") } it "strips version of new line characters" do diff --git a/spec/bundler/mirror_spec.rb b/spec/bundler/mirror_spec.rb index 0a8b9f8926..acd0895f2f 100644 --- a/spec/bundler/mirror_spec.rb +++ b/spec/bundler/mirror_spec.rb @@ -304,7 +304,7 @@ RSpec.describe Bundler::Settings::TCPSocketProbe do server.close unless server.closed? end - it "probes the server correctly" do + it "probes the server correctly", :ruby_repo do with_server_and_mirror do |server, mirror| expect(server.closed?).to be_falsey expect(probe.replies?(mirror)).to be_truthy diff --git a/spec/bundler/shared_helpers_spec.rb b/spec/bundler/shared_helpers_spec.rb index 72b1c2a51f..b66c43fd92 100644 --- a/spec/bundler/shared_helpers_spec.rb +++ b/spec/bundler/shared_helpers_spec.rb @@ -384,7 +384,8 @@ RSpec.describe Bundler::SharedHelpers do it "sets BUNDLE_BIN_PATH to the bundle executable file" do subject.set_bundle_environment - expect(ENV["BUNDLE_BIN_PATH"]).to eq(File.expand_path("../../../exe/bundle", __FILE__)) + bundle_exe = ruby_core? ? "../../../../exe/bundle" : "../../../exe/bundle" + expect(ENV["BUNDLE_BIN_PATH"]).to eq(File.expand_path(bundle_exe, __FILE__)) end end diff --git a/spec/commands/binstubs_spec.rb b/spec/commands/binstubs_spec.rb index 09371572eb..2f014f2631 100644 --- a/spec/commands/binstubs_spec.rb +++ b/spec/commands/binstubs_spec.rb @@ -192,7 +192,7 @@ RSpec.describe "bundle binstubs " do end end - context "using another binstub", :ruby_repo do + context "using another binstub" do let(:system_bundler_version) { :bundler } it "loads all gems" do sys_exec! bundled_app("bin/print_loaded_gems").to_s @@ -202,7 +202,7 @@ RSpec.describe "bundle binstubs " do context "when requesting a different bundler version" do before { lockfile lockfile.gsub(Bundler::VERSION, "999.999.999") } - it "attempts to load that version" do + it "attempts to load that version", :ruby_repo do sys_exec bundled_app("bin/rackup").to_s expect(exitstatus).to eq(42) if exitstatus expect(last_command.stderr).to include("Activating bundler (999.999.999) failed:"). diff --git a/spec/commands/clean_spec.rb b/spec/commands/clean_spec.rb index 00fa40f92e..37cbeeb4e7 100644 --- a/spec/commands/clean_spec.rb +++ b/spec/commands/clean_spec.rb @@ -734,7 +734,7 @@ RSpec.describe "bundle clean" do expect(vendored_gems("bundler/gems/very_simple_git_binary-1.0-#{revision[0..11]}")).to exist end - it "removes extension directories", :rubygems => "2.2" do + it "removes extension directories", :ruby_repo, :rubygems => "2.2" do gemfile <<-G source "file://#{gem_repo1}" diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb index 490bedacf0..fdf60cefe7 100644 --- a/spec/commands/exec_spec.rb +++ b/spec/commands/exec_spec.rb @@ -178,7 +178,7 @@ RSpec.describe "bundle exec" do expect(out).to have_rubyopts(rubyopt) end - it "does not duplicate already exec'ed RUBYLIB", :ruby_repo do + it "does not duplicate already exec'ed RUBYLIB" do install_gemfile <<-G gem "rack" G @@ -303,35 +303,35 @@ RSpec.describe "bundle exec" do expect(out).to eq('args: ["-h"]') end - it "shows bundle-exec's man page when --help is between exec and the executable", :ruby_repo do + it "shows bundle-exec's man page when --help is between exec and the executable" do with_fake_man do bundle "#{exec} --help cat" end expect(out).to include(%(["#{root}/man/bundle-exec.1"])) end - it "shows bundle-exec's man page when --help is before exec", :ruby_repo do + it "shows bundle-exec's man page when --help is before exec" do with_fake_man do bundle "--help #{exec}" end expect(out).to include(%(["#{root}/man/bundle-exec.1"])) end - it "shows bundle-exec's man page when -h is before exec", :ruby_repo do + it "shows bundle-exec's man page when -h is before exec" do with_fake_man do bundle "-h #{exec}" end expect(out).to include(%(["#{root}/man/bundle-exec.1"])) end - it "shows bundle-exec's man page when --help is after exec", :ruby_repo do + it "shows bundle-exec's man page when --help is after exec" do with_fake_man do bundle "#{exec} --help" end expect(out).to include(%(["#{root}/man/bundle-exec.1"])) end - it "shows bundle-exec's man page when -h is after exec", :ruby_repo do + it "shows bundle-exec's man page when -h is after exec" do with_fake_man do bundle "#{exec} -h" end @@ -342,20 +342,20 @@ RSpec.describe "bundle exec" do end describe "with gem executables" do - describe "run from a random directory" do + describe "run from a random directory", :ruby_repo do before(:each) do install_gemfile <<-G gem "rack" G end - it "works when unlocked", :ruby_repo do + it "works when unlocked" do bundle "exec 'cd #{tmp("gems")} && rackup'", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" } expect(out).to eq("1.0.0") expect(out).to include("1.0.0") end - it "works when locked", :ruby_repo do + it "works when locked" do expect(the_bundle).to be_locked bundle "exec 'cd #{tmp("gems")} && rackup'", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" } expect(out).to include("1.0.0") @@ -445,7 +445,7 @@ RSpec.describe "bundle exec" do expect(out).to include("Installing foo 1.0") end - describe "with gems bundled via :path with invalid gemspecs" do + describe "with gems bundled via :path with invalid gemspecs", :ruby_repo do it "outputs the gemspec validation errors", :rubygems => ">= 1.7.2" do build_lib "foo" @@ -785,7 +785,7 @@ __FILE__: #{path.to_s.inspect} end end - context "nested bundle exec", :ruby_repo do + context "nested bundle exec" do let(:system_gems_to_install) { super() << :bundler } context "with shared gems disabled" do diff --git a/spec/commands/help_spec.rb b/spec/commands/help_spec.rb index cd6f13756c..56b1b6f722 100644 --- a/spec/commands/help_spec.rb +++ b/spec/commands/help_spec.rb @@ -10,21 +10,21 @@ RSpec.describe "bundle help" do expect(err).to include("running `gem cleanup bundler`.") end - it "uses mann when available", :ruby_repo do + it "uses mann when available" do with_fake_man do bundle "help gemfile" end expect(out).to eq(%(["#{root}/man/gemfile.5"])) end - it "prefixes bundle commands with bundle- when finding the groff files", :ruby_repo do + it "prefixes bundle commands with bundle- when finding the groff files" do with_fake_man do bundle "help install" end expect(out).to eq(%(["#{root}/man/bundle-install.1"])) end - it "simply outputs the txt file when there is no man on the path", :ruby_repo do + it "simply outputs the txt file when there is no man on the path" do with_path_as("") do bundle "help install" end @@ -49,28 +49,28 @@ RSpec.describe "bundle help" do expect(out).to eq("--help") end - it "is called when the --help flag is used after the command", :ruby_repo do + it "is called when the --help flag is used after the command" do with_fake_man do bundle "install --help" end expect(out).to eq(%(["#{root}/man/bundle-install.1"])) end - it "is called when the --help flag is used before the command", :ruby_repo do + it "is called when the --help flag is used before the command" do with_fake_man do bundle "--help install" end expect(out).to eq(%(["#{root}/man/bundle-install.1"])) end - it "is called when the -h flag is used before the command", :ruby_repo do + it "is called when the -h flag is used before the command" do with_fake_man do bundle "-h install" end expect(out).to eq(%(["#{root}/man/bundle-install.1"])) end - it "is called when the -h flag is used after the command", :ruby_repo do + it "is called when the -h flag is used after the command" do with_fake_man do bundle "install -h" end @@ -84,7 +84,7 @@ RSpec.describe "bundle help" do expect(out).to include('Could not find command "instill".') end - it "is called when only using the --help flag", :ruby_repo do + it "is called when only using the --help flag" do with_fake_man do bundle "--help" end diff --git a/spec/commands/pristine_spec.rb b/spec/commands/pristine_spec.rb index da6bb1c093..76848c5e44 100644 --- a/spec/commands/pristine_spec.rb +++ b/spec/commands/pristine_spec.rb @@ -42,7 +42,7 @@ RSpec.describe "bundle pristine", :ruby_repo do expect(changes_txt).to_not be_file end - it "does not delete the bundler gem", :ruby_repo do + it "does not delete the bundler gem" do ENV["BUNDLER_SPEC_KEEP_DEFAULT_BUNDLER_GEM"] = "true" system_gems :bundler bundle! "install" diff --git a/spec/install/gemfile/platform_spec.rb b/spec/install/gemfile/platform_spec.rb index 6c226eb29f..c2d4321004 100644 --- a/spec/install/gemfile/platform_spec.rb +++ b/spec/install/gemfile/platform_spec.rb @@ -96,7 +96,7 @@ RSpec.describe "bundle install across platforms" do simulate_platform java install_gemfile! <<-G - source "file://localhost/#{gem_repo4}" + source "file://#{gem_repo4}" gem "empyrean", "0.1.0" gem "pry" @@ -104,7 +104,7 @@ RSpec.describe "bundle install across platforms" do expect(the_bundle.lockfile).to read_as strip_whitespace(<<-L) GEM - remote: file://localhost/#{gem_repo4}/ + remote: file://#{gem_repo4}/ specs: coderay (1.1.2) empyrean (0.1.0) @@ -132,7 +132,7 @@ RSpec.describe "bundle install across platforms" do good_lockfile = strip_whitespace(<<-L) GEM - remote: file://localhost/#{gem_repo4}/ + remote: file://#{gem_repo4}/ specs: coderay (1.1.2) empyrean (0.1.0) @@ -164,7 +164,7 @@ RSpec.describe "bundle install across platforms" do bad_lockfile = strip_whitespace <<-L GEM - remote: file://localhost/#{gem_repo4}/ + remote: file://#{gem_repo4}/ specs: coderay (1.1.2) empyrean (0.1.0) diff --git a/spec/install/gems/compact_index_spec.rb b/spec/install/gems/compact_index_spec.rb index b06b72ecfa..02a37a77d5 100644 --- a/spec/install/gems/compact_index_spec.rb +++ b/spec/install/gems/compact_index_spec.rb @@ -717,7 +717,7 @@ The checksum of /versions does not match the checksum provided by the server! So end end - context "when ruby is compiled without openssl", :ruby_repo do + context "when ruby is compiled without openssl" do before do # Install a monkeypatch that reproduces the effects of openssl being # missing when the fetcher runs, as happens in real life. The reason diff --git a/spec/install/gems/dependency_api_spec.rb b/spec/install/gems/dependency_api_spec.rb index fe696f38c3..2ffe4b62d7 100644 --- a/spec/install/gems/dependency_api_spec.rb +++ b/spec/install/gems/dependency_api_spec.rb @@ -691,7 +691,7 @@ RSpec.describe "gemcutter's dependency API" do end end - context "when ruby is compiled without openssl", :ruby_repo do + context "when ruby is compiled without openssl" do before do # Install a monkeypatch that reproduces the effects of openssl being # missing when the fetcher runs, as happens in real life. The reason diff --git a/spec/lock/lockfile_bundler_1_spec.rb b/spec/lock/lockfile_bundler_1_spec.rb index a8615d4c89..fcdf6ebf0d 100644 --- a/spec/lock/lockfile_bundler_1_spec.rb +++ b/spec/lock/lockfile_bundler_1_spec.rb @@ -75,7 +75,7 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do G end - it "does not update the lockfile's bundler version if nothing changed during bundle install" do + it "does not update the lockfile's bundler version if nothing changed during bundle install", :ruby_repo do version = "#{Bundler::VERSION.split(".").first}.0.0.0.a" lockfile <<-L diff --git a/spec/other/bundle_ruby_spec.rb b/spec/other/bundle_ruby_spec.rb index 8e365a489c..a7da9cbec9 100644 --- a/spec/other/bundle_ruby_spec.rb +++ b/spec/other/bundle_ruby_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe "bundle_ruby", :ruby_repo, :bundler => "< 2" do +RSpec.describe "bundle_ruby", :bundler => "< 2" do context "without patchlevel" do it "returns the ruby version" do gemfile <<-G diff --git a/spec/quality_spec.rb b/spec/quality_spec.rb index 84da4aaeb9..e85d0bfa97 100644 --- a/spec/quality_spec.rb +++ b/spec/quality_spec.rb @@ -104,11 +104,12 @@ RSpec.describe "The library itself" do end end - it "has no malformed whitespace", :ruby_repo do + it "has no malformed whitespace" do exempt = /\.gitmodules|\.marshal|fixtures|vendor|ssl_certs|LICENSE|vcr_cassettes/ error_messages = [] Dir.chdir(root) do - `git ls-files -z`.split("\x0").each do |filename| + lib_files = ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb spec/bundler` : `git ls-files -z -- lib` + lib_files.split("\x0").each do |filename| next if filename =~ exempt error_messages << check_for_tab_characters(filename) error_messages << check_for_extra_spaces(filename) @@ -117,11 +118,12 @@ RSpec.describe "The library itself" do expect(error_messages.compact).to be_well_formed end - it "does not include any leftover debugging or development mechanisms", :ruby_repo do + it "does not include any leftover debugging or development mechanisms" do exempt = %r{quality_spec.rb|support/helpers|vcr_cassettes|\.md|\.ronn} error_messages = [] Dir.chdir(root) do - `git ls-files -z`.split("\x0").each do |filename| + lib_files = ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb spec/bundler` : `git ls-files -z -- lib` + lib_files.split("\x0").each do |filename| next if filename =~ exempt error_messages << check_for_debugging_mechanisms(filename) end @@ -129,11 +131,12 @@ RSpec.describe "The library itself" do expect(error_messages.compact).to be_well_formed end - it "does not include any unresolved merge conflicts", :ruby_repo do + it "does not include any unresolved merge conflicts" do error_messages = [] exempt = %r{lock/lockfile_(bundler_1_)?spec|quality_spec|vcr_cassettes|\.ronn|lockfile_parser\.rb} Dir.chdir(root) do - `git ls-files -z`.split("\x0").each do |filename| + lib_files = ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb spec/bundler` : `git ls-files -z -- lib` + lib_files.split("\x0").each do |filename| next if filename =~ exempt error_messages << check_for_git_merge_conflicts(filename) end @@ -141,7 +144,7 @@ RSpec.describe "The library itself" do expect(error_messages.compact).to be_well_formed end - it "maintains language quality of the documentation", :ruby_repo do + it "maintains language quality of the documentation" do included = /ronn/ error_messages = [] Dir.chdir(root) do @@ -154,11 +157,12 @@ RSpec.describe "The library itself" do expect(error_messages.compact).to be_well_formed end - it "maintains language quality of sentences used in source code", :ruby_repo do + it "maintains language quality of sentences used in source code" do error_messages = [] exempt = /vendor/ Dir.chdir(root) do - `git ls-files -z -- lib`.split("\x0").each do |filename| + lib_files = ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb` : `git ls-files -z -- lib` + lib_files.split("\x0").each do |filename| next if filename =~ exempt error_messages << check_for_expendable_words(filename) error_messages << check_for_specific_pronouns(filename) @@ -167,7 +171,7 @@ RSpec.describe "The library itself" do expect(error_messages.compact).to be_well_formed end - it "documents all used settings", :ruby_repo do + it "documents all used settings" do exemptions = %w[ auto_config_jobs cache_command_is_package @@ -191,7 +195,8 @@ RSpec.describe "The library itself" do Dir.chdir(root) do key_pattern = /([a-z\._-]+)/i - `git ls-files -z -- lib`.split("\x0").each do |filename| + lib_files = ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb` : `git ls-files -z -- lib` + lib_files.split("\x0").each do |filename| File.readlines(filename).each_with_index do |line, number| line.scan(/Bundler\.settings\[:#{key_pattern}\]/).flatten.each {|s| all_settings[s] << "referenced at `#{filename}:#{number.succ}`" } end @@ -216,10 +221,10 @@ RSpec.describe "The library itself" do expect(documented_settings).to be_sorted end - it "can still be built", :ruby_repo do + it "can still be built" do Dir.chdir(root) do begin - gem_command! :build, "bundler.gemspec" + gem_command! :build, gemspec if Bundler.rubygems.provides?(">= 2.4") # there's no way around this warning last_command.stderr.sub!(/^YAML safe loading.*/, "") @@ -230,12 +235,13 @@ RSpec.describe "The library itself" do end ensure # clean up the .gem generated - FileUtils.rm("bundler-#{Bundler::VERSION}.gem") + path_prefix = ruby_core? ? "lib/" : "./" + FileUtils.rm("#{path_prefix}bundler-#{Bundler::VERSION}.gem") end end end - it "does not contain any warnings", :ruby_repo do + it "does not contain any warnings" do Dir.chdir(root) do exclusions = %w[ lib/bundler/capistrano.rb @@ -244,7 +250,8 @@ RSpec.describe "The library itself" do lib/bundler/vlad.rb lib/bundler/templates/gems.rb ] - lib_files = `git ls-files -z -- lib`.split("\x0").grep(/\.rb$/) - exclusions + lib_files = ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb` : `git ls-files -z -- lib` + lib_files = lib_files.split("\x0").grep(/\.rb$/) - exclusions lib_files.reject! {|f| f.start_with?("lib/bundler/vendor") } lib_files.map! {|f| f.chomp(".rb") } sys_exec!("ruby -w -Ilib") do |input, _, _| diff --git a/spec/runtime/gem_tasks_spec.rb b/spec/runtime/gem_tasks_spec.rb index 1cf808f35b..de72869dc3 100644 --- a/spec/runtime/gem_tasks_spec.rb +++ b/spec/runtime/gem_tasks_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe "require 'bundler/gem_tasks'" do +RSpec.describe "require 'bundler/gem_tasks'", :ruby_repo do before :each do bundled_app("foo.gemspec").open("w") do |f| f.write <<-GEMSPEC diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index 376053a625..abe9979109 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -144,7 +144,7 @@ RSpec.describe "Bundler.setup" do expect(rack_load_order).to be > 0 end - it "orders the load path correctly when there are dependencies", :ruby_repo do + it "orders the load path correctly when there are dependencies" do install_gemfile <<-G source "file://#{gem_repo1}" gem "rails" @@ -860,7 +860,7 @@ end context "with bundler is located in symlinked GEM_HOME" do let(:gem_home) { Dir.mktmpdir } let(:symlinked_gem_home) { Tempfile.new("gem_home").path } - let(:bundler_dir) { File.expand_path("../../..", __FILE__) } + let(:bundler_dir) { ruby_core? ? File.expand_path("../../../..", __FILE__) : File.expand_path("../../..", __FILE__) } let(:bundler_lib) { File.join(bundler_dir, "lib") } before do @@ -872,7 +872,8 @@ end FileUtils.ln_s(bundler_dir, File.join(gems_dir, "bundler-#{Bundler::VERSION}")) - gemspec = File.read("#{bundler_dir}/bundler.gemspec"). + gemspec_file = ruby_core? ? "#{bundler_dir}/lib/bundler.gemspec" : "#{bundler_dir}/bundler.gemspec" + gemspec = File.read(gemmspec_file). sub("Bundler::VERSION", %("#{Bundler::VERSION}")) gemspec = gemspec.lines.reject {|line| line =~ %r{lib/bundler/version} }.join @@ -881,7 +882,7 @@ end end end - it "should successfully require 'bundler/setup'" do + it "should successfully require 'bundler/setup'", :ruby_repo do install_gemfile "" ruby <<-'R', :env => { "GEM_PATH" => symlinked_gem_home }, :no_lib => true @@ -1265,7 +1266,7 @@ end expect(out).to eq("undefined\nconstant") end - describe "default gem activation", :ruby_repo do + describe "default gem activation" do let(:exemptions) do if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("2.7") || ENV["RGV"] == "master" [] diff --git a/spec/runtime/with_clean_env_spec.rb b/spec/runtime/with_clean_env_spec.rb index c88da3cd02..321f5b6415 100644 --- a/spec/runtime/with_clean_env_spec.rb +++ b/spec/runtime/with_clean_env_spec.rb @@ -16,7 +16,7 @@ RSpec.describe "Bundler.with_env helpers" do bundle "install" end - it "should return the PATH present before bundle was activated", :ruby_repo do + it "should return the PATH present before bundle was activated" do code = "print Bundler.original_env['PATH']" path = `getconf PATH`.strip + "#{File::PATH_SEPARATOR}/foo" with_path_as(path) do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 711bf576a9..7a229dc28e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -99,7 +99,7 @@ RSpec.configure do |config| config.filter_run_excluding :git => LessThanProc.with(git_version) config.filter_run_excluding :rubygems_master => (ENV["RGV"] != "master") config.filter_run_excluding :bundler => LessThanProc.with(Bundler::VERSION.split(".")[0, 2].join(".")) - config.filter_run_excluding :ruby_repo => (ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]) + config.filter_run_excluding :ruby_repo => !!(ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]) config.filter_run_when_matching :focus unless ENV["CI"] diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index e3b57c1a31..b027e7a922 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -314,7 +314,11 @@ module Spec gems.each do |g| path = if g == :bundler Dir.chdir(root) { gem_command! :build, gemspec.to_s } - bundler_path = root + "bundler-#{Bundler::VERSION}.gem" + bundler_path = if ruby_core? + root + "lib/bundler-#{Bundler::VERSION}.gem" + else + root + "bundler-#{Bundler::VERSION}.gem" + end elsif g.to_s =~ %r{\A/.*\.gem\z} g else diff --git a/spec/support/path.rb b/spec/support/path.rb index 1a3444f365..cecab45c9b 100644 --- a/spec/support/path.rb +++ b/spec/support/path.rb @@ -5,19 +5,19 @@ require "pathname" module Spec module Path def root - @root ||= Pathname.new(for_ruby_core? ? "../../../.." : "../../..").expand_path(__FILE__) + @root ||= Pathname.new(ruby_core? ? "../../../.." : "../../..").expand_path(__FILE__) end def gemspec - @gemspec ||= root.join(for_ruby_core? ? "lib/bundler.gemspec" : "bundler.gemspec") + @gemspec ||= root.join(ruby_core? ? "lib/bundler.gemspec" : "bundler.gemspec") end def bindir - @bindir ||= root.join(for_ruby_core? ? "bin" : "exe") + @bindir ||= root.join(ruby_core? ? "bin" : "exe") end def spec_dir - @spec_dir ||= root.join(for_ruby_core? ? "spec/bundler" : "spec") + @spec_dir ||= root.join(ruby_core? ? "spec/bundler" : "spec") end def tmp(*path) @@ -110,19 +110,17 @@ module Spec tmp "tmpdir", *args end - extend self - - private - - def for_ruby_core? + def ruby_core? # avoid to wornings - @for_ruby_core ||= nil + @ruby_core ||= nil - if @for_ruby_core.nil? - @for_ruby_core = true & (ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]) + if @ruby_core.nil? + @ruby_core = true & (ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]) else - @for_ruby_core + @ruby_core end end + + extend self end end -- cgit v1.2.1 From 35c189b81ed8fc684f1394008564f4b6871f2c18 Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Thu, 1 Nov 2018 22:05:16 +0900 Subject: Fixed typo --- spec/runtime/setup_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index abe9979109..7ea7d5ea0b 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -873,7 +873,7 @@ end FileUtils.ln_s(bundler_dir, File.join(gems_dir, "bundler-#{Bundler::VERSION}")) gemspec_file = ruby_core? ? "#{bundler_dir}/lib/bundler.gemspec" : "#{bundler_dir}/bundler.gemspec" - gemspec = File.read(gemmspec_file). + gemspec = File.read(gemspec_file). sub("Bundler::VERSION", %("#{Bundler::VERSION}")) gemspec = gemspec.lines.reject {|line| line =~ %r{lib/bundler/version} }.join -- cgit v1.2.1 From 55d13286ae75f5b20b16c2853d9af66d884c019e Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Thu, 1 Nov 2018 22:09:09 +0900 Subject: rubocop -a --- spec/spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7a229dc28e..ede0bdc1d0 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -99,7 +99,7 @@ RSpec.configure do |config| config.filter_run_excluding :git => LessThanProc.with(git_version) config.filter_run_excluding :rubygems_master => (ENV["RGV"] != "master") config.filter_run_excluding :bundler => LessThanProc.with(Bundler::VERSION.split(".")[0, 2].join(".")) - config.filter_run_excluding :ruby_repo => !!(ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]) + config.filter_run_excluding :ruby_repo => !(ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]).nil? config.filter_run_when_matching :focus unless ENV["CI"] -- cgit v1.2.1 From 886de38f9ea049dd3ad1f946bb66023694488ff0 Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Thu, 1 Nov 2018 22:16:03 +0900 Subject: To use helper method instead of env variables. --- spec/commands/newgem_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/commands/newgem_spec.rb b/spec/commands/newgem_spec.rb index cfea63ece5..e6d6e19122 100644 --- a/spec/commands/newgem_spec.rb +++ b/spec/commands/newgem_spec.rb @@ -213,7 +213,7 @@ RSpec.describe "bundle gem" do Dir.chdir(bundled_app("newgem")) do gems = ["rake-10.0.2", :bundler] # for Ruby core repository, Ruby 2.6+ has bundler as standard library. - gems.delete(:bundler) if ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"] + gems.delete(:bundler) if ruby_core? system_gems gems, :path => :bundle_path bundle! "exec rake build" end -- cgit v1.2.1 From 8ff21c96c374281caf03035d8765df9f779e1294 Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Fri, 2 Nov 2018 06:44:54 +0900 Subject: Partly reverted 09bfdfa31ad5ae34d29745344493f6a63d355804. --- spec/install/gemfile/platform_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/install/gemfile/platform_spec.rb b/spec/install/gemfile/platform_spec.rb index c2d4321004..6c226eb29f 100644 --- a/spec/install/gemfile/platform_spec.rb +++ b/spec/install/gemfile/platform_spec.rb @@ -96,7 +96,7 @@ RSpec.describe "bundle install across platforms" do simulate_platform java install_gemfile! <<-G - source "file://#{gem_repo4}" + source "file://localhost/#{gem_repo4}" gem "empyrean", "0.1.0" gem "pry" @@ -104,7 +104,7 @@ RSpec.describe "bundle install across platforms" do expect(the_bundle.lockfile).to read_as strip_whitespace(<<-L) GEM - remote: file://#{gem_repo4}/ + remote: file://localhost/#{gem_repo4}/ specs: coderay (1.1.2) empyrean (0.1.0) @@ -132,7 +132,7 @@ RSpec.describe "bundle install across platforms" do good_lockfile = strip_whitespace(<<-L) GEM - remote: file://#{gem_repo4}/ + remote: file://localhost/#{gem_repo4}/ specs: coderay (1.1.2) empyrean (0.1.0) @@ -164,7 +164,7 @@ RSpec.describe "bundle install across platforms" do bad_lockfile = strip_whitespace <<-L GEM - remote: file://#{gem_repo4}/ + remote: file://localhost/#{gem_repo4}/ specs: coderay (1.1.2) empyrean (0.1.0) -- cgit v1.2.1 From abb17aa367f666ff78e3cf51008ba2ec4144f21a Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Fri, 2 Nov 2018 06:57:21 +0900 Subject: Support old versions of Ruby on platform_spec.rb --- spec/install/gemfile/platform_spec.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/install/gemfile/platform_spec.rb b/spec/install/gemfile/platform_spec.rb index 6c226eb29f..bfdf9b68c8 100644 --- a/spec/install/gemfile/platform_spec.rb +++ b/spec/install/gemfile/platform_spec.rb @@ -102,7 +102,7 @@ RSpec.describe "bundle install across platforms" do gem "pry" G - expect(the_bundle.lockfile).to read_as strip_whitespace(<<-L) + expect(the_bundle.lockfile).to read_as normalize_uri_file(strip_whitespace(<<-L)) GEM remote: file://localhost/#{gem_repo4}/ specs: @@ -160,7 +160,7 @@ RSpec.describe "bundle install across platforms" do #{Bundler::VERSION} L - expect(the_bundle.lockfile).to read_as good_lockfile + expect(the_bundle.lockfile).to read_as normalize_uri_file(good_lockfile) bad_lockfile = strip_whitespace <<-L GEM @@ -196,23 +196,23 @@ RSpec.describe "bundle install across platforms" do aggregate_failures do lockfile bad_lockfile bundle! :install - expect(the_bundle.lockfile).to read_as good_lockfile + expect(the_bundle.lockfile).to read_as normalize_uri_file(good_lockfile) lockfile bad_lockfile bundle! :update, :all => true - expect(the_bundle.lockfile).to read_as good_lockfile + expect(the_bundle.lockfile).to read_as normalize_uri_file(good_lockfile) lockfile bad_lockfile bundle! "update ffi" - expect(the_bundle.lockfile).to read_as good_lockfile + expect(the_bundle.lockfile).to read_as normalize_uri_file(good_lockfile) lockfile bad_lockfile bundle! "update empyrean" - expect(the_bundle.lockfile).to read_as good_lockfile + expect(the_bundle.lockfile).to read_as normalize_uri_file(good_lockfile) lockfile bad_lockfile bundle! :lock - expect(the_bundle.lockfile).to read_as good_lockfile + expect(the_bundle.lockfile).to read_as normalize_uri_file(good_lockfile) end end -- cgit v1.2.1 From 359b6920c45fa05b92259ca284de16c65ed71ac1 Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Tue, 6 Nov 2018 20:29:55 +0000 Subject: To use File.file? instead of handling LoadError. --- bundler.gemspec | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bundler.gemspec b/bundler.gemspec index c004de0965..bffcbd4ec2 100644 --- a/bundler.gemspec +++ b/bundler.gemspec @@ -1,9 +1,10 @@ # coding: utf-8 # frozen_string_literal: true -begin - require File.expand_path("../lib/bundler/version", __FILE__) -rescue LoadError +version = File.expand_path("../lib/bundler/version", __FILE__) +if File.file?(version) + require version +else # for Ruby core repository require File.expand_path("../bundler/version", __FILE__) end -- cgit v1.2.1 From 8b1245ca967df4107d0f75ea20316d86fb63bed1 Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Tue, 6 Nov 2018 20:31:05 +0000 Subject: To use helper method instead of env variables. --- spec/bundler/ssl_certs/certificate_manager_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/bundler/ssl_certs/certificate_manager_spec.rb b/spec/bundler/ssl_certs/certificate_manager_spec.rb index 4250bfc497..56606a830f 100644 --- a/spec/bundler/ssl_certs/certificate_manager_spec.rb +++ b/spec/bundler/ssl_certs/certificate_manager_spec.rb @@ -12,7 +12,7 @@ RSpec.describe Bundler::SSLCerts::CertificateManager do # Pretend bundler root is rubygems root before do # Backing up rubygems ceriticates - FileUtils.mv(rubygems_certs_dir, rubygems_certs_dir + ".back") if ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"] + FileUtils.mv(rubygems_certs_dir, rubygems_certs_dir + ".back") if ruby_core? FileUtils.mkdir_p(rubygems_certs_dir) FileUtils.touch(stub_cert) @@ -22,7 +22,7 @@ RSpec.describe Bundler::SSLCerts::CertificateManager do FileUtils.rm_rf(rubygems_certs_dir) # Restore rubygems certificates - FileUtils.mv(rubygems_certs_dir + ".back", rubygems_certs_dir) if ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"] + FileUtils.mv(rubygems_certs_dir + ".back", rubygems_certs_dir) if ruby_core? end describe "#update_from" do -- cgit v1.2.1 From 35031a16b90e8883582319f78d396d7ba215c43d Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Tue, 6 Nov 2018 20:41:49 +0000 Subject: To use around hook instead of before suite. --- spec/spec_helper.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ede0bdc1d0..3bb08c75a8 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -114,11 +114,13 @@ RSpec.configure do |config| mocks.allow_message_expectations_on_nil = false end - config.before :suite do + config.around :suite do |example| if ENV["BUNDLE_RUBY"] @orig_ruby = Gem.ruby Gem.ruby = ENV["BUNDLE_RUBY"] end + example.run + Gem.ruby = @orig_ruby if ENV["BUNDLE_RUBY"] end config.before :all do @@ -146,7 +148,4 @@ RSpec.configure do |config| ENV.replace(original_env) end - config.after :suite do - Gem.ruby = @orig_ruby if ENV["BUNDLE_RUBY"] - end end -- cgit v1.2.1 From 490591030356b835f1cbd1815ff7acff6c9fe394 Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Wed, 7 Nov 2018 12:33:20 +0000 Subject: Added extname --- bundler.gemspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bundler.gemspec b/bundler.gemspec index bffcbd4ec2..b642ce272f 100644 --- a/bundler.gemspec +++ b/bundler.gemspec @@ -1,12 +1,12 @@ # coding: utf-8 # frozen_string_literal: true -version = File.expand_path("../lib/bundler/version", __FILE__) +version = File.expand_path("../lib/bundler/version.rb", __FILE__) if File.file?(version) require version else # for Ruby core repository - require File.expand_path("../bundler/version", __FILE__) + require File.expand_path("../bundler/version.rb", __FILE__) end require "shellwords" -- cgit v1.2.1 From 3df26b93b0afdce0d2b34596bc2de21649b174d0 Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Wed, 7 Nov 2018 14:53:23 +0000 Subject: expand version path for rspec examples. --- bundler.gemspec | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bundler.gemspec b/bundler.gemspec index b642ce272f..b7123077d9 100644 --- a/bundler.gemspec +++ b/bundler.gemspec @@ -1,9 +1,8 @@ # coding: utf-8 # frozen_string_literal: true -version = File.expand_path("../lib/bundler/version.rb", __FILE__) -if File.file?(version) - require version +if File.file?(File.expand_path("../lib/bundler/version.rb", __FILE__)) + require File.expand_path("../lib/bundler/version.rb", __FILE__) else # for Ruby core repository require File.expand_path("../bundler/version.rb", __FILE__) -- cgit v1.2.1 From 79307d4aba2beb04045d3c84722f0f0498339d25 Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Wed, 7 Nov 2018 15:27:02 +0000 Subject: rubocop -a --- spec/spec_helper.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 3bb08c75a8..f79c4e683a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -147,5 +147,4 @@ RSpec.configure do |config| Dir.chdir(original_wd) ENV.replace(original_env) end - end -- cgit v1.2.1 From 2aa84b2372371c4895cab4e096b48a34f88c451a Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Wed, 7 Nov 2018 16:10:15 +0000 Subject: Revert File.file? conditioon on gemspec, Because it break spec/runtime/setup_spec.rb:896 --- bundler.gemspec | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bundler.gemspec b/bundler.gemspec index b7123077d9..c004de0965 100644 --- a/bundler.gemspec +++ b/bundler.gemspec @@ -1,11 +1,11 @@ # coding: utf-8 # frozen_string_literal: true -if File.file?(File.expand_path("../lib/bundler/version.rb", __FILE__)) - require File.expand_path("../lib/bundler/version.rb", __FILE__) -else +begin + require File.expand_path("../lib/bundler/version", __FILE__) +rescue LoadError # for Ruby core repository - require File.expand_path("../bundler/version.rb", __FILE__) + require File.expand_path("../bundler/version", __FILE__) end require "shellwords" -- cgit v1.2.1