diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2022-02-28 10:32:28 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2022-02-28 11:39:20 +0900 |
commit | ff3d7b720ec21e4856aac0b3c493bc78cbac83d4 (patch) | |
tree | 5954bdfc783adb6060337b0f7dbb1589984e6291 /spec/bundler | |
parent | 02ead4a82eff7dd48153d6457929fe48f50e28df (diff) | |
download | ruby-ff3d7b720ec21e4856aac0b3c493bc78cbac83d4.tar.gz |
Merge RubyGems and Bundler master
Diffstat (limited to 'spec/bundler')
-rw-r--r-- | spec/bundler/bundler/fetcher_spec.rb | 4 | ||||
-rw-r--r-- | spec/bundler/bundler/rubygems_integration_spec.rb | 11 | ||||
-rw-r--r-- | spec/bundler/commands/config_spec.rb | 14 | ||||
-rw-r--r-- | spec/bundler/commands/exec_spec.rb | 6 | ||||
-rw-r--r-- | spec/bundler/commands/inject_spec.rb | 2 | ||||
-rw-r--r-- | spec/bundler/commands/lock_spec.rb | 4 | ||||
-rw-r--r-- | spec/bundler/install/gemfile/groups_spec.rb | 13 | ||||
-rw-r--r-- | spec/bundler/install/gems/standalone_spec.rb | 3 | ||||
-rw-r--r-- | spec/bundler/realworld/parallel_spec.rb | 2 | ||||
-rw-r--r-- | spec/bundler/spec_helper.rb | 2 | ||||
-rw-r--r-- | spec/bundler/support/helpers.rb | 27 |
11 files changed, 43 insertions, 45 deletions
diff --git a/spec/bundler/bundler/fetcher_spec.rb b/spec/bundler/bundler/fetcher_spec.rb index 256d342775..a104760075 100644 --- a/spec/bundler/bundler/fetcher_spec.rb +++ b/spec/bundler/bundler/fetcher_spec.rb @@ -26,7 +26,7 @@ RSpec.describe Bundler::Fetcher do context "when Gem.configuration specifies http_proxy " do let(:proxy) { "http://proxy-example2.com" } before do - allow(Bundler.rubygems.configuration).to receive(:[]).with(:http_proxy).and_return(proxy) + allow(Gem.configuration).to receive(:[]).with(:http_proxy).and_return(proxy) end it "consider Gem.configuration when determine proxy" do expect(fetcher.http_proxy).to match("http://proxy-example2.com") @@ -113,7 +113,7 @@ RSpec.describe Bundler::Fetcher do context "when gem ssl configuration is set" do before do - allow(Bundler.rubygems.configuration).to receive_messages( + allow(Gem.configuration).to receive_messages( :http_proxy => nil, :ssl_client_cert => "cert", :ssl_ca_cert => "ca" diff --git a/spec/bundler/bundler/rubygems_integration_spec.rb b/spec/bundler/bundler/rubygems_integration_spec.rb index 94abf70ddd..369f28fcef 100644 --- a/spec/bundler/bundler/rubygems_integration_spec.rb +++ b/spec/bundler/bundler/rubygems_integration_spec.rb @@ -34,13 +34,6 @@ RSpec.describe Bundler::RubygemsIntegration do end end - describe "#configuration" do - it "handles Gem::SystemExitException errors" do - allow(Gem).to receive(:configuration) { raise Gem::SystemExitException.new(1) } - expect { Bundler.rubygems.configuration }.to raise_error(Gem::SystemExitException) - end - end - describe "#download_gem" do let(:bundler_retry) { double(Bundler::Retry) } let(:uri) { Bundler::URI.parse("https://foo.bar") } @@ -54,7 +47,7 @@ RSpec.describe Bundler::RubygemsIntegration do it "successfully downloads gem with retries" do expect(Bundler.rubygems).to receive(:gem_remote_fetcher).and_return(fetcher) - expect(fetcher).to receive(:headers=).with("X-Gemfile-Source" => "https://foo.bar") + expect(fetcher).to receive(:headers=).with({ "X-Gemfile-Source" => "https://foo.bar" }) expect(Bundler::Retry).to receive(:new).with("download gem from #{uri}/"). and_return(bundler_retry) expect(bundler_retry).to receive(:attempts).and_yield @@ -76,7 +69,7 @@ RSpec.describe Bundler::RubygemsIntegration do it "sets the 'X-Gemfile-Source' header containing the original source" do expect(Bundler.rubygems).to receive(:gem_remote_fetcher).twice.and_return(fetcher) - expect(fetcher).to receive(:headers=).with("X-Gemfile-Source" => "http://zombo.com").twice + expect(fetcher).to receive(:headers=).with({ "X-Gemfile-Source" => "http://zombo.com" }).twice expect(fetcher).to receive(:fetch_path).with(uri + "specs.4.8.gz").and_return(specs_response) expect(fetcher).to receive(:fetch_path).with(uri + "prerelease_specs.4.8.gz").and_return(prerelease_specs_response) result = Bundler.rubygems.fetch_all_remote_specs(remote_with_mirror) diff --git a/spec/bundler/commands/config_spec.rb b/spec/bundler/commands/config_spec.rb index 9664fe6517..fb7aa3cc67 100644 --- a/spec/bundler/commands/config_spec.rb +++ b/spec/bundler/commands/config_spec.rb @@ -43,6 +43,12 @@ RSpec.describe ".bundle/config" do G end + it "is local by default" do + bundle "config set foo bar" + expect(bundled_app(".bundle/config")).to exist + expect(home(".bundle/config")).not_to exist + end + it "can be moved with an environment variable" do ENV["BUNDLE_APP_CONFIG"] = tmp("foo/bar").to_s bundle "config set --local path vendor/bundle" @@ -67,6 +73,12 @@ RSpec.describe ".bundle/config" do end describe "location without a gemfile" do + it "is global by default" do + bundle "config set foo bar" + expect(bundled_app(".bundle/config")).not_to exist + expect(home(".bundle/config")).to exist + end + it "works with an absolute path" do ENV["BUNDLE_APP_CONFIG"] = tmp("foo/bar").to_s bundle "config set --local path vendor/bundle" @@ -359,7 +371,7 @@ E it "doesn't return quotes around values" do bundle "config set foo '1'" - run "puts Bundler.settings.send(:global_config_file).read" + run "puts Bundler.settings.send(:local_config_file).read" expect(out).to include('"1"') run "puts Bundler.settings[:foo]" expect(out).to eq("1") diff --git a/spec/bundler/commands/exec_spec.rb b/spec/bundler/commands/exec_spec.rb index f2b7863591..c6947afeae 100644 --- a/spec/bundler/commands/exec_spec.rb +++ b/spec/bundler/commands/exec_spec.rb @@ -291,7 +291,7 @@ RSpec.describe "bundle exec" do end end - bundle "config set path.system true" + bundle "config set --global path.system true" install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" @@ -775,9 +775,7 @@ RSpec.describe "bundle exec" do end let(:expected_err) { "" } let(:exit_code) do - # signal mask 128 + plus signal 15 -> TERM - # this is specified by C99 - 128 + 15 + exit_status_for_signal(Signal.list["TERM"]) end it "runs" do diff --git a/spec/bundler/commands/inject_spec.rb b/spec/bundler/commands/inject_spec.rb index 2d97bf6ff0..92e86bd6cc 100644 --- a/spec/bundler/commands/inject_spec.rb +++ b/spec/bundler/commands/inject_spec.rb @@ -99,7 +99,7 @@ Usage: "bundle inject GEM VERSION" it "restores frozen afterwards" do bundle "inject 'rack-obama' '> 0'" - config = YAML.load(bundled_app(".bundle/config").read) + config = Psych.load(bundled_app(".bundle/config").read) expect(config["BUNDLE_DEPLOYMENT"] || config["BUNDLE_FROZEN"]).to eq("true") end diff --git a/spec/bundler/commands/lock_spec.rb b/spec/bundler/commands/lock_spec.rb index 131b46de0d..ee1c3ffd46 100644 --- a/spec/bundler/commands/lock_spec.rb +++ b/spec/bundler/commands/lock_spec.rb @@ -157,9 +157,9 @@ RSpec.describe "bundle lock" do gem "rack_middleware", :group => "test" G bundle "config set without test" - bundle "config set path .bundle" + bundle "config set path vendor/bundle" bundle "lock" - expect(bundled_app(".bundle")).not_to exist + expect(bundled_app("vendor/bundle")).not_to exist end # see update_spec for more coverage on same options. logic is shared so it's not necessary diff --git a/spec/bundler/install/gemfile/groups_spec.rb b/spec/bundler/install/gemfile/groups_spec.rb index c92b5dcc57..734e012e84 100644 --- a/spec/bundler/install/gemfile/groups_spec.rb +++ b/spec/bundler/install/gemfile/groups_spec.rb @@ -91,17 +91,8 @@ RSpec.describe "bundle install with groups" do expect(the_bundle).to include_gems "rack 1.0.0", :groups => [:default] end - it "respects global `without` configuration, and saves it locally", :bundler => "< 3" do - bundle "config set without emo" - bundle :install - expect(the_bundle).to include_gems "rack 1.0.0", :groups => [:default] - bundle "config list" - expect(out).to include("Set for your local app (#{bundled_app(".bundle/config")}): [:emo]") - expect(out).to include("Set for the current user (#{home(".bundle/config")}): [:emo]") - end - - it "respects global `without` configuration, but does not save it locally", :bundler => "3" do - bundle "config set without emo" + it "respects global `without` configuration, but does not save it locally" do + bundle "config set --global without emo" bundle :install expect(the_bundle).to include_gems "rack 1.0.0", :groups => [:default] bundle "config list" diff --git a/spec/bundler/install/gems/standalone_spec.rb b/spec/bundler/install/gems/standalone_spec.rb index 0c77e883df..c7efc836a8 100644 --- a/spec/bundler/install/gems/standalone_spec.rb +++ b/spec/bundler/install/gems/standalone_spec.rb @@ -120,8 +120,9 @@ RSpec.shared_examples "bundle install --standalone" do realworld_system_gems "tsort --version 0.1.0" - necessary_system_gems = ["optparse --version 0.1.1", "psych --version 3.3.2", "yaml --version 0.1.1", "logger --version 1.4.3", "etc --version 1.2.0", "stringio --version 3.0.0"] + necessary_system_gems = ["optparse --version 0.1.1", "psych --version 3.3.2", "logger --version 1.4.3", "etc --version 1.2.0", "stringio --version 3.0.0"] necessary_system_gems += ["shellwords --version 0.1.0", "base64 --version 0.1.0", "resolv --version 0.2.1"] if Gem.rubygems_version < Gem::Version.new("3.3.a") + necessary_system_gems += ["yaml --version 0.1.1"] if Gem.rubygems_version < Gem::Version.new("3.4.a") realworld_system_gems(*necessary_system_gems, :path => scoped_gem_path(bundled_app("bundle"))) build_gem "foo", "1.0.0", :to_system => true, :default => true do |s| diff --git a/spec/bundler/realworld/parallel_spec.rb b/spec/bundler/realworld/parallel_spec.rb index 97c0e0cab4..a1e4f83909 100644 --- a/spec/bundler/realworld/parallel_spec.rb +++ b/spec/bundler/realworld/parallel_spec.rb @@ -46,7 +46,7 @@ RSpec.describe "parallel", :realworld => true do end it "works with --standalone" do - gemfile <<-G, :standalone => true + gemfile <<-G source "https://rubygems.org" gem "diff-lcs" G diff --git a/spec/bundler/spec_helper.rb b/spec/bundler/spec_helper.rb index 2988cab9c5..dce2939e83 100644 --- a/spec/bundler/spec_helper.rb +++ b/spec/bundler/spec_helper.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "bundler/psyched_yaml" +require "psych" require "bundler/vendored_fileutils" require "bundler/vendored_uri" require "digest" diff --git a/spec/bundler/support/helpers.rb b/spec/bundler/support/helpers.rb index c27096a0cf..d7556102b4 100644 --- a/spec/bundler/support/helpers.rb +++ b/spec/bundler/support/helpers.rb @@ -199,7 +199,7 @@ module Spec command_execution.exitstatus = if status.exited? status.exitstatus elsif status.signaled? - 128 + status.termsig + exit_status_for_signal(status.termsig) end end @@ -225,7 +225,7 @@ module Spec end def config(config = nil, path = bundled_app(".bundle/config")) - return YAML.load_file(path) unless config + return Psych.load_file(path) unless config FileUtils.mkdir_p(File.dirname(path)) File.open(path, "w") do |f| f.puts config.to_yaml @@ -237,33 +237,31 @@ module Spec config(config, home(".bundle/config")) end - def create_file(*args) - path = bundled_app(args.shift) - path = args.shift if args.first.is_a?(Pathname) - str = args.shift || "" + def create_file(path, contents = "") + path = Pathname.new(path).expand_path(bundled_app) unless path.is_a?(Pathname) path.dirname.mkpath File.open(path.to_s, "w") do |f| - f.puts strip_whitespace(str) + f.puts strip_whitespace(contents) end end def gemfile(*args) - contents = args.shift + contents = args.pop if contents.nil? File.open(bundled_app_gemfile, "r", &:read) else - create_file("Gemfile", contents, *args) + create_file(args.pop || "Gemfile", contents) end end def lockfile(*args) - contents = args.shift + contents = args.pop if contents.nil? File.open(bundled_app_lock, "r", &:read) else - create_file("Gemfile.lock", contents, *args) + create_file(args.pop || "Gemfile.lock", contents) end end @@ -274,8 +272,8 @@ module Spec end def install_gemfile(*args) + opts = args.last.is_a?(Hash) ? args.pop : {} gemfile(*args) - opts = args.last.is_a?(Hash) ? args.last : {} bundle :install, opts end @@ -560,6 +558,11 @@ module Spec port end + def exit_status_for_signal(signal_number) + # For details see: https://en.wikipedia.org/wiki/Exit_status#Shell_and_scripts + 128 + signal_number + end + private def git_root_dir? |