Skip to content

Commit

Permalink
Merge pull request #123 from chef/tduffield/tweak-logging-for-clarity
Browse files Browse the repository at this point in the history
Tweak logging for clarity
  • Loading branch information
tduffield authored Dec 8, 2016
2 parents c1f4302 + d60073c commit 01adede
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/kitchen/verifier/inspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,25 @@ def call(state)
opts[:attrs] = config[:attrs]
opts[:attributes] = Hashie.stringify_keys config[:attributes] unless config[:attributes].nil?

# setup logger
::Inspec::Log.init(STDERR)
::Inspec::Log.level = Kitchen::Util.from_logger_level(logger.level)

# initialize runner
runner = ::Inspec::Runner.new(opts)

# add each profile to runner
tests = collect_tests
tests.each { |target| runner.add_target(target, opts) }
profile_ctx = nil
tests.each do |target|
profile_ctx = runner.add_target(target, opts)
end

profile_ctx ||= []
profile_ctx.each do |profile|
logger.info("Loaded #{profile.name} ")
end

logger.debug("Running tests from: #{tests.inspect}")
exit_code = runner.run
return if exit_code == 0
raise ActionFailed, "Inspec Runner returns #{exit_code}"
Expand Down Expand Up @@ -127,7 +138,6 @@ def local_suite_files
end

base = File.join(base, "inspec") if legacy_mode
logger.info("Using `#{base}` for testing")

# only return the directory if it exists
Pathname.new(base).exist? ? [{ :path => base }] : []
Expand Down

0 comments on commit 01adede

Please sign in to comment.