diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/bundler/bundler/cli_spec.rb | 4 | ||||
-rw-r--r-- | spec/bundler/bundler/definition_spec.rb | 40 | ||||
-rw-r--r-- | spec/bundler/commands/check_spec.rb | 9 | ||||
-rw-r--r-- | spec/bundler/commands/exec_spec.rb | 43 | ||||
-rw-r--r-- | spec/bundler/commands/outdated_spec.rb | 11 | ||||
-rw-r--r-- | spec/bundler/install/gemfile/specific_platform_spec.rb | 57 | ||||
-rw-r--r-- | spec/bundler/install/gems/resolving_spec.rb | 6 | ||||
-rw-r--r-- | spec/bundler/lock/lockfile_spec.rb | 4 | ||||
-rw-r--r-- | spec/bundler/realworld/edgecases_spec.rb | 111 | ||||
-rw-r--r-- | spec/bundler/support/artifice/vcr.rb | 1 | ||||
-rw-r--r-- | spec/bundler/support/platforms.rb | 2 |
11 files changed, 223 insertions, 65 deletions
diff --git a/spec/bundler/bundler/cli_spec.rb b/spec/bundler/bundler/cli_spec.rb index dc7d4a50aa..ccf957d6df 100644 --- a/spec/bundler/bundler/cli_spec.rb +++ b/spec/bundler/bundler/cli_spec.rb @@ -7,10 +7,10 @@ using Module.new { # non-tty. refine Spec::Helpers do def out - super.gsub(/.[\b]/, '') + super.gsub(/.[\b]/, "") end end -} +} if RUBY_VERSION >= "2.4" RSpec.describe "bundle executable" do it "returns non-zero exit status when passed unrecognized options" do diff --git a/spec/bundler/bundler/definition_spec.rb b/spec/bundler/bundler/definition_spec.rb index d0ebb37933..dcdde75315 100644 --- a/spec/bundler/bundler/definition_spec.rb +++ b/spec/bundler/bundler/definition_spec.rb @@ -34,45 +34,7 @@ RSpec.describe Bundler::Definition do end describe "detects changes" do - it "for a path gem with changes", :bundler => "< 3" do - build_lib "foo", "1.0", :path => lib_path("foo") - - install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" - gem "foo", :path => "#{lib_path("foo")}" - G - - build_lib "foo", "1.0", :path => lib_path("foo") do |s| - s.add_dependency "rack", "1.0" - end - - bundle :install, :env => { "DEBUG" => "1" } - - expect(out).to match(/re-resolving dependencies/) - lockfile_should_be <<-G - PATH - remote: #{lib_path("foo")} - specs: - foo (1.0) - rack (= 1.0) - - GEM - remote: #{file_uri_for(gem_repo1)}/ - specs: - rack (1.0.0) - - PLATFORMS - #{lockfile_platforms} - - DEPENDENCIES - foo! - - BUNDLED WITH - #{Bundler::VERSION} - G - end - - it "for a path gem with changes", :bundler => "3" do + it "for a path gem with changes" do build_lib "foo", "1.0", :path => lib_path("foo") install_gemfile <<-G diff --git a/spec/bundler/commands/check_spec.rb b/spec/bundler/commands/check_spec.rb index 5a746591b3..fdf3bc7d51 100644 --- a/spec/bundler/commands/check_spec.rb +++ b/spec/bundler/commands/check_spec.rb @@ -311,6 +311,8 @@ RSpec.describe "bundle check" do end before do + bundle "config set --local path vendor/bundle" + install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "rack" @@ -336,9 +338,10 @@ RSpec.describe "bundle check" do context "is older" do it "does not change the lock" do - lockfile lock_with("1.10.1") - bundle :check, :raise_on_error => false - lockfile_should_be lock_with("1.10.1") + system_gems "bundler-1.18.0" + lockfile lock_with("1.18.0") + bundle :check + lockfile_should_be lock_with("1.18.0") end end end diff --git a/spec/bundler/commands/exec_spec.rb b/spec/bundler/commands/exec_spec.rb index 4c34964053..85f8ceef62 100644 --- a/spec/bundler/commands/exec_spec.rb +++ b/spec/bundler/commands/exec_spec.rb @@ -938,6 +938,49 @@ __FILE__: #{path.to_s.inspect} end end + context "when gemfile and path are configured", :ruby_repo do + before do + skip "https://github.com/rubygems/rubygems/issues/3351" if Gem.win_platform? + + build_repo2 do + build_gem "rails", "6.1.0" do |s| + s.executables = "rails" + end + end + + bundle "config set path vendor/bundle" + bundle "config set gemfile gemfiles/rack_6_1.gemfile" + + create_file(bundled_app("gemfiles/rack_6_1.gemfile"), <<~RUBY) + source "#{file_uri_for(gem_repo2)}" + + gem "rails", "6.1.0" + RUBY + + # A Gemfile needs to be in the root to trick bundler's root resolution + create_file(bundled_app("Gemfile")) + + bundle "install" + end + + it "can still find gems after a nested subprocess" do + script = bundled_app("bin/myscript") + + create_file(script, <<~RUBY) + #!#{Gem.ruby} + + puts `bundle exec rails` + RUBY + + script.chmod(0o777) + + bundle "exec #{script}" + + expect(err).to be_empty + expect(out).to eq("6.1.0") + end + end + context "with a system gem that shadows a default gem" do let(:openssl_version) { "99.9.9" } let(:expected) { ruby "gem 'openssl', '< 999999'; require 'openssl'; puts OpenSSL::VERSION", :artifice => nil, :raise_on_error => false } diff --git a/spec/bundler/commands/outdated_spec.rb b/spec/bundler/commands/outdated_spec.rb index 1faee23f26..0ee8bd425a 100644 --- a/spec/bundler/commands/outdated_spec.rb +++ b/spec/bundler/commands/outdated_spec.rb @@ -429,6 +429,17 @@ RSpec.describe "bundle outdated" do expect(out).to end_with(expected_output) end + it "doesn't crash when some deps unused on the current platform" do + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + gem "activesupport", platforms: [:ruby_22] + G + + bundle :outdated, filter_strict_option => true + + expect(out).to end_with("Bundle up to date!") + end + it "only reports gem dependencies when they can actually be updated" do install_gemfile <<-G source "#{file_uri_for(gem_repo2)}" diff --git a/spec/bundler/install/gemfile/specific_platform_spec.rb b/spec/bundler/install/gemfile/specific_platform_spec.rb index 82492e78cb..d85c670b64 100644 --- a/spec/bundler/install/gemfile/specific_platform_spec.rb +++ b/spec/bundler/install/gemfile/specific_platform_spec.rb @@ -9,36 +9,67 @@ RSpec.describe "bundle install with specific platforms" do context "when on a darwin machine" do before { simulate_platform "x86_64-darwin-15" } - it "locks to both the specific darwin platform and ruby" do + it "locks to the specific darwin platform" do setup_multiplatform_gem install_gemfile(google_protobuf) allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile) - expect(the_bundle.locked_gems.platforms).to eq([pl("ruby"), pl("x86_64-darwin-15")]) + expect(the_bundle.locked_gems.platforms).to eq([pl("x86_64-darwin-15")]) expect(the_bundle).to include_gem("google-protobuf 3.0.0.alpha.5.0.5.1 universal-darwin") expect(the_bundle.locked_gems.specs.map(&:full_name)).to eq(%w[ - google-protobuf-3.0.0.alpha.5.0.5.1 google-protobuf-3.0.0.alpha.5.0.5.1-universal-darwin ]) end - it "caches both the universal-darwin and ruby gems when --all-platforms is passed and properly picks them up on further bundler invocations" do + it "understands that a non-plaform specific gem in a old lockfile doesn't necessarily mean installing the non-specific variant" do + setup_multiplatform_gem + + system_gems "bundler-2.1.4" + + # Consistent location to install and look for gems + bundle "config set --local path vendor/bundle", :env => { "BUNDLER_VERSION" => "2.1.4" } + + install_gemfile(google_protobuf, :env => { "BUNDLER_VERSION" => "2.1.4" }) + + # simulate lockfile created with old bundler, which only locks for ruby platform + lockfile <<-L + GEM + remote: #{file_uri_for(gem_repo2)}/ + specs: + google-protobuf (3.0.0.alpha.5.0.5.1) + + PLATFORMS + ruby + + DEPENDENCIES + google-protobuf + + BUNDLED WITH + 2.1.4 + L + + # force strict usage of the lock file by setting frozen mode + bundle "config set --local frozen true", :env => { "BUNDLER_VERSION" => "2.1.4" } + + # make sure the platform that got actually installed with the old bundler is used + expect(the_bundle).to include_gem("google-protobuf 3.0.0.alpha.5.0.5.1 universal-darwin") + end + + it "caches the universal-darwin gem when --all-platforms is passed and properly picks it up on further bundler invocations" do setup_multiplatform_gem gemfile(google_protobuf) bundle "cache --all-platforms" - expect([cached_gem("google-protobuf-3.0.0.alpha.5.0.5.1"), cached_gem("google-protobuf-3.0.0.alpha.5.0.5.1-universal-darwin")]). - to all(exist) + expect(cached_gem("google-protobuf-3.0.0.alpha.5.0.5.1-universal-darwin")).to exist bundle "install --verbose" expect(err).to be_empty end - it "caches both the universal-darwin and ruby gems when cache_all_platforms is configured and properly picks them up on further bundler invocations" do + it "caches the universal-darwin gem when cache_all_platforms is configured and properly picks it up on further bundler invocations" do setup_multiplatform_gem gemfile(google_protobuf) bundle "config set --local cache_all_platforms true" bundle "cache" - expect([cached_gem("google-protobuf-3.0.0.alpha.5.0.5.1"), cached_gem("google-protobuf-3.0.0.alpha.5.0.5.1-universal-darwin")]). - to all(exist) + expect(cached_gem("google-protobuf-3.0.0.alpha.5.0.5.1-universal-darwin")).to exist bundle "install --verbose" expect(err).to be_empty @@ -87,10 +118,9 @@ RSpec.describe "bundle install with specific platforms" do G allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile) - expect(the_bundle.locked_gems.platforms).to eq([pl("ruby"), pl("x86_64-darwin-15")]) + expect(the_bundle.locked_gems.platforms).to eq([pl("x86_64-darwin-15")]) expect(the_bundle).to include_gems("facter 2.4.6 universal-darwin", "CFPropertyList 1.0") expect(the_bundle.locked_gems.specs.map(&:full_name)).to eq(["CFPropertyList-1.0", - "facter-2.4.6", "facter-2.4.6-universal-darwin"]) end @@ -104,9 +134,8 @@ RSpec.describe "bundle install with specific platforms" do install_gemfile(google_protobuf) bundle "lock --add-platform=#{x64_mingw}" - expect(the_bundle.locked_gems.platforms).to eq([rb, x64_mingw, pl("x86_64-darwin-15")]) + expect(the_bundle.locked_gems.platforms).to eq([x64_mingw, pl("x86_64-darwin-15")]) expect(the_bundle.locked_gems.specs.map(&:full_name)).to eq(%w[ - google-protobuf-3.0.0.alpha.5.0.5.1 google-protobuf-3.0.0.alpha.5.0.5.1-universal-darwin google-protobuf-3.0.0.alpha.5.0.5.1-x64-mingw32 ]) @@ -117,7 +146,7 @@ RSpec.describe "bundle install with specific platforms" do install_gemfile(google_protobuf) bundle "lock --add-platform=#{java}" - expect(the_bundle.locked_gems.platforms).to eq([java, rb, pl("x86_64-darwin-15")]) + expect(the_bundle.locked_gems.platforms).to eq([java, pl("x86_64-darwin-15")]) expect(the_bundle.locked_gems.specs.map(&:full_name)).to eq(%w[ google-protobuf-3.0.0.alpha.5.0.5.1 google-protobuf-3.0.0.alpha.5.0.5.1-universal-darwin diff --git a/spec/bundler/install/gems/resolving_spec.rb b/spec/bundler/install/gems/resolving_spec.rb index 1c01ce588b..4384a731cd 100644 --- a/spec/bundler/install/gems/resolving_spec.rb +++ b/spec/bundler/install/gems/resolving_spec.rb @@ -116,7 +116,7 @@ RSpec.describe "bundle install with install-time dependencies" do bundle :install, :env => { "BUNDLER_DEBUG_RESOLVER" => "1" } - expect(err).to include("BUNDLER: Starting resolution") + expect(out).to include("BUNDLER: Starting resolution") end end @@ -130,7 +130,7 @@ RSpec.describe "bundle install with install-time dependencies" do bundle :install, :env => { "DEBUG_RESOLVER" => "1" } - expect(err).to include("BUNDLER: Starting resolution") + expect(out).to include("BUNDLER: Starting resolution") end end @@ -147,7 +147,7 @@ RSpec.describe "bundle install with install-time dependencies" do activated_groups = "net_b (1.0) (ruby)" activated_groups += ", net_b (1.0) (#{local_platforms.join(", ")})" if local_platforms.any? && local_platforms != ["ruby"] - expect(err).to include(" net_b"). + expect(out).to include(" net_b"). and include("BUNDLER: Starting resolution"). and include("BUNDLER: Finished resolution"). and include("Attempting to activate [#{activated_groups}]") diff --git a/spec/bundler/lock/lockfile_spec.rb b/spec/bundler/lock/lockfile_spec.rb index 941cbd13e0..0d340b070e 100644 --- a/spec/bundler/lock/lockfile_spec.rb +++ b/spec/bundler/lock/lockfile_spec.rb @@ -981,7 +981,7 @@ RSpec.describe "the lockfile format" do G end - it "persists the spec's platform and specific platform to the lockfile" do + it "persists the spec's specific platform to the lockfile" do build_repo2 do build_gem "platform_specific", "1.0" do |s| s.platform = Gem::Platform.new("universal-java-16") @@ -999,11 +999,9 @@ RSpec.describe "the lockfile format" do GEM remote: #{file_uri_for(gem_repo2)}/ specs: - platform_specific (1.0-java) platform_specific (1.0-universal-java-16) PLATFORMS - java universal-java-16 DEPENDENCIES diff --git a/spec/bundler/realworld/edgecases_spec.rb b/spec/bundler/realworld/edgecases_spec.rb index e5600bb1c1..0f19cc7842 100644 --- a/spec/bundler/realworld/edgecases_spec.rb +++ b/spec/bundler/realworld/edgecases_spec.rb @@ -345,4 +345,115 @@ RSpec.describe "real world edgecases", :realworld => true, :sometimes => true do expect(err).to include("You have one or more invalid gemspecs that need to be fixed.") expect(err).to include("resque-scheduler 2.2.0 has an invalid gemspec") end + + it "doesn't hang on big gemfile" do + skip "Only for ruby 2.7.2" if RUBY_VERSION != "2.7.2" + + gemfile <<~G + # frozen_string_literal: true + + source "https://rubygems.org" + + ruby "2.7.2" + + gem "rails" + gem "pg", ">= 0.18", "< 2.0" + gem "goldiloader" + gem "awesome_nested_set" + gem "circuitbox" + gem "passenger" + gem "globalid" + gem "rack-cors" + gem "rails-pg-extras" + gem "linear_regression_trend" + gem "rack-protection" + gem "pundit" + gem "remote_ip_proxy_scrubber" + gem "bcrypt" + gem "searchkick" + gem "excon" + gem "faraday_middleware-aws-sigv4" + gem "typhoeus" + gem "sidekiq" + gem "sidekiq-undertaker" + gem "sidekiq-cron" + gem "storext" + gem "appsignal" + gem "fcm" + gem "business_time" + gem "tzinfo" + gem "holidays" + gem "bigdecimal" + gem "progress_bar" + gem "redis" + gem "hiredis" + gem "state_machines" + gem "state_machines-audit_trail" + gem "state_machines-activerecord" + gem "interactor" + gem "ar_transaction_changes" + gem "redis-rails" + gem "seed_migration" + gem "lograge" + gem "graphiql-rails", group: :development + gem "graphql" + gem "pusher" + gem "rbnacl" + gem "jwt" + gem "json-schema" + gem "discard" + gem "money" + gem "strip_attributes" + gem "validates_email_format_of" + gem "audited" + gem "concurrent-ruby" + gem "with_advisory_lock" + + group :test do + gem "rspec-sidekiq" + gem "simplecov", require: false + end + + group :development, :test do + gem "byebug", platform: :mri + gem "guard" + gem "guard-bundler" + gem "guard-rspec" + gem "rb-fsevent" + gem "rspec_junit_formatter" + gem "rspec-collection_matchers" + gem "rspec-rails" + gem "rspec-retry" + gem "state_machines-rspec" + gem "dotenv-rails" + gem "database_cleaner-active_record" + gem "database_cleaner-redis" + gem "timecop" + end + + gem "factory_bot_rails" + gem "faker" + + group :development do + gem "listen" + gem "sql_queries_count" + gem "rubocop" + gem "rubocop-performance" + gem "rubocop-rspec" + gem "rubocop-rails" + gem "brakeman" + gem "bundler-audit" + gem "solargraph" + gem "annotate" + end + G + + bundle :lock, :env => { "DEBUG_RESOLVER" => "1" } + + if Bundler.feature_flag.bundler_3_mode? + expect(out).to include("BUNDLER: Finished resolution (2492 steps)") + else + expect(out).to include("BUNDLER: Finished resolution (2722 steps)") + end + end end diff --git a/spec/bundler/support/artifice/vcr.rb b/spec/bundler/support/artifice/vcr.rb index 19670287b3..bd13a338b4 100644 --- a/spec/bundler/support/artifice/vcr.rb +++ b/spec/bundler/support/artifice/vcr.rb @@ -56,6 +56,7 @@ class BundlerVCRHTTP < Net::HTTP response = http.request_without_vcr(request, body, &response_block) @recording = false unless @recording + require "fileutils" FileUtils.mkdir_p(File.dirname(request_path)) binwrite(request_path, request_to_string(request)) binwrite(response_path, response_to_string(response)) diff --git a/spec/bundler/support/platforms.rb b/spec/bundler/support/platforms.rb index ab203919e7..0cb7f7cd29 100644 --- a/spec/bundler/support/platforms.rb +++ b/spec/bundler/support/platforms.rb @@ -94,7 +94,7 @@ module Spec end def local_platforms - [local, specific_local_platform].uniq + [specific_local_platform] end end end |