diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2023-03-16 18:37:42 +0100 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2023-03-23 17:18:49 +0900 |
commit | 8e6bbc032c1bde617a45e418af697831df471083 (patch) | |
tree | 1c72bed11329f3c2151c2702a817d05500bc6110 | |
parent | 4e7c39f98ceaf5160d9a97b7d2405623f972773a (diff) | |
download | ruby-8e6bbc032c1bde617a45e418af697831df471083.tar.gz |
Don't remove RUBY platform when healing a lockfile with missing specs
-rw-r--r-- | lib/bundler/spec_set.rb | 2 | ||||
-rw-r--r-- | spec/bundler/lock/lockfile_spec.rb | 92 |
2 files changed, 55 insertions, 39 deletions
diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb index 4882f7b38a..cf63c16a70 100644 --- a/lib/bundler/spec_set.rb +++ b/lib/bundler/spec_set.rb @@ -103,6 +103,8 @@ module Bundler def incomplete_ruby_specs?(deps) return false if @specs.empty? + @incomplete_specs = [] + self.for(deps, true, [Gem::Platform::RUBY]) @incomplete_specs.any? diff --git a/spec/bundler/lock/lockfile_spec.rb b/spec/bundler/lock/lockfile_spec.rb index 78130d8f15..d8fd09eb54 100644 --- a/spec/bundler/lock/lockfile_spec.rb +++ b/spec/bundler/lock/lockfile_spec.rb @@ -1272,57 +1272,71 @@ RSpec.describe "the lockfile format" do G end - it "auto-heals when the lockfile is missing dependent specs" do - build_repo4 do - build_gem "minitest-bisect", "1.6.0" do |s| - s.add_dependency "path_expander", "~> 1.1" + shared_examples_for "a lockfile missing dependent specs" do + it "auto-heals" do + build_repo4 do + build_gem "minitest-bisect", "1.6.0" do |s| + s.add_dependency "path_expander", "~> 1.1" + end + + build_gem "path_expander", "1.1.1" end - build_gem "path_expander", "1.1.1" - end + gemfile <<~G + source "#{file_uri_for(gem_repo4)}" + gem "minitest-bisect" + G - gemfile <<~G - source "#{file_uri_for(gem_repo4)}" - gem "minitest-bisect" - G + # Corrupt lockfile (completely missing path_expander) + lockfile <<~L + GEM + remote: #{file_uri_for(gem_repo4)}/ + specs: + minitest-bisect (1.6.0) - # Corrupt lockfile (completely missing path_expander) - lockfile <<~L - GEM - remote: #{file_uri_for(gem_repo4)}/ - specs: - minitest-bisect (1.6.0) + PLATFORMS + #{platforms} - PLATFORMS - #{lockfile_platforms} + DEPENDENCIES + minitest-bisect - DEPENDENCIES - minitest-bisect + BUNDLED WITH + #{Bundler::VERSION} + L - BUNDLED WITH - #{Bundler::VERSION} - L + cache_gems "minitest-bisect-1.6.0", "path_expander-1.1.1", :gem_repo => gem_repo4 + bundle :install - cache_gems "minitest-bisect-1.6.0", "path_expander-1.1.1", :gem_repo => gem_repo4 - bundle :install + expect(lockfile).to eq <<~L + GEM + remote: #{file_uri_for(gem_repo4)}/ + specs: + minitest-bisect (1.6.0) + path_expander (~> 1.1) + path_expander (1.1.1) - expect(lockfile).to eq <<~L - GEM - remote: #{file_uri_for(gem_repo4)}/ - specs: - minitest-bisect (1.6.0) - path_expander (~> 1.1) - path_expander (1.1.1) + PLATFORMS + #{platforms} - PLATFORMS - #{lockfile_platforms} + DEPENDENCIES + minitest-bisect - DEPENDENCIES - minitest-bisect + BUNDLED WITH + #{Bundler::VERSION} + L + end + end - BUNDLED WITH - #{Bundler::VERSION} - L + context "with just specific platform" do + let(:platforms) { lockfile_platforms } + + it_behaves_like "a lockfile missing dependent specs" + end + + context "with both ruby and specific platform" do + let(:platforms) { lockfile_platforms("ruby") } + + it_behaves_like "a lockfile missing dependent specs" end it "auto-heals when the lockfile is missing specs" do |