diff options
| -rw-r--r-- | lib/bundler/dsl.rb | 11 | ||||
| -rw-r--r-- | spec/bundler/bundler/dsl_spec.rb | 14 | ||||
| -rw-r--r-- | spec/bundler/commands/cache_spec.rb | 14 |
3 files changed, 38 insertions, 1 deletions
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index 5bfaa70e5b..d9cc3e0f34 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -413,6 +413,7 @@ module Bundler next if VALID_PLATFORMS.include?(p) raise GemfileError, "`#{p}` is not a valid platform. The available options are: #{VALID_PLATFORMS.inspect}" end + deprecate_legacy_windows_platforms(platforms) # Save sources passed in a key if opts.key?("source") @@ -493,6 +494,16 @@ module Bundler end end + def deprecate_legacy_windows_platforms(platforms) + windows_platforms = platforms.select {|pl| pl.to_s.match?(/mingw|mswin/) } + return if windows_platforms.empty? + + windows_platforms = windows_platforms.map! {|pl| ":#{pl}" }.join(", ") + message = "Platform #{windows_platforms} is deprecated. Please use platform :windows instead." + removed_message = "Platform #{windows_platforms} has been removed. Please use platform :windows instead." + Bundler::SharedHelpers.major_deprecation 2, message, removed_message: removed_message + end + def check_path_source_safety return if @sources.global_path_source.nil? diff --git a/spec/bundler/bundler/dsl_spec.rb b/spec/bundler/bundler/dsl_spec.rb index f5fc0c7bbe..9dca4ade05 100644 --- a/spec/bundler/bundler/dsl_spec.rb +++ b/spec/bundler/bundler/dsl_spec.rb @@ -221,6 +221,11 @@ RSpec.describe Bundler::Dsl do to raise_error(Bundler::GemfileError, /is not a valid platform/) end + it "raises a deprecation warning for legacy windows platforms" do + expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, /\APlatform :mswin, :x64_mingw is deprecated/, removed_message: /\APlatform :mswin, :x64_mingw has been removed/) + subject.gem("foo", platforms: [:mswin, :jruby, :x64_mingw]) + end + it "rejects empty gem name" do expect { subject.gem("") }. to raise_error(Bundler::GemfileError, /an empty gem name is not valid/) @@ -285,6 +290,15 @@ RSpec.describe Bundler::Dsl do end end + describe "#platforms" do + it "raises a deprecation warning for legacy windows platforms" do + expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, /\APlatform :mswin64, :mingw is deprecated/, removed_message: /\APlatform :mswin64, :mingw has been removed/) + subject.platforms(:mswin64, :jruby, :mingw) do + subject.gem("foo") + end + end + end + context "can bundle groups of gems with" do # git "https://github.com/rails/rails.git" do # gem "railties" diff --git a/spec/bundler/commands/cache_spec.rb b/spec/bundler/commands/cache_spec.rb index ee05bf2e49..c4d83f0542 100644 --- a/spec/bundler/commands/cache_spec.rb +++ b/spec/bundler/commands/cache_spec.rb @@ -221,16 +221,28 @@ RSpec.describe "bundle cache" do expect(bundled_app("vendor/cache/myrack-1.0.0.gem")).to exist end - it "puts the gems in vendor/cache even for legacy windows rubies" do + it "puts the gems in vendor/cache even for legacy windows rubies, but prints a warning", bundler: "< 3" do gemfile <<-D source "https://gem.repo1" gem 'myrack', :platforms => [:ruby_20, :x64_mingw_20] D bundle "cache --all-platforms" + expect(err).to include("deprecated") expect(bundled_app("vendor/cache/myrack-1.0.0.gem")).to exist end + it "prints an error when using legacy windows rubies", bundler: "3" do + gemfile <<-D + source "https://gem.repo1" + gem 'myrack', :platforms => [:ruby_20, :x64_mingw_20] + D + + bundle "cache --all-platforms", raise_on_error: false + expect(err).to include("removed") + expect(bundled_app("vendor/cache/myrack-1.0.0.gem")).not_to exist + end + it "does not attempt to install gems in without groups" do build_repo4 do build_gem "uninstallable", "2.0" do |s| |
