summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan McLellan <btm@loftninjas.org>2015-11-06 12:01:45 -0500
committerBryan McLellan <btm@loftninjas.org>2015-11-06 12:01:45 -0500
commita5d015215b2bfe5f6cc485ddf006db91ff486f83 (patch)
tree3fc08a2290c8fa654f14117d07b2b343b397244a
parent2e9789882242f62d60dc687a68b31c4b2488def7 (diff)
parentbd18b913954333f67dc4da4dc3f330298247b3f1 (diff)
downloadchef-a5d015215b2bfe5f6cc485ddf006db91ff486f83.tar.gz
Merge pull request #4137 from chef/btm/knife-backtrace
don't squash Chef::Config[:verbosity] on subsequent instances of Chef::Knife::Bootstrap
-rw-r--r--lib/chef/knife.rb2
-rw-r--r--spec/unit/knife_spec.rb15
2 files changed, 15 insertions, 2 deletions
diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb
index fed2ad4cfa..6fa29bea16 100644
--- a/lib/chef/knife.rb
+++ b/lib/chef/knife.rb
@@ -306,7 +306,7 @@ class Chef
# copy Mixlib::CLI over so that it can be configured in knife.rb
# config file
- Chef::Config[:verbosity] = config[:verbosity]
+ Chef::Config[:verbosity] = config[:verbosity] if config[:verbosity]
end
def parse_options(args)
diff --git a/spec/unit/knife_spec.rb b/spec/unit/knife_spec.rb
index 9ccd91775f..5ab8e84eac 100644
--- a/spec/unit/knife_spec.rb
+++ b/spec/unit/knife_spec.rb
@@ -63,6 +63,12 @@ describe Chef::Knife do
Chef::Knife.reset_config_loader!
end
+ it "does not reset Chef::Config[:verbosity to nil if config[:verbosity] is nil" do
+ Chef::Config[:verbosity] = 2
+ Chef::Knife.new
+ expect(Chef::Config[:verbosity]).to eq(2)
+ end
+
describe "after loading a subcommand" do
before do
Chef::Knife.reset_subcommands!
@@ -309,7 +315,7 @@ describe Chef::Knife do
expect(Chef::Config[:listen]).to be(false)
end
- context "verbosity is greater than zero" do
+ context "verbosity is one" do
let(:fake_config) { "/does/not/exist/knife.rb" }
before do
@@ -327,6 +333,13 @@ describe Chef::Knife do
knife.configure_chef
end
end
+
+ it "does not humanize the exception if Chef::Config[:verbosity] is two" do
+ Chef::Config[:verbosity] = 2
+ allow(knife).to receive(:run).and_raise(Exception)
+ expect(knife).not_to receive(:humanize_exception)
+ expect { knife.run_with_pretty_exceptions }.to raise_error(Exception)
+ end
end
end