diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 69e782402c..0d743c7205 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -48,6 +48,11 @@ def colorize(str, color) require 'webmock/rspec' WebMock.disable_net_connect! +# Configure test logger +logdest = StringIO.new +logdest = File.new(ENV['FACTER_TEST_LOG'], 'w') if ENV['FACTER_TEST_LOG'] +logger = Logger.new(logdest) + # Configure RSpec RSpec.configure do |config| # Enable flags like --only-failures and --next-failure @@ -77,10 +82,13 @@ def colorize(str, color) end config.before(:all) do - Facter::Log.class_variable_set(:@@logger, Logger.new(StringIO.new)) # rubocop:disable Style/ClassVars + Facter::Log.class_variable_set(:@@logger, logger) # rubocop:disable Style/ClassVars end - config.before do + config.before do |test| + m = test.metadata + logger.info("*** BEGIN TEST #{m[:file_path]}:#{m[:line_number]}") + LegacyFacter.clear Facter.clear_messages end