From 76123dbbdd9365b2f2b6f20b0e4158dcdf12599c Mon Sep 17 00:00:00 2001 From: Pete Higgins Date: Wed, 22 Jul 2020 12:33:14 -0700 Subject: Set log level to :fatal in test to prevent excess logging. Signed-off-by: Pete Higgins --- spec/functional/knife/ssh_spec.rb | 11 ----------- spec/spec_helper.rb | 3 +++ spec/support/chef_helpers.rb | 8 -------- spec/support/shared/functional/file_resource.rb | 1 - spec/unit/application_spec.rb | 5 ++++- 5 files changed, 7 insertions(+), 21 deletions(-) (limited to 'spec') diff --git a/spec/functional/knife/ssh_spec.rb b/spec/functional/knife/ssh_spec.rb index 803fbff0a3..1d4aff15b5 100644 --- a/spec/functional/knife/ssh_spec.rb +++ b/spec/functional/knife/ssh_spec.rb @@ -36,17 +36,6 @@ describe Chef::Knife::Ssh do allow(Net::SSH).to receive(:configuration_for).and_return(ssh_config) end - # Force log level to info. - around do |ex| - old_level = Chef::Log.level - begin - Chef::Log.level = :info - ex.run - ensure - Chef::Log.level = old_level - end - end - describe "identity file" do context "when knife[:ssh_identity_file] is set" do before do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e6d1bcc3ce..6c04291e89 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -243,6 +243,9 @@ RSpec.configure do |config| Chef::Log.setup! + Chef::Config[:log_level] = :fatal + Chef::Log.level(Chef::Config[:log_level]) + # By default, treat deprecation warnings as errors in tests. Chef::Config.treat_deprecation_warnings_as_errors(true) diff --git a/spec/support/chef_helpers.rb b/spec/support/chef_helpers.rb index c566ced8b1..1fdd24c033 100644 --- a/spec/support/chef_helpers.rb +++ b/spec/support/chef_helpers.rb @@ -18,14 +18,6 @@ CHEF_SPEC_DATA = File.expand_path(File.dirname(__FILE__) + "/../data/") CHEF_SPEC_ASSETS = File.expand_path(File.dirname(__FILE__) + "/../functional/assets/") CHEF_SPEC_BACKUP_PATH = File.join(Dir.tmpdir, "test-backup-path") -Chef::Config[:log_level] = :fatal -Chef::Config[:persistent_queue] = false -Chef::Config[:file_backup_path] = CHEF_SPEC_BACKUP_PATH - -Chef::Log.init(StringIO.new) -Chef::Log.level(Chef::Config.log_level) -Chef::Config.solo(false) - def sha256_checksum(path) OpenSSL::Digest.hexdigest("SHA256", File.read(path)) end diff --git a/spec/support/shared/functional/file_resource.rb b/spec/support/shared/functional/file_resource.rb index 7547d119bb..8319dee41e 100644 --- a/spec/support/shared/functional/file_resource.rb +++ b/spec/support/shared/functional/file_resource.rb @@ -366,7 +366,6 @@ shared_examples_for "a configured file resource" do include_context "diff disabled" before do - Chef::Log.level = :info Chef::Config[:ssl_verify_mode] = :verify_none end diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb index 4e77084644..aa916d0793 100644 --- a/spec/unit/application_spec.rb +++ b/spec/unit/application_spec.rb @@ -26,7 +26,6 @@ describe Chef::Application do allow(@app).to receive(:trap) allow(Dir).to receive(:chdir).and_return(0) allow(@app).to receive(:reconfigure) - Chef::Log.init(STDERR) end after do @@ -253,6 +252,10 @@ describe Chef::Application do end context "when log_level is not set" do + before do + Chef::Config.delete(:log_level) + end + it_behaves_like "log_level_is_auto" end -- cgit v1.2.1