Skip to content

Commit

Permalink
[rubygems/rubygems] Test that git sources in lockfiles have stable so…
Browse files Browse the repository at this point in the history
  • Loading branch information
duckinator authored and hsbt committed Jul 4, 2023
1 parent 0938213 commit 4f2f1dd
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions spec/bundler/install/git_spec.rb
Expand Up @@ -98,5 +98,79 @@
bundle "info zebra"
expect(out).to include("* zebra (2.0 #{revision_for(lib_path("gems"))[0..6]})")
end

it "should always sort dependencies in the same order" do
# This Gemfile + lockfile had a problem where the first
# `bundle install` would change the order, but the second would
# change it back.

# NOTE: both gems MUST have the same path! It has to be two gems in one repo.

test = build_git "test", "1.0.0", :path => lib_path("test-and-other")
other = build_git "other", "1.0.0", :path => lib_path("test-and-other")
test_ref = test.ref_for("HEAD")
other_ref = other.ref_for("HEAD")

gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "test", git: #{test.path.to_s.inspect}
gem "other", ref: #{other_ref.inspect}, git: #{other.path.to_s.inspect}
G

lockfile <<-L
GIT
remote: #{test.path}
revision: #{test_ref}
specs:
test (1.0.0)
GIT
remote: #{other.path}
revision: #{other_ref}
ref: #{other_ref}
specs:
other (1.0.0)
GEM
remote: #{file_uri_for(gem_repo1)}/
specs:
PLATFORMS
ruby
DEPENDENCIES
other!
test!
BUNDLED WITH
#{Bundler::VERSION}
L

original_lockfile = lockfile

# If GH#6743 is present, the first `bundle install` will change the
# lockfile, by flipping the order (`other` would be moved to the top).
#
# The second `bundle install` would then change the lockfile back
# to the original.
#
# The fix makes it so it may change it once, but it will not change
# it a second time.
#
# So, we run `bundle install` once, and store the value of the
# modified lockfile.
bundle :install
modified_lockfile = lockfile

# If GH#6743 is present, the second `bundle install` would change the
# lockfile back to what it was originally.
#
# This `expect` makes sure it doesn't change a second time.
bundle :install
expect(lockfile).to eq(modified_lockfile)

expect(out).to include("Bundle complete!")
end
end
end

0 comments on commit 4f2f1dd

Please sign in to comment.