Skip to content

Commit

Permalink
[rubygems/rubygems] Make all tests still pass when switching from tru…
Browse files Browse the repository at this point in the history
…ffleruby to cruby

rubygems/rubygems@4f3d9fa3bf
  • Loading branch information
deivid-rodriguez authored and matzbot committed Jul 26, 2024
1 parent 7feccb1 commit bfaccd6
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 50 deletions.
28 changes: 21 additions & 7 deletions spec/bundler/cache/gems_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 203,7 @@
end

describe "when previously cached" do
before :each do
let :setup_main_repo do
build_repo2
install_gemfile <<-G
source "https://gem.repo2"
Expand All @@ -217,13 217,15 @@
end

it "re-caches during install" do
setup_main_repo
cached_gem("myrack-1.0.0").rmtree
bundle :install
expect(out).to include("Updating files in vendor/cache")
expect(cached_gem("myrack-1.0.0")).to exist
end

it "adds and removes when gems are updated" do
setup_main_repo
update_repo2 do
build_gem "myrack", "1.2" do |s|
s.executables = "myrackup"
Expand All @@ -236,6 238,7 @@
end

it "adds new gems and dependencies" do
setup_main_repo
install_gemfile <<-G
source "https://gem.repo2"
gem "rails"
Expand All @@ -245,6 248,7 @@
end

it "removes .gems for removed gems and dependencies" do
setup_main_repo
install_gemfile <<-G
source "https://gem.repo2"
gem "myrack"
Expand All @@ -255,6 259,7 @@
end

it "removes .gems when gem changes to git source" do
setup_main_repo
build_git "myrack"

install_gemfile <<-G
Expand All @@ -279,16 284,20 @@
end

simulate_new_machine
install_gemfile <<-G
source "https://gem.repo1"
gem "platform_specific"
G

expect(cached_gem("platform_specific-1.0-#{Bundler.local_platform}")).to exist
expect(cached_gem("platform_specific-1.0-java")).to exist
simulate_platform "x86-darwin-100" do
install_gemfile <<-G
source "https://gem.repo1"
gem "platform_specific"
G

expect(cached_gem("platform_specific-1.0-x86-darwin-100")).to exist
expect(cached_gem("platform_specific-1.0-java")).to exist
end
end

it "doesn't remove gems cached gems that don't match their remote counterparts, but also refuses to install and prints an error" do
setup_main_repo
cached_myrack = cached_gem("myrack-1.0.0")
cached_myrack.rmtree
build_gem "myrack", "1.0.0",
Expand Down Expand Up @@ -319,6 328,7 @@
end

it "raises an error when a cached gem is altered and produces a different checksum than the remote gem" do
setup_main_repo
cached_gem("myrack-1.0.0").rmtree
build_gem "myrack", "1.0.0", path: bundled_app("vendor/cache")

Expand Down Expand Up @@ -348,6 358,7 @@
end

it "installs a modified gem with a non-matching checksum when the API implementation does not provide checksums" do
setup_main_repo
cached_gem("myrack-1.0.0").rmtree
build_gem "myrack", "1.0.0", path: bundled_app("vendor/cache")
simulate_new_machine
Expand All @@ -364,12 375,14 @@
end

it "handles directories and non .gem files in the cache" do
setup_main_repo
bundled_app("vendor/cache/foo").mkdir
File.open(bundled_app("vendor/cache/bar"), "w") {|f| f.write("not a gem") }
bundle :cache
end

it "does not say that it is removing gems when it isn't actually doing so" do
setup_main_repo
install_gemfile <<-G
source "https://gem.repo1"
gem "myrack"
Expand All @@ -380,6 393,7 @@
end

it "does not warn about all if it doesn't have any git/path dependency" do
setup_main_repo
install_gemfile <<-G
source "https://gem.repo1"
gem "myrack"
Expand Down
12 changes: 7 additions & 5 deletions spec/bundler/commands/install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 249,14 @@

describe "with a gem that installs multiple platforms" do
it "installs gems for the local platform as first choice" do
install_gemfile <<-G
source "https://gem.repo1"
gem "platform_specific"
G
simulate_platform "x86-darwin-100" do
install_gemfile <<-G
source "https://gem.repo1"
gem "platform_specific"
G

expect(the_bundle).to include_gems("platform_specific 1.0 #{Bundler.local_platform}")
expect(the_bundle).to include_gems("platform_specific 1.0 x86-darwin-100")
end
end

it "falls back on plain ruby" do
Expand Down
58 changes: 30 additions & 28 deletions spec/bundler/commands/update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -559,37 559,39 @@
gem "myrack-obama"
gem "platform_specific"
G

lockfile <<~L
GEM
remote: https://gem.repo2/
specs:
activesupport (2.3.5)
platform_specific (1.0-#{local_platform})
myrack (1.0.0)
myrack-obama (1.0)
myrack
PLATFORMS
#{local_platform}
DEPENDENCIES
activesupport
platform_specific
myrack-obama
BUNDLED WITH
#{Bundler::VERSION}
L

bundle "install"
end

it "doesn't hit repo2" do
FileUtils.rm_rf(gem_repo2)

bundle "update --local --all"
expect(out).not_to include("Fetching source index")
simulate_platform "x86-darwin-100" do
lockfile <<~L
GEM
remote: https://gem.repo2/
specs:
activesupport (2.3.5)
platform_specific (1.0-x86-darwin-100)
myrack (1.0.0)
myrack-obama (1.0)
myrack
PLATFORMS
#{local_platform}
DEPENDENCIES
activesupport
platform_specific
myrack-obama
BUNDLED WITH
#{Bundler::VERSION}
L

bundle "install"

FileUtils.rm_rf(gem_repo2)

bundle "update --local --all"
expect(out).not_to include("Fetching source index")
end
end
end

Expand Down
14 changes: 8 additions & 6 deletions spec/bundler/install/gemfile/force_ruby_platform_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 118,17 @@
#{Bundler::VERSION}
L

system_gems "platform_specific-1.0-#{Gem::Platform.local}", path: default_bundle_path
simulate_platform "x86-darwin-100" do
system_gems "platform_specific-1.0-x86-darwin-100", path: default_bundle_path

install_gemfile <<-G, env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }, artifice: "compact_index"
source "https://gem.repo4"
install_gemfile <<-G, env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }, artifice: "compact_index"
source "https://gem.repo4"
gem "platform_specific", :force_ruby_platform => true
G
gem "platform_specific", :force_ruby_platform => true
G

expect(the_bundle).to include_gems "platform_specific 1.0 ruby"
expect(the_bundle).to include_gems "platform_specific 1.0 ruby"
end
end
end
end
4 changes: 0 additions & 4 deletions spec/bundler/support/builders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 88,6 @@ def build_repo1
s.write "lib/myrack/test.rb", "MYRACK_TEST = '1.0'"
end

build_gem "platform_specific" do |s|
s.platform = Gem::Platform.local
end

build_gem "platform_specific" do |s|
s.platform = "java"
end
Expand Down

0 comments on commit bfaccd6

Please sign in to comment.