mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[rubygems/rubygems] Add tests for universal Ruby with arch-specific prebuilt gems
https://github.com/rubygems/rubygems/commit/11229b16c3
This commit is contained in:
parent
2244d5084e
commit
0df47fdaf9
4 changed files with 89 additions and 1 deletions
|
@ -310,7 +310,7 @@ module Gem
|
|||
|
||||
# On universal Rubies, resolve the "universal" arch to the real CPU arch, without changing the extension directory.
|
||||
class Specification
|
||||
if /^universal\.(?<arch>.*?)-/ =~ RUBY_PLATFORM
|
||||
if /^universal\.(?<arch>.*?)-/ =~ (CROSS_COMPILING || RUBY_PLATFORM)
|
||||
local_platform = Platform.local
|
||||
if local_platform.cpu == "universal"
|
||||
ORIGINAL_LOCAL_PLATFORM = local_platform.to_s.freeze
|
||||
|
|
|
@ -75,6 +75,81 @@ RSpec.describe "bundle install across platforms" do
|
|||
expect(the_bundle).to include_gems "platform_specific 1.0 RUBY"
|
||||
end
|
||||
|
||||
context "on universal Rubies" do
|
||||
before do
|
||||
build_repo4 do
|
||||
build_gem "darwin_single_arch" do |s|
|
||||
s.platform = "ruby"
|
||||
s.write "lib/darwin_single_arch.rb", "DARWIN_SINGLE_ARCH = '1.0 RUBY'"
|
||||
end
|
||||
build_gem "darwin_single_arch" do |s|
|
||||
s.platform = "arm64-darwin"
|
||||
s.write "lib/darwin_single_arch.rb", "DARWIN_SINGLE_ARCH = '1.0 arm64-darwin'"
|
||||
end
|
||||
build_gem "darwin_single_arch" do |s|
|
||||
s.platform = "x86_64-darwin"
|
||||
s.write "lib/darwin_single_arch.rb", "DARWIN_SINGLE_ARCH = '1.0 x86_64-darwin'"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it "pulls in the correct architecture gem" do
|
||||
lockfile <<-G
|
||||
GEM
|
||||
remote: #{file_uri_for(gem_repo4)}
|
||||
specs:
|
||||
darwin_single_arch (1.0)
|
||||
darwin_single_arch (1.0-arm64-darwin)
|
||||
darwin_single_arch (1.0-x86_64-darwin)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
darwin_single_arch
|
||||
G
|
||||
|
||||
simulate_platform "universal-darwin-21"
|
||||
simulate_ruby_platform "universal.x86_64-darwin21" do
|
||||
install_gemfile <<-G
|
||||
source "#{file_uri_for(gem_repo4)}"
|
||||
|
||||
gem "darwin_single_arch"
|
||||
G
|
||||
|
||||
expect(the_bundle).to include_gems "darwin_single_arch 1.0 x86_64-darwin"
|
||||
end
|
||||
end
|
||||
|
||||
it "pulls in the correct architecture gem on arm64e macOS Ruby" do
|
||||
lockfile <<-G
|
||||
GEM
|
||||
remote: #{file_uri_for(gem_repo4)}
|
||||
specs:
|
||||
darwin_single_arch (1.0)
|
||||
darwin_single_arch (1.0-arm64-darwin)
|
||||
darwin_single_arch (1.0-x86_64-darwin)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
darwin_single_arch
|
||||
G
|
||||
|
||||
simulate_platform "universal-darwin-21"
|
||||
simulate_ruby_platform "universal.arm64e-darwin21" do
|
||||
install_gemfile <<-G
|
||||
source "#{file_uri_for(gem_repo4)}"
|
||||
|
||||
gem "darwin_single_arch"
|
||||
G
|
||||
|
||||
expect(the_bundle).to include_gems "darwin_single_arch 1.0 arm64-darwin"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it "works with gems that have different dependencies" do
|
||||
simulate_platform "java"
|
||||
install_gemfile <<-G
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
if ENV["BUNDLER_SPEC_RUBY_PLATFORM"]
|
||||
Object.send(:remove_const, :RUBY_PLATFORM)
|
||||
RUBY_PLATFORM = ENV["BUNDLER_SPEC_RUBY_PLATFORM"]
|
||||
end
|
||||
|
||||
module Gem
|
||||
def self.ruby=(ruby)
|
||||
@ruby = ruby
|
||||
|
|
|
@ -432,6 +432,14 @@ module Spec
|
|||
pristine_system_gems :bundler
|
||||
end
|
||||
|
||||
def simulate_ruby_platform(ruby_platform)
|
||||
old = ENV["BUNDLER_SPEC_RUBY_PLATFORM"]
|
||||
ENV["BUNDLER_SPEC_RUBY_PLATFORM"] = ruby_platform.to_s
|
||||
yield
|
||||
ensure
|
||||
ENV["BUNDLER_SPEC_RUBY_PLATFORM"] = old
|
||||
end
|
||||
|
||||
def simulate_platform(platform)
|
||||
old = ENV["BUNDLER_SPEC_PLATFORM"]
|
||||
ENV["BUNDLER_SPEC_PLATFORM"] = platform.to_s
|
||||
|
|
Loading…
Reference in a new issue