summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBundlerbot <bot@bundler.io>2019-08-13 09:59:44 +0000
committerBundlerbot <bot@bundler.io>2019-08-13 09:59:44 +0000
commit10b2118130fc3a7c095697446785267550a4a136 (patch)
tree53392dd3c5f8ed2d1273e6f68ab89b60f0430462
parentde3c5692dd6651f76f26487de64f2f493e3f093f (diff)
parent220c54b7faf056f29b2403bd27b4f8caa53f9aa5 (diff)
downloadbundler-10b2118130fc3a7c095697446785267550a4a136.tar.gz
Merge #7294
7294: Stop printing deprecation messages during specs r=deivid-rodriguez a=deivid-rodriguez ### What was the end-user problem that led to this PR? The problem was that that test suite prints some deprecation messages to the screen and I think that's unintented. See for example https://travis-ci.org/bundler/bundler/jobs/568969249. ### What was your diagnosis of the problem? My diagnosis was that bundler is using a different UI than the one intented sometimes. ### What is your fix for the problem, implemented in this PR? My fix is to make sure all deprecation messages go through bundler's UI. ### Why did you choose this fix out of the possible options? I chose this fix because it stops deprecation messages from being interleaved with other output during the specs. Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
-rw-r--r--lib/bundler/shared_helpers.rb20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
index 00ff541598..62a292fcee 100644
--- a/lib/bundler/shared_helpers.rb
+++ b/lib/bundler/shared_helpers.rb
@@ -134,8 +134,9 @@ module Bundler
return unless bundler_major_version >= major_version && prints_major_deprecations?
@major_deprecation_ui ||= Bundler::UI::Shell.new("no-color" => true)
- ui = Bundler.ui.is_a?(@major_deprecation_ui.class) ? Bundler.ui : @major_deprecation_ui
- ui.warn("[DEPRECATED] #{message}")
+ with_major_deprecation_ui do |ui|
+ ui.warn("[DEPRECATED] #{message}")
+ end
end
def print_major_deprecations!
@@ -212,6 +213,21 @@ module Bundler
private
+ def with_major_deprecation_ui(&block)
+ ui = Bundler.ui
+
+ if ui.is_a?(@major_deprecation_ui.class)
+ yield ui
+ else
+ begin
+ Bundler.ui = @major_deprecation_ui
+ yield Bundler.ui
+ ensure
+ Bundler.ui = ui
+ end
+ end
+ end
+
def validate_bundle_path
path_separator = Bundler.rubygems.path_separator
return unless Bundler.bundle_path.to_s.split(path_separator).size > 1