summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick LaMuro <nicklamuro@gmail.com>2016-07-25 23:31:27 -0500
committerNick LaMuro <nicklamuro@gmail.com>2016-07-25 23:31:27 -0500
commit2ac26bc88ba30b28aba6e11c9b2d04cdb0276a25 (patch)
treeb568020dbe3a3213da4f514f8f3237ef05c9c87e
parentd761d20a25381058804b5d40348f38188dd98172 (diff)
downloadbundler-2ac26bc88ba30b28aba6e11c9b2d04cdb0276a25.tar.gz
Update Bundler::Retry newlines
When using Bundler::Retry in conjunction with "dots" for regular printing, the retry messages show up inline with the dots, then the dots continue on the next line. It reads a bit better to have the retry messages show up on a new line after the dots, then allow the dots to continue on the same line, so that the dots now represent the status for the retry. When in debug, just print the retry message as we always have. The new line will assumed to not be necessary before the message, since the standard is to print newlines after everything in debug mode, and a newline will then also follow the retry message.
-rw-r--r--lib/bundler/retry.rb3
-rw-r--r--spec/bundler/retry_spec.rb33
2 files changed, 35 insertions, 1 deletions
diff --git a/lib/bundler/retry.rb b/lib/bundler/retry.rb
index bf4d6ab7f7..fb79dabff0 100644
--- a/lib/bundler/retry.rb
+++ b/lib/bundler/retry.rb
@@ -45,7 +45,8 @@ module Bundler
@failed = true
raise e if last_attempt? || @exceptions.any? {|k| e.is_a?(k) }
return true unless name
- Bundler.ui.warn "Retrying#{" #{name}" if name} due to error (#{current_run.next}/#{total_runs}): #{e.class} #{e.message}"
+ Bundler.ui.info "" unless Bundler.ui.debug? # Add new line incase dots preceded this
+ Bundler.ui.warn "Retrying#{" #{name}" if name} due to error (#{current_run.next}/#{total_runs}): #{e.class} #{e.message}", Bundler.ui.debug?
end
def keep_trying?
diff --git a/spec/bundler/retry_spec.rb b/spec/bundler/retry_spec.rb
index cafa099b51..665ba9f2df 100644
--- a/spec/bundler/retry_spec.rb
+++ b/spec/bundler/retry_spec.rb
@@ -46,4 +46,37 @@ describe Bundler::Retry do
end.to raise_error(error)
expect(attempts).to eq(1)
end
+
+ context "logging" do
+ let(:error) { Bundler::GemfileNotFound }
+ let(:failure_message) { "Retrying test due to error (2/2): #{error} #{error}" }
+
+ context "with debugging on" do
+ it "print error message with newline" do
+ allow(Bundler.ui).to receive(:debug?).and_return(true)
+ expect(Bundler.ui).to_not receive(:info)
+ expect(Bundler.ui).to receive(:warn).with(failure_message, true)
+
+ expect do
+ Bundler::Retry.new("test", [], 1).attempt do
+ raise error
+ end
+ end.to raise_error(error)
+ end
+ end
+
+ context "with debugging on" do
+ it "print error message with newlines" do
+ allow(Bundler.ui).to receive(:debug?).and_return(false)
+ expect(Bundler.ui).to receive(:info).with("")
+ expect(Bundler.ui).to receive(:warn).with(failure_message, false)
+
+ expect do
+ Bundler::Retry.new("test", [], 1).attempt do
+ raise error
+ end
+ end.to raise_error(error)
+ end
+ end
+ end
end