1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
# frozen_string_literal: true
RSpec.describe "bundle install with force_ruby_platform DSL option", :jruby do
context "when no transitive deps" do
before do
build_repo4 do
# Build a gem with platform specific versions
build_gem("platform_specific")
build_gem("platform_specific") do |s|
s.platform = Bundler.local_platform
end
# Build the exact same gem with a different name to compare using vs not using the option
build_gem("platform_specific_forced")
build_gem("platform_specific_forced") do |s|
s.platform = Bundler.local_platform
end
end
end
it "pulls the pure ruby variant of the given gem" do
install_gemfile <<-G
source "https://gem.repo4"
gem "platform_specific_forced", :force_ruby_platform => true
gem "platform_specific"
G
expect(the_bundle).to include_gems "platform_specific_forced 1.0 ruby"
expect(the_bundle).to include_gems "platform_specific 1.0 #{Bundler.local_platform}"
end
it "still respects a global `force_ruby_platform` config" do
install_gemfile <<-G, env: { "BUNDLE_FORCE_RUBY_PLATFORM" => "true" }
source "https://gem.repo4"
gem "platform_specific_forced", :force_ruby_platform => true
gem "platform_specific"
G
expect(the_bundle).to include_gems "platform_specific_forced 1.0 ruby"
expect(the_bundle).to include_gems "platform_specific 1.0 ruby"
end
end
context "when also a transitive dependency" do
before do
build_repo4 do
build_gem("depends_on_platform_specific") {|s| s.add_dependency "platform_specific" }
build_gem("platform_specific")
build_gem("platform_specific") do |s|
s.platform = Bundler.local_platform
end
end
end
it "still pulls the ruby variant" do
install_gemfile <<-G
source "https://gem.repo4"
gem "depends_on_platform_specific"
gem "platform_specific", :force_ruby_platform => true
G
expect(the_bundle).to include_gems "platform_specific 1.0 ruby"
end
end
context "with transitive dependencies with platform specific versions" do
before do
build_repo4 do
build_gem("depends_on_platform_specific") do |s|
s.add_dependency "platform_specific"
end
build_gem("depends_on_platform_specific") do |s|
s.add_dependency "platform_specific"
s.platform = Bundler.local_platform
end
build_gem("platform_specific")
build_gem("platform_specific") do |s|
s.platform = Bundler.local_platform
end
end
end
it "ignores ruby variants for the transitive dependencies" do
install_gemfile <<-G, env: { "DEBUG_RESOLVER" => "true" }
source "https://gem.repo4"
gem "depends_on_platform_specific", :force_ruby_platform => true
G
expect(the_bundle).to include_gems "depends_on_platform_specific 1.0 ruby"
expect(the_bundle).to include_gems "platform_specific 1.0 #{Bundler.local_platform}"
end
it "reinstalls the ruby variant when a platform specific variant is already installed, the lockile has only ruby platform, and :force_ruby_platform is used in the Gemfile" do
skip "Can't simulate platform reliably on JRuby, installing a platform specific gem fails to activate io-wait because only the -java version is present, and we're simulating a different platform" if RUBY_ENGINE == "jruby"
lockfile <<-L
GEM
remote: https://gem.repo4
specs:
platform_specific (1.0)
PLATFORMS
ruby
DEPENDENCIES
platform_specific
BUNDLED WITH
#{Bundler::VERSION}
L
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"
gem "platform_specific", :force_ruby_platform => true
G
expect(the_bundle).to include_gems "platform_specific 1.0 ruby"
end
end
end
end
|