[rubygems/rubygems] Make all tests still pass when switching from truffleruby to cruby

4f3d9fa3bf
This commit is contained in:
David Rodríguez 2024-07-24 20:38:00 +02:00 committed by git
parent 7feccb123a
commit bfaccd6433
5 changed files with 65 additions and 49 deletions

View file

@ -203,7 +203,7 @@ RSpec.describe "bundle cache" do
end end
describe "when previously cached" do describe "when previously cached" do
before :each do let :setup_main_repo do
build_repo2 build_repo2
install_gemfile <<-G install_gemfile <<-G
source "https://gem.repo2" source "https://gem.repo2"
@ -217,6 +217,7 @@ RSpec.describe "bundle cache" do
end end
it "re-caches during install" do it "re-caches during install" do
setup_main_repo
cached_gem("myrack-1.0.0").rmtree cached_gem("myrack-1.0.0").rmtree
bundle :install bundle :install
expect(out).to include("Updating files in vendor/cache") expect(out).to include("Updating files in vendor/cache")
@ -224,6 +225,7 @@ RSpec.describe "bundle cache" do
end end
it "adds and removes when gems are updated" do it "adds and removes when gems are updated" do
setup_main_repo
update_repo2 do update_repo2 do
build_gem "myrack", "1.2" do |s| build_gem "myrack", "1.2" do |s|
s.executables = "myrackup" s.executables = "myrackup"
@ -236,6 +238,7 @@ RSpec.describe "bundle cache" do
end end
it "adds new gems and dependencies" do it "adds new gems and dependencies" do
setup_main_repo
install_gemfile <<-G install_gemfile <<-G
source "https://gem.repo2" source "https://gem.repo2"
gem "rails" gem "rails"
@ -245,6 +248,7 @@ RSpec.describe "bundle cache" do
end end
it "removes .gems for removed gems and dependencies" do it "removes .gems for removed gems and dependencies" do
setup_main_repo
install_gemfile <<-G install_gemfile <<-G
source "https://gem.repo2" source "https://gem.repo2"
gem "myrack" gem "myrack"
@ -255,6 +259,7 @@ RSpec.describe "bundle cache" do
end end
it "removes .gems when gem changes to git source" do it "removes .gems when gem changes to git source" do
setup_main_repo
build_git "myrack" build_git "myrack"
install_gemfile <<-G install_gemfile <<-G
@ -279,16 +284,20 @@ RSpec.describe "bundle cache" do
end end
simulate_new_machine simulate_new_machine
simulate_platform "x86-darwin-100" do
install_gemfile <<-G install_gemfile <<-G
source "https://gem.repo1" source "https://gem.repo1"
gem "platform_specific" gem "platform_specific"
G G
expect(cached_gem("platform_specific-1.0-#{Bundler.local_platform}")).to exist expect(cached_gem("platform_specific-1.0-x86-darwin-100")).to exist
expect(cached_gem("platform_specific-1.0-java")).to exist expect(cached_gem("platform_specific-1.0-java")).to exist
end 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 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 = cached_gem("myrack-1.0.0")
cached_myrack.rmtree cached_myrack.rmtree
build_gem "myrack", "1.0.0", build_gem "myrack", "1.0.0",
@ -319,6 +328,7 @@ RSpec.describe "bundle cache" do
end end
it "raises an error when a cached gem is altered and produces a different checksum than the remote gem" do 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 cached_gem("myrack-1.0.0").rmtree
build_gem "myrack", "1.0.0", path: bundled_app("vendor/cache") build_gem "myrack", "1.0.0", path: bundled_app("vendor/cache")
@ -348,6 +358,7 @@ RSpec.describe "bundle cache" do
end end
it "installs a modified gem with a non-matching checksum when the API implementation does not provide checksums" do 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 cached_gem("myrack-1.0.0").rmtree
build_gem "myrack", "1.0.0", path: bundled_app("vendor/cache") build_gem "myrack", "1.0.0", path: bundled_app("vendor/cache")
simulate_new_machine simulate_new_machine
@ -364,12 +375,14 @@ RSpec.describe "bundle cache" do
end end
it "handles directories and non .gem files in the cache" do it "handles directories and non .gem files in the cache" do
setup_main_repo
bundled_app("vendor/cache/foo").mkdir bundled_app("vendor/cache/foo").mkdir
File.open(bundled_app("vendor/cache/bar"), "w") {|f| f.write("not a gem") } File.open(bundled_app("vendor/cache/bar"), "w") {|f| f.write("not a gem") }
bundle :cache bundle :cache
end end
it "does not say that it is removing gems when it isn't actually doing so" do it "does not say that it is removing gems when it isn't actually doing so" do
setup_main_repo
install_gemfile <<-G install_gemfile <<-G
source "https://gem.repo1" source "https://gem.repo1"
gem "myrack" gem "myrack"
@ -380,6 +393,7 @@ RSpec.describe "bundle cache" do
end end
it "does not warn about all if it doesn't have any git/path dependency" do it "does not warn about all if it doesn't have any git/path dependency" do
setup_main_repo
install_gemfile <<-G install_gemfile <<-G
source "https://gem.repo1" source "https://gem.repo1"
gem "myrack" gem "myrack"

View file

@ -249,12 +249,14 @@ RSpec.describe "bundle install with gem sources" do
describe "with a gem that installs multiple platforms" do describe "with a gem that installs multiple platforms" do
it "installs gems for the local platform as first choice" do it "installs gems for the local platform as first choice" do
simulate_platform "x86-darwin-100" do
install_gemfile <<-G install_gemfile <<-G
source "https://gem.repo1" source "https://gem.repo1"
gem "platform_specific" gem "platform_specific"
G 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 end
it "falls back on plain ruby" do it "falls back on plain ruby" do

View file

@ -559,13 +559,16 @@ RSpec.describe "bundle update" do
gem "myrack-obama" gem "myrack-obama"
gem "platform_specific" gem "platform_specific"
G G
end
it "doesn't hit repo2" do
simulate_platform "x86-darwin-100" do
lockfile <<~L lockfile <<~L
GEM GEM
remote: https://gem.repo2/ remote: https://gem.repo2/
specs: specs:
activesupport (2.3.5) activesupport (2.3.5)
platform_specific (1.0-#{local_platform}) platform_specific (1.0-x86-darwin-100)
myrack (1.0.0) myrack (1.0.0)
myrack-obama (1.0) myrack-obama (1.0)
myrack myrack
@ -583,15 +586,14 @@ RSpec.describe "bundle update" do
L L
bundle "install" bundle "install"
end
it "doesn't hit repo2" do
FileUtils.rm_rf(gem_repo2) FileUtils.rm_rf(gem_repo2)
bundle "update --local --all" bundle "update --local --all"
expect(out).not_to include("Fetching source index") expect(out).not_to include("Fetching source index")
end end
end end
end
describe "with --group option" do describe "with --group option" do
before do before do

View file

@ -118,7 +118,8 @@ RSpec.describe "bundle install with force_ruby_platform DSL option", :jruby do
#{Bundler::VERSION} #{Bundler::VERSION}
L 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" install_gemfile <<-G, env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }, artifice: "compact_index"
source "https://gem.repo4" source "https://gem.repo4"
@ -129,4 +130,5 @@ RSpec.describe "bundle install with force_ruby_platform DSL option", :jruby do
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
end
end end

View file

@ -88,10 +88,6 @@ module Spec
s.write "lib/myrack/test.rb", "MYRACK_TEST = '1.0'" s.write "lib/myrack/test.rb", "MYRACK_TEST = '1.0'"
end end
build_gem "platform_specific" do |s|
s.platform = Gem::Platform.local
end
build_gem "platform_specific" do |s| build_gem "platform_specific" do |s|
s.platform = "java" s.platform = "java"
end end