-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Add config variable and check for platform warnings #6309
Changes from 2 commits
6d563b0
94d399d
16831ef
5e73a89
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,21 +230,46 @@ | |
expect(out).not_to match(/Could not find gem 'some_gem/) | ||
end | ||
|
||
it "prints a helpful warning when a dependency is unused on any platform" do | ||
simulate_platform "ruby" | ||
simulate_ruby_engine "ruby" | ||
context "when disable_platform_warnings is false (by default)" do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test doesn't need a |
||
before { bundle! "config disable_platform_warnings false" } | ||
|
||
gemfile <<-G | ||
source "file://#{gem_repo1}" | ||
it "prints a helpful warning when a dependency is unused on any platform" do | ||
simulate_platform "ruby" | ||
simulate_ruby_engine "ruby" | ||
|
||
gem "rack", :platform => [:mingw, :mswin, :x64_mingw, :jruby] | ||
G | ||
gemfile <<-G | ||
source "file://#{gem_repo1}" | ||
|
||
gem "rack", :platform => [:mingw, :mswin, :x64_mingw, :jruby] | ||
G | ||
|
||
bundle! "install" | ||
bundle! "install" | ||
|
||
expect(out).to include <<-O.strip | ||
The dependency #{Gem::Dependency.new("rack", ">= 0")} will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`. | ||
O | ||
expect(out).to include <<-O.strip | ||
The dependency #{Gem::Dependency.new("rack", ">= 0")} will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`. | ||
O | ||
end | ||
end | ||
|
||
context "when disable_platform_warnings is true" do | ||
before { bundle! "config disable_platform_warnings true" } | ||
|
||
it "doesnot print the warning when a dependency is unused on any platform" do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My bad! |
||
simulate_platform "ruby" | ||
simulate_ruby_engine "ruby" | ||
|
||
gemfile <<-G | ||
source "file://#{gem_repo1}" | ||
|
||
gem "rack", :platform => [:mingw, :mswin, :x64_mingw, :jruby] | ||
G | ||
|
||
bundle! "install" | ||
|
||
expect(out).not_to include <<-O.strip | ||
The dependency #{Gem::Dependency.new("rack", ">= 0")} will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a lot to match exactly against in the output which could easily be missed if we change the test or behavior. I would match with:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool. Will change it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. However, using include is throwing a TypeError TypeError:
no implicit conversion of Regexp into String How about using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, that was a typo on my part. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using expect(out).not_to match(/The dependency (.*) will be unused/) does the trick. Is it good? |
||
O | ||
end | ||
end | ||
end | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would reword this to be a bit more explicit, something like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 😄