mirror of
https://github.com/inspec/inspec
synced 2024-11-26 22:50:36 +00:00
count controls in the summary output. Fix #852
This commit is contained in:
parent
31a7d58473
commit
6c91183995
1 changed files with 30 additions and 1 deletions
|
@ -87,7 +87,7 @@ class InspecRspecMiniJson < RSpec::Core::Formatters::JsonFormatter
|
|||
end
|
||||
|
||||
class InspecRspecJson < InspecRspecMiniJson
|
||||
RSpec::Core::Formatters.register self, :start, :stop
|
||||
RSpec::Core::Formatters.register self, :start, :stop, :dump_summary
|
||||
attr_writer :backend
|
||||
|
||||
def initialize(*args)
|
||||
|
@ -133,6 +133,35 @@ class InspecRspecJson < InspecRspecMiniJson
|
|||
@output_hash[:other_checks] = missing
|
||||
end
|
||||
|
||||
def dump_summary(summary)
|
||||
super(summary)
|
||||
total = 0
|
||||
failed = 0
|
||||
skipped = 0
|
||||
passed = 0
|
||||
|
||||
@profiles_info.each do |_name, profile|
|
||||
total += profile[:controls].length
|
||||
profile[:controls].each do |_control_name, control|
|
||||
next unless control[:results]
|
||||
if control[:results].any? { |r| r[:status] == 'failed' }
|
||||
failed += 1
|
||||
elsif control[:results].any? { |r| r[:status] == 'skipped' }
|
||||
skipped += 1
|
||||
else
|
||||
passed += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@output_hash[:control_summary] = {
|
||||
total: total,
|
||||
failed: failed,
|
||||
skipped: skipped,
|
||||
passed: passed,
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def profile_info(profile)
|
||||
|
|
Loading…
Reference in a new issue