From 8e6bbc032c1bde617a45e418af697831df471083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Thu, 16 Mar 2023 18:37:42 +0100 Subject: Don't remove RUBY platform when healing a lockfile with missing specs --- spec/bundler/lock/lockfile_spec.rb | 92 ++++++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 39 deletions(-) (limited to 'spec/bundler/lock') 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 -- cgit v1.2.1